(For more resources on Windows Phone, see here.)
Windows Phone 7.5 supports two methods of map display in your mobile app:
Before we delve into the methods, actions, and tasks of the Windows Phone Bing Maps Silverlight Control or the Bing Maps task Launcher, it is a good idea to get acquainted with the background of map geometry and how it works for Bing Maps. If you have a background in Computer Science, then you would be aware of keywords such as projection, trajectory, coordinate systems, raster and scalable graphics. If you are not from a Computer Science background, then a basic understanding of the Bing Maps API can be found at http://msdn.microsoft.com/en-us/library/ff428643.aspx. This should be good to get you started with Bing Maps.
Bing Maps uses the Mercator projection model of converting the Earth’s sphere into a corresponding flat surface, grid-based, parallel map. In such a projection the longitude lines are parallel, and hence the land mass further from the equator tends to be distorted. However, the Mercator projection works well for navigational purposes, and therefore, despite the drawbacks, it is still used today.
The Mercator projection offers two compelling advantages:
The following diagrams should give you a good idea about the Mercator projection:
Earth’s surface as a sphere diagram courtesy Michael Pidwirny from http://www.eoearth.org/article/Maps and http://www.physicalgeography.net/fundamentals/2a.html.
Mercator projection of the Earth’s surface diagram courtesy Michael Pidwirny from http://www.eoearth.org/article/Maps and http://www.physicalgeography.net/fundamentals/2a.html.
The world map is pre-rendered at many different levels of detail and cut into tiles for quick retrieval. When you zoom in or zoom out on your Bing Maps, it is nothing but loading different tiles at different levels. To read more about the Bing Maps Tile System please see the following MSDN link:
http://msdn.microsoft.com/en-us/library/bb259689.aspx
The Bing Maps Silverlight Control for Windows Phone 7.5 is a port of the desktop version of the Silverlight Map Control, which provides full mapping capabilities on the Windows Phone 7.5 device. Before using the Bing Maps control you need to get an application key from Microsoft’s Bing Maps portal at: https://www.bingmapsportal.com/.
The Microsoft.Phone.Controls.Maps namespace contains the classes of the Bing Maps Silverlight Control for Windows Phone. Let us quickly see an example of using maps in our WP7.5 app.
We will now create a new application titled HelloMaps that shows the Windows Phone Bing Maps Silverlight Control in action:
<Grid x_Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<my:Map Height="595"
CredentialsProvider="xxxxxxxxxxxxxx"
HorizontalAlignment="Left" Margin="6,6,0,0" Name="myMap"
VerticalAlignment="Top" Width="444" />
</Grid>
<!--Sample code showing usage of ApplicationBar-->
<!--<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton
IconUri="/Images/appbar_button1.png" Text="Button 1"/>
<shell:ApplicationBarIconButton
IconUri="/Images/appbar_button2.png" Text="Button 2"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>-->
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="Aerial Mode"/>
<shell:ApplicationBarMenuItem Text="Road Mode"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBarMenuItem
Click="ApplicationBarMenuItem_Click" Text="Aerial Mode"/>
<shell:ApplicationBarMenuItem
Click="ApplicationBarMenuItem_Click_1" Text="Road Mode"/>
private void ApplicationBarMenuItem_Click(object sender,
EventArgs e)
{
myMap.Mode = new AerialMode();
}
private void ApplicationBarMenuItem_Click_1(object sender,
EventArgs e)
{
myMap.Mode = newRoadMode();
}
I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…
Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…
Once we learn how to deploy an Ubuntu server, how to manage users, and how…
Key-takeaways: Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…
While developing a web application, or setting dynamic pages and meta tags we need to deal with…
Software architecture is one of the most discussed topics in the software industry today, and…