Windows phone7 Study Notes 15 -- Bing Maps

Source: Internet
Author: User

Bing Maps is a map control of Windows Phone. It differs from Bing Maps control of Silverlight in that it supports touch events and caches maps. I will not talk about what I can do. The following describes how to use it.

  1. Get Bing Maps key

(1) login http://www.bingmapsportal.com;

(2) Use the live ID to log on;

(3) apply for an account for free.

 

  2. Use Bing Maps key

If your project only has one Bing Maps control, write it as follows:

<map:Map CredentialsProvider="AsWlUnHEvLgHlLHaRqTZLslewv1QIdGppxOqyL-7He2jxyHvLAjutrcntemUih-w9"> 

However, if you use several map controls in your project, you can write them to the app. in XAML, We are in app. A static credentialsprovider is created in the XAML file and accessed on our page.

App. XAML

<Application.Resources>
<map:ApplicationIdCredentialsProvider ApplicationId="AsWlUnHEvLgHlLHaRqTZLslewv1QIdGppxOqyL-7He2jxyHvLAjutrcntemUih-w9" x:Key="BingMapsAPIKey"></map:ApplicationIdCredentialsProvider>
</Application.Resources>

Map Control

<map:Map CredentialsProvider="{StaticResource BingMapsAPIKey}">

  

  3. Use of Bing Maps

(1) first introduce Microsoft. Phone. Control. Maps. dll.

 

(2) Scaling

 

(3) Center

 

See http://www.microsoft.com/maps/isdk/silverlight/default.htm for some other features

 

 4. Add a dingtalk

In C #, you can create a pushpin object, set its position, and add it to the map. It can also be implemented in XAML.

XAML

<map:Pushpin Location="40.1449, -82.9754" FontSize="30" Background="Orange" Content="1" />

C #

Pushpin pushpin = new Pushpin();
Location location = new Location();
location.Latitude = 40.1449;
location.Longitude = -82.9754;
pushpin.Location = location;
pushpin.Background = new SolidColorBrush(Colors.Orange);
pushpin.Content = "1";
pushpin.FontSize = 30;
MapControl.Children.Add(pushpin);

 

  5. add custom XAML to the map

In the map program set, there is a small control called mappolygon. Providing it with a series of positions, it will draw a custom polygon in your map, and it will still be fixed at that position when the user scales and moves the map. Because it is bound to a map based on longitude and latitude, it is necessary in the program to easily use it to outline the outlines of a home, State, region, or even a parking lot. The implementation method is as follows:

XAML

<map:MapPolygon Fill="Purple" Stroke="White" Opacity=".7" Locations="40.1449,-82.9754 40.1449,-12.9754 10.1449,-82.9754" />

C #

MapPolygon mapPolygon = new MapPolygon();
mapPolygon.Fill = new SolidColorBrush(Colors.Purple);
mapPolygon.Stroke = new SolidColorBrush(Colors.White);
mapPolygon.Opacity = .7;
LocationCollection locations = new LocationCollection();
Location location = new Location();
location.Latitude = 40.1449;
location.Longitude = -82.9754;
Location location1 = new Location();
location1.Latitude = 40.1449;
location1.Longitude = -12.9754;
Location location2 = new Location();
location1.Latitude = 10.1449;
location1.Longitude = -82.9754;
locations.Add(location);
locations.Add(location1);
locations.Add(location2);
mapPolygon.Locations = locations;
MapControl.Children.Add(mapPolygon);

 

6. Use the Bing Maps soap service to calculate the path

For more information about this, see: http://msdn.microsoft.com/en-us/library/ee681887.aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.