Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bing Maps - UK Postcode to Map

Tags:

bing-maps

I am trying to do is show a small bing generated map centred on a uk postcode through the ajax API. I am sure 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});
  }
like image 883
u07ch Avatar asked Aug 24 '26 16:08

u07ch


1 Answers

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.

like image 121
Alastair Aitchison Avatar answered Aug 26 '26 22:08

Alastair Aitchison



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!