Updating your current location on Google Maps using UIWebview in iOS

I have a WebView application that I created in an application that calls Google Maps Directions to determine the route between the current location and the POI.

The entire google map with directions loads as soon as the WebView loads. Now I need to update the map with my current location. Like in, I want a flag / icon representing my current location to move with the user while traveling. But the only way I can do this so far is to reload the entire map, causing a new location.

It is very expensive to use time and data. Is there a better way that I am missing?

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

+4
source share
2 answers

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

+3
source

u can use .. CLLocationManager to get the location of the user UIWebview is not used to determine the location.

0
source

Source: https://habr.com/ru/post/1442709/


All Articles