google static maps with enc path is not always working - google-maps-static-api

i have implement a static map that show a route based on
routes[0]->overview_polyline
and i also have add the start and end markers
The problem is that is not always working and i assume that there is a problem with overview_polyline but i can not figure out
This is a working static map that show both markets and route
https://maps.googleapis.com/maps/api/staticmap?size=650x400&path=enc:q|wfFs}yoCuEhLyC`Gk#rI{#pLoF|LyEiAaHrE{VlPzAxNsAnK{Plc#gl#jbAon#|sAuN~b#uRr\}Rl\iIxWbCr}#fG`d#iJnp#{Ez]v#nhA~ItjAgGzn#}Ib[wQfAit#vAcf#rOig#h\wWpc#ie#~uAmF~aAtRrbAsLdVgZf_#_LjrAuEjp#^|_#n^fr#`_#pi#h\|Z|y#|`#rRhZ?~a#sGz\nLjiB~Yh`Cvr#vqBjc#`qAf^xoBvXfoAp|#bdBht#xwAhC~ZqAb^aGlt#fHbe#jp#rfAfE`a#oBna#cMlr#aXljATnx#xIbp#dA~r#_Ghm#jKds#`O~z#nAj|#tP`h#|nAvrCz]fw#hIx^nLzu#|Nz[jZjl#vh#ndAny#n_Btv#n}AQfl#{Rfm#wTl`#eQdv#Cni#nGjb#zL|k#~Afj#iCva#eJblDrE`n#`Mbe#eAxUiJxTHj\`Oh_#nRtcA?lWsJpq#wJfy#w#rt#pG|w#zGfh#`FfqCpSl{BnWvzAxLt{#tD~}#]`|#cGxj#}Ujy#_Uv^yUt|#oHdk#{^xbBap#jkB{\bu#gYd`#wd#`c#}_#`Wid#lR_b#rD}SfU{b#rXgh#p[wVw#giAZe\{BwNXq^xNm|#~^em#nd#uiAr{Au_#hrA}Zf}#g]p}#eKp^eBxd#wGrWcQjPwNbP{ElV}o#v}Bl#hh#cArn#cO`d#mNv^wBnU}Wtw#sM|[yAvTyKl^ae#|y#mM|k#aOb`#cGvd#{Wr}Agr#foAkk#p}#ij#pw#aZfr#^lm#hAzbAd\lkB{Krs#oMrXeNpj#}Jh`AbCpQfS`s#`Avj#_]``Cwh#rbA?hc#wTty#iSffAs]`n#{Xd\cg#zb#ai#lhAc#n_AyBlpAwCfx#~Frd#xNpb#y#~kAsFjZuYn_#uFp[v#fZcGjs#{F`j#cGdxAeXjyA{Kx{#}HjaAiAde#sOr[}IvzAe[`c#iNpNu[h^mM`ZmNlXgJfY{ZfeAwWzkA}h#rjAqt#j}Ak]j]qr#j\qk#dTg\`g#wNtJuWzUma#n~#iUpd#_Wz[iE~S{Gld#yEpMuRzIuVpNmp#nvAeYll#{_#vWuNtZaa#jq#oYv_#qf#tsA}Nli#mAlXeHd|#xHv^uAjx#lLl\|Bhf#iCli#xGpi#}If{#fFn[d#py#uFd|#vCftAq#h`#vBhb#tB`m#jUrj#rZ|WrOjb#rJji#rPte#h`#f|#dq#lwAjXtm#dY|^ti#|m#veAzbAb}#ri#fKxH_CtQ^f#bWzHlQfPrQzY&markers=color:green|label:A|37.9746479,23.73097699999994&markers=color:red|label:B|38.24670270000001,21.7345758000000162
This route is not working
https://maps.googleapis.com/maps/api/staticmap?size=650x400&path=enc:q|wfFs…n#y#zHc#hCg#jCmASUnDUbDc#tGWzCEp#MxBSnBCRM?uDlCkA{AY_#[c#IHmAjA[^e#Z}At#aC`BeIvFu#^cBfA{GlEKF\fCb#lDXpBJhAE~#[rBMv#c#bDgAvIW~#aA~BKPcBjDoAbCsA~BeCrDeEnG}D~GmDdGeE~G}F~J{B~D}DzGUNUZ_A~AaHjLIXAf#Bf#H^^t#FR#PbDrDpDvEbAlAjAvApD`E~#`A`KrLX\v#|#vCjDr#t#`Av#rKxGnEpCfFjDtHdFbC~AhAn#lFdD~E~CpMjIzBtAn#b#lIpFlC~A\LnBp#j#JbAFrB?|Ba#bBm#vBkAdG}C`#WvBwAxAgAxAaAbAk#p#Wp#Mz#G^AdAHpCt#t#Vh#V|J`DlHbCpKnDbBd#lB^~Bd#rCr#|HzBzIhCfAXfAP`F^z#FbEVhDJnJFlGBjC#d#Ln#?ZHb#V^j#Jb#Fr#?bA?bGEpBAzNE|DPzK#zAAr#KfASx#a#z#mDbGyGfLeBzCs#~Am#fB{#bE_#|Bw#dJ]xENd##l#FbBDz#DN`#P`Bx#lCtAlD~AdAd#vA|#vIhHvAdA^Vx#n#CH&markers=color:green|label:A|37.9746479,23.73097699999994&markers=color:red|label:B|37.9429712,23.646971099999973
Its only displays the markers without the route
i have implement the code from here
Google static maps with directions
Can any help me make this work, any help appreciated

