共用方式為


How to display maps and directions in the built-in Maps app (XAML)

Call the bingmaps: Uri scheme from your Windows Phone Store app when you simply want to display a map or directions in the built-in Maps app. The bingmaps: Uri scheme for Windows Phone Store apps provides a rich subset of the functionality of the maps: Uri scheme for Windows Store apps, which launches the built-in Windows Store Maps app on Windows Runtime devices.

The bingmaps: Uri scheme replaces the MapsTask and the MapsDirectionsTask from Windows Phone 8.

For detailed info about the parameters used in the Uri, see URI scheme for Maps app.

Typically you call the LaunchUriAsync method to launch another app by using a Uri scheme such as bingmaps:. For more info about calling a Uri to launch another app, see How to launch the default app for a URI.

Important  The methods described in this topic take the user to another app. The user has to go back to your app manually after using the built-in Maps app.

 

Launching the built-in Maps app from your app

The following simple example launches the built-in Maps app and displays a map centered over New York City with a zoom level of 10.

For more info about launching an app by using a Uri scheme, see How to launch the default app for a URI.

// The URI to launch
string uriToLaunch = @"bingmaps:?cp=40.726966~-74.006076&lvl=10";
var uri = new Uri(uriToLaunch);

// Launch the URI
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
if (success)
{
    // URI launched
}
    else
{
    // URI launch failed
}

Displaying known locations

Sample Uri Results
bingmaps: Displays the most recently used map view.
bingmaps:?cp=40.726966~-74.006076 Displays a map centered over New York City.
bingmaps:?cp=40.726966~-74.006076&lvl=10 Displays a map centered over New York City with a zoom level of 10.
bingmaps:?bb=39.719_-74.52~41.71_-73.5 Displays a map of New York City with the size of the screen as the bounding box.
bingmaps:?bb=39.719_-74.52~41.71_-73.5&cp=47~-122 Displays a map of New York City, which is the area specified in the bounding box argument. The center point for Seattle specified in the cp argument is ignored.
bingmaps:?bb=39.719_-74.52~41.71_-73.5&cp=47~-122&lvl=8 Displays a map of New York, which is the area specified in the bb argument. The cp argument, which specifies Seattle, is ignored because cp and lvl are ignored when bb is specified.
bingmaps:?collection=point.36.116584_-115.176753_Caesars%20Palace&lvl=16 Displays a map with a point named Caesar's Palace (in Las Vegas) and sets the zoom level to 16.
bingmaps:?collection=point.40.726966_-74.006076_Some%255FBusiness Displays a map with a point named Some_Business (in Las Vegas).

 

Displaying search results

Sample Uri Results
bingmaps:?where=1600%20Pennsylvania%20Ave,%20Washington,%20DC Displays a map and searches for the address of the White House in Washington, D.C.
bingmaps:?cp=40.726966~-74.006076&lvl=10&where=New%20York Searches for New York near the specified center point, displays the results on a map, and sets the zoom level to 10.
bingmaps:?cp=40.726966~-74.006076&lvl=14.5&q=pizza Searches for pizza near the specified center point (that is, in New York City), displays the results on a map, and sets the zoom level to 14.5.
bingmaps:?collection=point.36.116584_-115.176753_Caesars%20Palace Searches for Caesar's Palace in Las Vegas and displays the results on a map in the best map view.
Tip  Only collections that contain a single item are supported.
 

 

Displaying driving directions and traffic

Sample Uri Results
bingmaps:?rtp=pos.44.1222_-121.1111~pos.45.23423_-122.1232 Displays a map with point-to-point driving directions.
bingmaps:?cp=40.726966~-74.006076&trfc=1 Displays a map centered over New York City with traffic.
bingmaps:?rtp=adr.One Microsoft Way, Redmond, WA 98052~pos.45.23423_-122.1232 Displays a map with driving directions from the specified address to the specified location.
bingmaps:?rtp=adr.Mountain View, CA~adr.San Francisco International Airport, CA Displays a map with driving directions from the specified location to the specified landmark.

 

Unsupported options

The following examples are not supported in Windows Phone Store apps.

Unsupported operation Sample Uri Desired results
Aerial view. bingmaps:?cp=40.726966~-74.006076&sty=a Displays a map in Aerial view centered over New York City.
Searches that include a search term and a location. bingmaps:?q=coffee&where=Omaha Searches for coffee in Omaha and displays the results on a map.
Collections that include more than one element. bingmaps:?collection=name.Hotel%20List~point.36.116584_-115.176753_Caesars%20Palace~point.36.113126_-115.175188_The%20Bellagio&lvl=16&cp=36.114902~-115.176669 Displays a map with a list named Hotel List that includes two points for Caesars Palace and The Bellagio in Las Vegas, and sets the zoom level to 16.

 

How to get locations and addresses

How to get routes and directions

How to display maps in the Map control