Latitude & longitude on Google Maps
by Neil on Wednesday, 8th October, 2008 at 20:58, under Technology
While building this page using the excellent Google MAPS API, I ran into a frustrating problem. The placement of the markers I have is pre-configured in an XML file that my web page parses when it displays. Here is an example of one of the markers in the XML file:
<marker lat=”57.18561055070526″ lng=”-2.085258590317864″ label=”AECC”> <infowindow> <![CDATA[ <strong><a href="http://www.aecc.co.uk" target="_blank">Aberdeen Exhibition & Conference Centre</a></strong><br/> Bridge of Don<br/> Aberdeen<br/> AB23 8BL<br/><br/> <strong>Tel:</strong> 01224 824824<br/> <strong>Email:</strong> <a href="mailto:aecc@aecc.co.uk">aecc@aecc.co.uk</a> ]]> </infowindow> </marker> |
As you can see the position of the marker is determined using latitude (lat) and longitude (lng) parameters and not, for example, an address or post code. Now perform a quick search for an address on Google Maps and tell me where you can see the latitude and longitude of your location. Exactly. It isn’t displayed anywhere on the web front-end, from that I can see anyway.
Here is a little trick to get the latitude and longitude displayed though. Once you’ve searched your location in Google Maps, paste the following into the location bar in your web browser:
javascript:void(prompt(”,gApplication.getMap().getCenter()));
Hit return and boom! You should be presented with a JavaScript pop-up window with the latitude and longitude of your location. Far from ideal, but it’ll do for me!