When I check the encoded polyline from the second example in the Interactive Polyline encoder utility
https://developers.google.com/maps/documentation/utilities/polylineutility
I can see that the route is located somewhere in the sea as shown in the screenshot
Can you post the original Directions API request that returns this encoded polyline, please?

Related

How to zoom at particular point in google maps added to uiwebview?

I have google maps added to UIWebview. I want to zoom the map to destination location. Destination location is passed programmatically.
How do I do it? I tried setting parameter z=10 while loading google maps url but it doesn't zoom at particular point.
Please help
Thanks
Why you dont use MapKit?
It uses google map to provide the map.
http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MapKit_Framework_Reference/_index.html
if you really want to use google maps inside an webview you will need to do something like that:
http://maps.google.com/maps?q=24.197611,120.780512&z=10
where q=latitude,longitude
and you will need to know the latitude and longitude of the point you want to zoom
for more informations you can look at:
http://mapki.com/wiki/Google_Map_Parameters
I solved it with by adding certain parameters to the google maps url:
http://maps.google.com/?saddr=%#&daddr=%1.6f,%1.6f&ll=%#&sll=%#&sspn=0.015&output=embed&z=15

how to draw route from userlocation to some pin in iphone sdk?

I am implementing map based application in iPhone sdk. I want to give functionality in map view like Google maps directoins. means is at some location from that he selects one pin from multiple pins from MKPinAnnotationView. is it possible that user can get direction from his current location to selected pin location in MapView? user can select any aanonations from that he can get directions in some way of line to his current location to pin location. i have get some idea from here
but this all was some static data you can download this example.
here also apple example. but this example is only for track & draw line for user movement.
is it possible that user can get direction from his current location to selected pin location in MapView?
Yes. You can send a query to google maps api using your current location and the selected annotation location. When google responds with the route, you will use that polyline decoder method to decode the data and draw the route on your map view.
I have got all side idea from here
this can be useful for other developers also.
i have found some other examples also that can be also useful for other developers just google. you will find this is polyline link for user current location use this apple code
Here is Google direction api. Read it and use it.
For test purpose you can check this request
http://maps.googleapis.com/maps/api/directions/json?origin=28.459497,77.026638&destination=28.435600,77.009997&sensor=true
And use JSON Viewer to see the json response.

Driving Directions in the map

I have a view based application and in that I want to show driving directions on map.
I searched for it on google, I got the google maps driving directions api but I didn't got how to use it in program directly webview or is there any other way to use that api programmatically. Any help appreciated.
If you want my advice (and this is the way I do things), use an UIWebView and use a Javascript-based sample to to ask Google to draw directions for you.
It's easy!
Use this link:
http://maps.google.com/maps?f=q&saddr=25.612524,85.128281&daddr=28.574815,77.236545&output=kml
or
http://maps.google.com/maps?f=q&saddr=patna&daddr=new+delhi&output=kml
You can use both web services, one with lat and long ,where second one is with saddr(source address) and daddr(destination address). It gives you xml file parse it and make array of intermediately lat-long points . I think u know how to draw route on MKMapView with the help of Overlay class.
**If you need to finding lat long of given name of location ,use this link:
http://maps.google.co.in/maps?t=h&z=10&hl=en&format=p&q=new+delhi&output=kml
**Keep in mind that ,if location name have two or more then two words then it combines with + operator.
You should take a look at MKMapViewController for displaying maps. Take a look at this tutorial on how to draw routes with MKPolyline.

How to draw route in map in iphone

I want to draw route in map, for this I am storing latitude and longitude in my server. when this view opens it fetches all lat and long from server and plots it in mapView. Suppose server gets new lat and long this should show in mapView without closing this view, means map has plotted route if it gets new lat and long this route should continue from last point.
Apple supplied a demo application called Breadcrumb with the 2010 WWDC Developer videos that does exactly this. You can get the sample code from here: http://developer.apple.com/videos/wwdc/2010/
We wrote a category to mapKit that allow you to show route over the map :
http://code.google.com/p/octomapkit/
Very easy to use :
[youMap addRouteFrom:startCoord to:endCoord zommed:shouldZoom]
Hope this helps,
Vincent

google map link with marker (on iphone & android)

I've tried to open Google Map application on iphone & android. From iPhone developer reference website I am able to open the native google map from link.
http://maps.google.com/maps?ll=11.5558762589,104.921697935&z=15
However, I have trouble with adding a marker into the map. As in google static map, we can add markers into map. I wonder if we can do the same to google map link.
Hey Borey
You can add markers. But it has to be google's own preset marker.
Try this link :
http://maps.google.com/?q=5.352135,100.299683&z=17
Use q instead of ll and I think it will work.
Problems I saw:
1) Cannot choose your own marker
2) Cannot remove that 'additional marker' that tells you what's around that area.
I guess, that's the next best thing for you? For your info, I am using it too as I lack other choices.
The only way I am aware of for doing this is to use the My Maps feature of google maps. You can create a public map in My Maps. Add a marker using the toolbar in the map, then use the link button on the top right to get the URL of your public map.
Not sure how this looks on a mobile device, but I assume that it works.
Edit
Ok. So my assumption was incorrect. I tried this out on Android and iPhone and got the following results:
iPhone - Switches out to the maps application (no option to view in the browser), displays the correct region, but no markers.
Android - Gives you the option of viewing the URL in the browser or in maps. If you view in the browser, you get the correct region, but no markers.
Android - If you view on the maps application, you get the correct region and the markers.
So basically not very useful to you. When I have done this in my mobile web apps (not native), I have used static maps. You give up the dynamic functionality, but you get lots of flexibility with what gets rendered on the map.