开发者

Bing Maps - UK Postcode to Map

开发者 https://www.devze.com 2023-02-12 22:48 出处:网络
I am trying to do is show a small bing generated map centred on a uk postcode through the ajax API. I am su开发者_如何学运维re this is possible; what i can\'t find in the Bing Map documentation how to

I am trying to do is show a small bing generated map centred on a uk postcode through the ajax API. I am su开发者_如何学运维re this is possible; what i can't find in the Bing Map documentation how to convert a UK Postcode into coordinates that I can plug into the Maps Ajax Control. Can anyone point me in the right direction?

  function GetMap()
  {   

     var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), 
                       {credentials: "MyKeyHere",
                        center: new Microsoft.Maps.Location(45.5, -122.5),
                        mapTypeId: Microsoft.Maps.MapTypeId.road,
                        zoom: 7});
  }


You can use the Bing Maps REST Locations service to geocode the postcode, and then create a map centred on the resulting coordinate location:

For example, to geocode the postcode "NR2 4TE": http://dev.virtualearth.net/REST/v1/Locations/UK/NR24TE?key=YourBingMapsKey

Look in the coordinates property of the "point" object returned to get the latitude and longitude coordinates on which to centre your map.

0

精彩评论

暂无评论...
验证码 换一张
取 消