Posted  by 

C Http Dev.virtualearth.net Rest V1 Locations Parse

Dev.virtualearth.net-->

Depending on the type of application you are creating, you may find it useful to be able to share a map with someone. Whether it’s a map of a single location or a map with a route on it, this can easily be accomplished in a Windows Store app. In this blog post we are going to take a look at two different ways you can share a map in a Windows Store app.

Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Copyright © 2020 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced. Geocoding with Bing Maps REST Services in.NET Log in Subscribe Sign up for my weekly curated newsletter, The Catch Block, by becoming a paid subscriber today!

  1. The culture parameter provides the following strings in the language of the culture for: Geographic entities and place names returned by the Bing Maps REST Services. Map labels on map images. Route instructions. You can use the alias to shorten the length of the culture parameter. For example, culture=da can be shortened to c=da.
  2. Open Static Map API Migration Guide Basic Map. For this example, we want a 600px by 400px retina static map image of New York, NY with a zoom level manually set to 12.

Sharing things is easy in Windows Store apps when using the Share charm. We can easily specify text or HTML that we want to share inside a message. There are two ways we can do share a map. The first is to use the Bing Maps REST Imagery service and generate an image of a map. The second method is to make use of the Bing Maps consumer site (http://bing.com/maps) and build a URL.

Creating a Map Image

The Bing Maps REST Imagery service makes it easy to generate an image of map. There are several different options and parameters that can be used to generate static map images. Here is one of the most basic structures for generating a static map image.

http://dev.virtualearth.net/REST/v1/Imagery/Map/ [ImagerySet] / [CenterPoint] / [ZoomLevel] ? [ImageOptionParameters]& key= [BingMapsKey]

C http dev.virtualearth.net rest v1 locations parse map

The ImagerySet parameter can have one of the following values:

Aerial

AerialWithLabels

Road

OrdnanceSurvey (UK only)

CollinsBart (London UK only)

The CenterPoint value of the URL is used to center the map over a specific coordinate. This consists of the latitude and longitude values being separated by a comma. The ZoomLevel is an integer value between 1 and 19 that indicates the level at which the map image should zoom. The following are some of the image option parameters that can be used with the Imagery API.

Parameter

Description

declutterPins

Specifies whether to change the display of overlapping pushpins so that they display separately on a map. (Optional)

1: Declutter pushpin icons.

0: Do not declutter pushpin icons. (default)

format

The image format to use for the static map. By default the best file format for a particular map style is used. (Optional)

gif: GIF image format.

jpeg: JPEG image format. JPEG format is the default for Road, Aerial and AerialWithLabels imagery.

png: PNG image format. PNG is the default format for CollinsBart and OrdnanceSurvey imagery.

mapArea

Req 6 stereo vst download. The geographic area to display on the map. Required when a center point or set of route points are not specified. This is a comma separated set of numbers using the following format:

“South Latitude,West Longitude,North Latitude,East Longitude”

mapLayer

A display layer that renders on top of the imagery set. The only value for this parameter is TrafficFlow. (Optional)

Example: mapLayer=TrafficFlow

mapSize

A string that contains a width and a height separated by a comma. The width must be between 80 and 900 pixels and the height must be between 80 and 834 pixels. The default map size for static maps is 350 pixels by 350 pixels. (Optional)

pushpin

A series of values that include a Point value (latitude and longitude) with options to add a label of up to three (3) characters and to specify an icon style. You can specify up to 18 pushpins within a URL and 100 if you use the HTTP POST method and specify the pushpins in the body of the request. (Optional)

A short form version of this parameter is available: pp

There are many other parameters available that can be used to add routes as well. You can find full documentation on Bing Maps REST Imagery serviceon MSDN.

One nice thing about REST services is that they are very easy to test. Once you have created a REST request URL you can simply put it in the address bar of a browser to see the response.

Using this information we can create the following URL that opens an image of Bing Maps with the map centered on a specific location (Seattle - 47.60356,-122.32943) with a zoom level of 12, and the map view set to the road map view:

Here is the generated image:

Creating a URL to Bing Maps

The Bing Maps consumer site exposes a number of URL query parameters which can be used to load a custom map view. These parameters are very similar to the Bing Maps REST Imagery service. You can customize the URL to display specific search results, driving directions, or items in your “My Places” folder.

To create a URL to the Bing Maps consumer site, start with the base URL and then use parameters to specify the location and options such as zoom level, map view, search panels, and more. The base address you should use is http://bing.com/maps/default.aspx. The following is a list of some of the basic parameters you can use:

Parameter

Description

cp

Defines where the center of the map should be. Use the following format for the cp parameter: Latitude~Longitude

lvl

Defines the zoom level of the map. Valid values are 1-19. This parameter is ignored if you don't include the cp parameter.

style

Defines the map view. Valid values for this parameter include:

a: Display an aerial view of the map.

r: Display a road view of the map.

h: Display an aerial view of the map with labels.

o: Use this value to display a bird's eye (oblique) view of the map.

b: Display a bird's eye (oblique) with labels view of the map.

u: Automatic

trfc

Specifies whether traffic information is included on the map. Omitting the trfc parameter produces the same results as trfc=0.

You can find full documentation on creating URLs for the Bing Maps consumer site on the Bing Help website.

Using this information we can create the following URL that opens Bing Maps with the map centered on a specific location (Seattle - 47.60356,-122.32943) with a zoom level of 12, and the map view set to the road map view: http://bing.com/maps/default.aspx?cp=47.60356~-122.32943&lvl=12&style=r

Opening this URL in a browser will load up the Bing Maps consumer site centered over Seattle.

Sharing from a Windows Store App

Now that we understand the basics of generating a static map image and a link to the Bing Maps consumer site, we can use this to create a Windows Store app that allows us to share this information through the Share charm. For this app we will create a simple application that uses the Bing Maps Windows Store control. When the Share charm is activated it will use the center point and zoom level of the map to generate the map image and URL to the Bing Maps consumer site. In addition to this, we will also add a button to the app that will launch the share charm. You may find this useful in the future if you have a list of results and you want to let the user select a single result and share it all with a single touch.

To get started let’s open up Visual Studios and create a new project in your preferred language: JavaScript, C# or Visual Basic. Select the Blank App template and call the application BingMapsShareCharm and press OK.

Add a reference to the Bing Maps SDK. To do this, right click on the References folder and press Add Reference. Select Windows -> Extensions select Bing Maps for C#, C++ and Visual Basic or Bing Maps for JavaScript. If you do not see this option ensure that you have installed the Bing Maps SDK for Windows Store apps. While you are here, if using C# or Visual Basic, add a reference to the Microsoft Visual C++ Runtime Package as this is required by the Bing Maps SDK.

If you are using C# or Visual Basic you may notice that there is a little yellow indicator on the references that you just added. The reason for this is that in the C++ runtime package you have to set the Active solution platform in Visual Studio to one of the following options; ARM, x86 or x64. To do this, right click on the Solution folder and select Properties. Then go to Configuration Properties -> Configuration. Find your project and under the Platform column set the target platform. For this blog post I’m going to select x86. Press Ok and the yellow indicator should disappear from our references.

If you are using JavaScript right click on the js folder and select Add -> New Item. Create a new JavaScript file called ShareMap.js. We will put all our JavaScript for this application in there to keep things clean. Now open up the default.html file and update the HTML to the following:

If you are using C# or Visual Basic open the MainPage.xaml file and add update the xaml to the following:

Be sure to add your Bing Maps key into the XAML.

C Http Dev.virtualearth.net Rest V1 Locations Parse File

Next we can add the functionality to power the application. Regardless of the language you are using you will have to do the following tasks:

1. Get a reference to the Share charm for the current view using the DataTransferManager.

2. Add an event handler when the user navigates to the app that is fired when data is requests by the Share charm. Remove this event handler when the user leaves the app.

3. Since we are using Bing Maps generate a session key from the map after the map has loaded. A session key is a special Bing Maps key that marks requests to the REST services as non-billable.

4. When a custom share button is tapped show the UI for the Share charm.

5. Create an event handler for when the Share charm is launched. To share an image through the share charm, generate some HTML with the layout you prefer. Add an img tag for where you want the image to go and provide it with a temporary URL. You can then load the image as a stream to the request and specify the temporary URL the image is meant for. In the HTML you can also add an anchor tag that links to the Bing Maps consumer site with the same map, but interactive.

If you are using JavaScript you have one more task and that is to load the Bing Maps control.

If you are using C# open the MainPage.xaml.cs file and update the code to the following:

If you are using Visual Basic open the MainPage.xaml.vb file and update the code to the following:

If you are using JavaScript open the ShareMap.js file and update the code to the following:

Be sure to add your Bing Maps key into the GetMap method.

Now run your application, and zoom in to a location. Press the custom share button you created or the Share charm button and select the Mail option. You should end up with an email with a map in it. Here is a screenshot of the app:

I have made the full source code for all the languages available on the visual Studio galleries here.

-->

The Bing Maps Time Zone API makes it easy to retrieve time zone information for any point on Earth. Given a pair of coordinates or a place name query the Time Zone API will return local time zone and daylight savings (DST) information for that location. Note that time zone data for bodies of water, like oceans or seas, is not supported.

API Templates

There are two Time Zone API operations to retrieve time zone information for a location.

Time Zone from Location Point

Given a specified point of latitude and longitude coordinates, like point = 47,-122, the Time Zone API returns information about the time zone for that location.

Time Zone from Location Name

Given a query for a location, like query = Bellevue, WA, the Time Zone API finds that location and then returns information about the time zone for that location.

To avoid ambiguity when processing location names, make sure to fully qualify the location name with state (administrative region) and country names.

Template Parameters

ParametersAliasDescriptionsValues
pointRequired for getting Time Zone by Location Point. The coordinates of the location for which you want the entities situated.
Note: The point and query parameters are mutually exclusive. Only one of these parameters can be specified in the same call.
A point on the Earth specified by a latitude and longitude. For more information, see the definition of Point in Location and Area Types.
Use the following ranges of values:
- Latitude (degrees): [-90, +90]
- Longitude (degrees): [-180, +180]
Example: 47.610679194331169,-122.10788659751415
queryqRequired for getting Time Zone by Query. A string containing information about the location, including address, locality, and postal code.
Note: The point and query parameters are mutually exclusive. Only one of these parameters can be specified in the same call.
To properly identify the given location, provide a fully qualified location e.g. place name, administrative region and country name.
Note: To avoid ambiguous results specify a qualified location name. For example, there are two Vancouvers, one in British Columbia, Canada and the other in Washington state, USA, so instead of the query 'Vancouver' use either 'Vancouver, BC' or 'Vancouver, WA' (alternatively: 'Vancouver, Canada' or 'Vancouver, USA'). If no such qualification is present and multiple locations of the given name are detected, then more likely than not the most popular location is returned.
Note: Please use full country names or official ISO country codes in queries, e.g., use either Capetown, ZA or Captetown, South Africa instead of Capetown, SA.
Examples:
- query = bellevue,wa,us
- q = 98052,wa
dateTimedtOptional. The UTC date time string for the specified location. The date must be specified to apply the correct DST.The date time string must be in UTC format. If the date is not included, the returned time zone information may be incorrect.
Example: 2018-05-15T13:14:15Z
includeDstRulesOptional. If set to true then DST rule information will be returned in the response.
Note: For information about DST rules, see the DSTRule Resource.
Either true or false.
Default: false
outputoOptional. Output format of the response.Format of the response:
- JSON
- XML
Default: JSON

Note

The Time Zone API does not maintain historical record of any time zone or day light settings. If a location had a different time zone in the past, it is not considered. The Bing Maps Time Zone API results are based only on current policies and standards.

Response

Detailed information about Time Zone API responses can be found at Time Zone Data.

All successful requests return a TimeZone Resource. Time Zone API calls by query wrap this TimeZone resource in a timeZoneAtLocation -- see the note below for details.

If applicable, daylight savings information is included separately in the ConvertedTime Resource and DSTRule Resource fields of the response.

Time Zone API responses are available in JSON and XML formats.

Note

Response for Time Zone API by Query.

If the Time Zone API is called successfully with the query parameter specified, then the response will consist of the field timeZoneAtLocation with two sub-fields: placeName and timeZone for JSON and PlaceName and TimeZone for XML.

For example, in JSON:

And in XML:

Examples

Below are several example URL requests and responses.

Return Time Zone Information in JSON for a Location Point

This example sends a request with a point in Alaska to the Time Zone API. It returns a JSON response with the local time for that point in Alaskan Standard Time.

The URL request:

JSON response:

Return the Time Zone Information in XML for a Location Query

This example sends a request with the query “Bellevue, WA” and returns an XML response with the local time for that location in Pacific Standard Time.

Tip

Use full country names or official ISO country codes in queries. For example, use “Capetown, ZA” or “Captetown, South Africa” instead of “Capetown, SA”.

The request URL:

XML Response:

HTTP Status Codes

Note

For more about these HTTP codes, see Status Codes and Error Handling.

When the request is successful, the following HTTP status code is returned.

C Http Dev.virtualearth.net Rest V1 Locations Parse Pdf

  • 200

C Http Dev.virtualearth.net Rest V1 Locations Parse Map

When the request is not successful, the response returns one of the following errors.

C Http Dev.virtualearth.net Rest V1 Locations Parse Free

  • 400
  • 500