Specifying center and zoom level

One of the first things you may want to do after displaying a map is to set its center and zoom level.

Specifying the center of a map

You can set the center of the Map control by using its Center property. To set the property using XAML, assign a (latitude, longitude) pair to the Center property.

The following code example shows how you can set the center of Map by using XAML.

<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
   <maps:Map x:Name="MyMap" Center="47.6097, -122.3331" />
</Grid>

The following code example shows how can set the center of Map using code.

using Microsoft.Phone.Maps.Controls;
using System.Device.Location;

...

    Map MyMap = new Map();
    MyMap.Center = new GeoCoordinate(47.6097, -122.3331);
    ContentPanel.Children.Add(MyMap);
}

Specifying the zoom level of a map

Use the ZoomLevel property to set the initial resolution at which you want to display the map. ZoomLevel property takes values from 1 to 20, where 1 corresponds to a fully zoomed out map, and higher zoom levels zoom in at a higher resolution. The following code examples show how you can set the zoom level of the map by using the ZoomLevel property in XAML and code.

The following code example shows how you can set the zoom level of the map by using the ZoomLevel property in XAML.

<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
   <maps:Map x:Name="MyMap" Center="47.6097, -122.3331" ZoomLevel="10"/>
</Grid>

The following code example shows how you can set the zoom level of the map by using the ZoomLevel property in code.

using Microsoft.Phone.Maps.Controls;
using System.Device.Location;

...

    Map MyMap = new Map();
    MyMap.Center = new GeoCoordinate(47.6097, -122.3331);
    MyMap.ZoomLevel = 10;
    ContentPanel.Children.Add(MyMap);
}

Coming soon more details about HERE Maps and Geolocation services!
Stay tuned and happy coding! :)

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...