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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to show the current GPS location in Xamarin.Forms maps (SfMaps)

Platform: Xamarin.Forms |
Control: SfMaps



This article explains how to show the current GPS location using the Syncfusion Xamarin.Forms maps.


To show the current GPS location, you can get the current location of device by using the Geolocation.GetLastKnownLocationAsync() method of Xamarin.Essentials and add the marker pin on maps using the current location values.

The following steps demonstrate how to add the marker on current geolocation:

Step 1: Initialize the SfMaps control and add Imagery layer with OSM type to the layer collection of the control.

<maps:SfMaps x:Name="sfmap">
        <maps:ImageryLayer LayerType="OSM"


Step 2: Create a custom marker by extending the MapMarker with Image property to show pin image as marker and define the MarkerTemplate to show pin marker on Xamairn.Forms Map.

      <Image x:Name="markerImage"
             Source="{Binding Image}"
             WidthRequest="15" />


public class CustomMarker : MapMarker
    public ImageSource Image { get; set; }
    public CustomMarker()
        Image = ImageSource.FromResource("MarkerOnGPSLocation.pin.png");


Step 3: Get the current location from Xamarin.Essentials’s Geolocation.GetLaskKnownLocationAsync() API and add the marker to Markers collection of Imagery layer with obtained latitude and longitude values.

public MainPage()
private async void AddMarkerInCurrentLocation()
        var location = await Geolocation.GetLastKnownLocationAsync();
        if (location != null)
            CustomMarker marker = new CustomMarker();
            marker.Latitude = location.Latitude.ToString();
            marker.Longitude = location.Longitude.ToString();
            this.layer.Markers = new ObservableCollection<MapMarker> { marker };
    catch (Exception ex)
        // Handle not supported on device exception
        await Application.Current.MainPage.DisplayAlert("Alert", ex.Message, "Ok");


Step 4: To display the map with specific distance around current location by specifying the Radius with DistanceType properties of imagery layer.

this.layer.GeoCoordinates = new Point(location.Latitude, location.Longitude);
this.layer.Radius = 5;
this.layer.DistanceType = DistanceType.KiloMeter;



Map showing current GPS location


You can find the complete sample in this link.

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment
Martin Márki
Oct 30, 2020


Is it possible to show this position (and update if it changes) when there is no internet connection?

I tried with layer.CanCacheTiles = true; but it doesn't work.

Regards, Martin

Ramya Soundar Rajan [Syncfusion]
Nov 02, 2020

Hi Martin,

We would like to let you know that the image layer tile images are loaded from a respected tile server. So, you need an internet access to download the tiles on the map for the first time and it was stored in the application cache when CanCacheTiles is set to true. Once the given location images are downloaded, they are loaded from the application cache.

Regards, Ramya S

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile