Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a default button for showing the current location in GMSMapView sdk

I am adding a custom button and adding the action

CLLocationCoordinate2D target=CLLocationCoordinate2DMake(currentLocation.coordinate.latitude,currentLocation.coordinate.longitude);
     [mapView_ animateToLocation:target]; 

for moving the map to current location.Is there a default button in the sdk ?

like image 949
Jeff Avatar asked Jan 17 '26 02:01

Jeff


1 Answers

Yes there is a default button to show current location of map. It will be only visible when you set myLocationEnable in the API.

From the documentation

Google Map SDK for iOS

By default, no location data is shown on the map. You may enable the blue "My Location" dot and compass direction by setting myLocationEnabled on GMSMapView.

mapView_.myLocationEnabled = YES;

Enabling this feature will also provide the user's current location through the myLocation property. This property may not be immediately available - for example, if the user is prompted by iOS to allow access to this data. It will be nil in this case.

NSLog(@"User's location: %@", mapView_.myLocation);
like image 104
Kampai Avatar answered Jan 19 '26 17:01

Kampai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!