MapPoint Forums

MapForums

Community of MapPoint and Bing Maps Users and Developers




Virtual Earth Silverlight Map Control CTP: Setting the Map Mode and View

This is a discussion on Virtual Earth Silverlight Map Control CTP: Setting the Map Mode and View within the Bing Maps Blogs & Tweets forums, part of the Blogs category; In a previous post , I showed you how to get started and create the simple “Hello World” sample using ...


Go Back   MapPoint Forums > Blogs > Bing Maps Blogs & Tweets

Today's Posts Twitter Feed Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  8 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 04-03-2009
Member
Green Belt
 
Join Date: Jan 2008
Posts: 51
Virtual Earth Silverlight Map Control CTP: Setting the Map Mode and View

In a previous post, I showed you how to get started and create the simple “Hello World” sample using the Virtual Earth Silverlight Map Control CTP.  Notice in that sample, the map by default shows the “Road” map.  The navigation control at the top left of the map lets users manually change the Map to other map styles by clicking on Aerial and toggling Labels.  Also, by default, the user can navigate the map to change the map view with input devices by using the mouse wheel and clicking and dragging the map. 


The Virtual Earth Silverlight Map Control also allows you to programmatically control the map mode and the map view which allows you to put the Map in a known state when it initializes.  In the Virtual Earth Ajax JavaScript Map Control, map modes were referred to as “map styles”.  To set the initial map mode, you can use the Mode property of the Map.  There are 3 supported Map Modes in the CTP: Road, Aerial, and AerialWithLabels


Here’s example XAML code to set the Map Mode to Aerial:



Mode=”Aerial” />


Here’s example XAML code to set the Map Mode to Aerial with labels turned on (known as Hybrid map style in the Ajax map control):



Mode=”AerialWithLabels” />


Here’s example XAML code to set the Map Mode to Road:



Mode=”Road” />


Also, the Mode XAML property uses a type converter so you can set it with a string in the XAML. If you want to set the MapMode in the code behind file, you can do this by setting the Mode property to an instance of the MapMode class. For example:



map.Mode = new RoadMode(); // Set the Mode to “Road”


map.Mode = new AerialMode(); // Set the Mode to “Aerial”


map.Mode = new AerialWithLabelsMode(); //Set the Mode to “AerialWithLabels”


In addition to setting the Map Mode, you can also set the Center and ZoomLevel properties on the Map to control the initial Map view. The Center property is of type Location which lets you specify the Latitude and Longitude of the Map center point.  The ZoomLevel is a double and lets you specify the level of detail of the Map View.  Notice in the Javascript Ajax Map Control the zoom level was an integer, however in Silverlight it is a double, so you can have in-between floating point zoom levels.


For example, the following XAML will initially put the Map in Aerial Mode with labels and set the center and zoom level over San Francisco:




Here’s the sample running:



Virtual Earth Silverlight Map Control CTP Sample



Virtual Earth Silverlight Map Control CTP: Set Initial View Sample


Here’s the complete listing of the XAML code from the sample:



    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:m="clr-namespace:Microsoft.VirtualEarth.MapControl;assemb ly=Microsoft.VirtualEarth.MapControl">
   
       
   


You can also programmatically set the Center and ZoomLevel in the code behind file. For example:



map.Center = new Location(37.806029, –122.407007);


map.ZoomLevel = 16;


There are also some additional SetView methods which allow you to set the view without using the properties directly.  For more information, see the Virtual Earth Silverlight Map Control CTP Interactive SDK.


(Note: this post is also available at the Virtual Earth Platform Team Blog)



More...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/virtual-earth-silverlight-map-control-ctp-setting-map-mode-view-10079.html

Posted By For Type Date
Virtual Map Attribute : The Official Microsoft Silverlight Site This thread Refback 11-10-2009 03:17 PM
Virtual Map Attribute : The Official Microsoft Silverlight Site This thread Refback 10-08-2009 12:53 PM
Virtual Map Attribute : The Official Microsoft Silverlight Site This thread Refback 09-29-2009 04:46 PM
Virtual Map Attribute : The Official Microsoft Silverlight Site This thread Refback 09-28-2009 04:46 AM
Technorati Mirror This thread Refback 04-08-2009 01:13 PM
Nebraska Map and Map of Nebraska - MapPoint State Map Gallery - MP2K Magazine This thread Refback 04-06-2009 12:39 PM
The Magazine for MapPoint - MP2K Magazine This thread Refback 04-05-2009 09:35 PM
Community : The Official Microsoft Silverlight Site This thread Refback 04-03-2009 08:28 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Virtual Earth Silverlight Map Control CTP: Setting the Map Mode and View VE Platform Team Blog Bing Maps Blogs & Tweets 0 04-03-2009 12:11 AM
Virtual Earth Session at MIX Updated: “Introducing the Microsoft Virtual Earth Silverlight Map Control” Keith Kinnan's Weblog Bing Maps Blogs & Tweets 0 03-18-2009 08:40 PM
Virtual Earth Session at MIX Updated: “Introducing the Microsoft Virtual Earth Silverlight Map Control” VE Platform Team Blog Bing Maps Blogs & Tweets 0 03-18-2009 05:50 PM
Virtual Earth Silverlight Map Control CTP announced at MIX! VE Platform Team Blog Bing Maps Blogs & Tweets 0 03-18-2009 05:50 PM
Announcing the Virtual Earth Silverlight Map Control VE Platform Team Blog Bing Maps Blogs & Tweets 0 03-18-2009 05:50 PM


All times are GMT -5. The time now is 08:59 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
MP2K Magazine
Visitor Map



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67