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

Programmatically zooming on the map/marker

Hello SyncfusionTeam,

I'm using the sfMap and I need to implement something that will allow a zoom on the map.

US : When a user loads the map, if he clicks on a given marker, the zoom should adapt to show only the needed part of the map.

For example : having a country map, when user select a region, the zoom should be only on the region.

I tried to do some tricks with properties MaxZoom and MinZoom but nothing's working as expected.

Is there a way to access zoom property without user interaction ?


4 Replies

YS Yogapriya Shanmugam Syncfusion Team November 12, 2018 08:43 AM UTC

Hi Rjuken, 
Query: Programmatically zoom on map marker. 
By selecting the map marker, you can programmatically zoom the area around it and this can be achieved by changing the GeoCoordinates and ZoomLevel property in the MarkerSelected event. 
By Specifying the marker latitude and longitude values to the GeoCoordinates property, maps will be centered at the specified location. 
To zoom the map, you can increase the ZoomLevel property.  
Please find the code snippet below, 
private void ImageryLayer_MarkerSelected(object sender, Syncfusion.SfMaps.XForms.MarkerSelectedEventArgs e) 
            double latitude = Convert.ToDouble(e.MapMarker.Latitude); 
            double longitude = Convert.ToDouble(e.MapMarker.Longitude); 
            layer.GeoCoordinates = new Point(latitude, longitude); 
            sfmap.ZoomLevel = 4; 
We have also prepared a sample for the same. You can download the sample from the below link. 
Please find the screenshot below, 
Before Zooming 
After Zooming (area around the marker is zoomed) 

RD Rjuken Developments December 3, 2018 11:17 PM UTC

Hello SyncfusionTeam,

Thank you for this complete answer ! I forgot to tell you that I'm using ShapeFileLayer and not ImageryLayer. 

Is it achievable on a shapeLayer too with another method ? I know ShapeFileLayer does not contain such property as Geocoordinates but ZoomLevel property is accessible, so there might be a way can't figure out.


MP Michael Prabhu M Syncfusion Team December 4, 2018 11:31 AM UTC

Hi Rjuken, 
We have analyzed your query and we like to let you know that currently, we do have programmatic zooming support with specified coordinate at the center for shape file layer as in Imagery layer. We have considered this as a feature request and logged it in to our feature management system. 
While this feature itself is important we cannot provide you an exact timeline on when this feature will be available in our suite, this feature will be available in any of our upcoming volume releases. 


RD Rjuken Developments December 5, 2018 10:26 AM UTC

Hello SyncfusionTeam,

Thank you for your fast answer. Yes its a really important feature for us, hope will be available in the next releases. 


Live Chat Icon For mobile
Up arrow icon