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 add map markers dynamically to the tapped location

Platform: Xamarin.Forms |
Control: SfMaps

Using SfMaps, you can add markers dynamically to the desired location just by tapping at the required locations. You can achieve this by converting the screen points to the corresponding latitude and longitude coordinates and add markers to the maps.


The following code snippet demonstrates how to add markers to a layer.


public void AddMarker()
    var layer = this.Layers[0];
    Point longitudeLatitude = layer.GetLatLonFromPoint(new Point(PointX, PointY));  // Getting longitude and latitude values from touch points.
    layer.Markers.Add(new CustomMarker()
        Latitude = longitudeLatitude.Y.ToString(),
        Longitude = longitudeLatitude.X.ToString()


Markers can be specified as demonstrated in the following code snippet.


                    <local:CustomMarker Label = "California" Latitude = "37" 
                                    Longitude = "-120" x:Name="marker" />
                        <Image HorizontalOptions="Center" 
                               Source="{Binding Image}"
                               VerticalOptions="Center" HeightRequest="15" WidthRequest="15"/>


Output screenshot

Adding Markers at tapped points using Xamarin SfMaps


Sample for adding markers at the tapped points: https://github.com/SyncfusionExamples/How-to-add-map-markers-dynamically-at-the-tapped-location

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment
Aman Kharzoum
Nov 21, 2019

Hi I used this sample, but using Touch Events prevent me from moving around Map without Adding any Markers in both Android and iOS like using Touch events prevent any other Events on Map! Mmm, How could I solve this?


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