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
close icon

centre map

I have begun experimenting with sfMap
I simply want to use OSM worldmap but zoomed to a particular location.
I can work out the zoom level required but I cant figure out how to (programmatically) pan to the required location.

I note a previous post over a year and a half ago said there was no functionality to centre a map
Is there now any way to achieve what I am trying to do ?

tia
JM

3 Replies

SS Sheik Syed Abthaheer M Syncfusion Team November 5, 2018 10:41 AM UTC

Hi John, 
Thanks for contacting Syncfusion Support. 
We can achieve your requirement of zooming the location by specifying the desired latitude and longitude in the GeoCoordinates property of imagery layer as like the below code snippet, 
         <maps:SfMaps ZoomLevel="3"> 
            <maps:SfMaps.Layers> 
                <maps:ImageryLayer x:Name="layer" GeoCoordinates="51.509, "-0.1180"> 
                    <maps:ImageryLayer.Markers> 
                        <maps:MapMarker  Label="London"  
                                         Latitude="51.509"  
                                         Longitude= "-0.1180"/> 
                        </maps:ImageryLayer.Markers> 
                </maps:ImageryLayer> 
            </maps:SfMaps.Layers> 
        </maps:SfMaps> 
 

Please find the output screen shot 
 
  
  
Please find the demo sample from below location 
Sample: MapsPanning 
Regards, 
Devi 




JM john murray November 5, 2018 12:31 PM UTC

many thanks 
I know you've all pretty much moved exclusively to xaml but it would help to see the c# equivalent


MP Michael Prabhu M Syncfusion Team November 7, 2018 08:45 AM UTC

Hi John, 
  
Based on your query, we have prepared the sample in code behind. Please download the sample from the below link, 
  
Code Snippet: 
  
C#: 
  
            SfMaps maps = new SfMaps(); 
            maps.ZoomLevel = 3; 
  
            ImageryLayer imageryLayer = new ImageryLayer(); 
            imageryLayer.GeoCoordinates = new Point(51.509, -0.1180); 
  
            MapMarker marker = new MapMarker(); 
            marker.Label = "London"; 
            marker.Latitude = "51.509"; 
            marker.Longitude = "-0.1180"; 
  
            imageryLayer.Markers.Add(marker); 
           
            maps.Layers.Add(imageryLayer); 
  
Sample: 
  
Regards, 
Michael 


Loader.
Live Chat Icon For mobile
Up arrow icon