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

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

Related

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.

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.

How to Display offline map in iphone using Mapkit

How to Display offline map in iphone using mapkit?
if i use static image then how do i get current location and pin drop on it?
anyone has idea please suggest some solution.
Thank you.
Try this post Force MapKit use cached map tiles only/disable network programmatically
It tells about open source map OSM , helps offline map browsing.
Source from here http://developers.cloudmade.com/projects/show/iphone-sdk.
Hope this helps , or r u looking for some thing else.
Similar to What SDKs can be used for creating offline maps application for iPad/iPhone?
In iOS4+, you can use an image MKOverlay to overlay whatever you want on top of a MapKit map. You can provide a semi-transperant base map of your own providing to display when the underlying Google Map can not be loaded. But you can not control what MapKit is doing under the hood caching Google maps.

MKMapView Road Map

How to Get Route from user current Location to Destination location in MkMapView?
You need to handle that yourself. Get the gps data somewhere for the route and draw the lines yourself.
I don't think that's something allowed in Mapkit. I believe it's part of the restrictions to prevent Mapkit from being used for a turn by turn application.
You can use MapKit for showing maps, but when it comes to routing you'll have to launch out to the Maps app. In the URL launching Maps you can pass the destination's lat/long coordinates and have it place pin. The user can then find their way there from their current location.