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});
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With