4
votes

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 !!!

2
I think you would need to set the location managers distance filter to probably 5 meters... and do this. Yes, it is very memory consuming.... but I am pretty sure it is the only wayMCKapur
so reload the entire map each time you want to update current location ? That sounds very tedious. Is there no other way ? Google Devs on the forum please answer !!SashaZd
I don't think there is another way.MCKapur

2 Answers

3
votes
0
votes

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