Question

I have a WebView I created in app which calls Google Maps Directions to plot out the route between the Current Location and a POI.

The entire google map with directions is loaded as soon as the webView loads. Now I need to update the map with my current location. As in, I want the flag/icon representing my current location to move along with the user while he is travelling. But the only way I seem to be able to do this so far, is reloading the entire map by calling the new location.

This is very expensive in both time/data usage. Is there a better way that I'm missing ?

Here's my code :

CLLocationCoordinate2D destination = { 37.773768,-122.408638 }; 

NSString *googleMapsURLString = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f&output=embed",
                                            myLocation.coordinate.latitude, myLocation.coordinate.longitude, destination.latitude, destination.longitude];



NSURL *url=[NSURL URLWithString:googleMapsURLString];
NSURLRequest *requestObj=[NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];

Someone please help !!!

Was it helpful?

Solution

Use the GeolocationMarker from the Google Maps API 3 Utility Library. It was created for this purpose.

OTHER TIPS

u can use.. CLLocationManager for getting user's location UIWebview is not use for location fetching..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top