We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

retrieve current location programatically

I'm using the sfMap and I need to find usre current location and allow to zoom on the map.
Is there any way to retrieve location (programatically ) on SfMaps?


3 Replies

BK Bharathiraja K Syncfusion Team September 26, 2019 11:12 AM UTC

Hi Maryam, 
Greetings from Syncfusion. To find out the Current Geo location, we have to refer Xamarin.Essential package. After getting GeoCoordinate  location, we need to update this value to map markers to pin on the Maps. Please refer the below code snippet to get the GeoCoordinate points of current location. 
private async void AddMarkerInCurrentLocation()
                // To get the current location
                var location = await Geolocation.GetLastKnownLocationAsync();
                // Add the marker on the current location
                if (location != null)
                    CustomMarker marker = new CustomMarker();
                    marker.Latitude = location.Latitude.ToString();
                    marker.Longitude = location.Longitude.ToString();
            catch (Exception ex)
                // Handle not supported on device exception
                await Application.Current.MainPage.DisplayAlert("Alert", ex.Message, "Ok");
Please refer the below help document for adding Markers on Map.  
We have prepared a sample based on your requirement and it can be downloaded from the below link. 

YE Yemoku March 2, 2021 08:35 AM UTC


Is this sample code/project still available? I am getting an error on the link.

Many thanks,


SS Sridevi Sivakumar Syncfusion Team March 3, 2021 08:01 AM UTC

Hi Yemoku,

We would like to inform you that the below KB document will assist you to show the current GPS location in SfMaps.


Let us know if you need any further assistance.

Sridevi S.

Live Chat Icon For mobile
Up arrow icon