Point extraction from Google Maps

Wednesday, 30 June 2010 00:00

Sometimes, the precise coordinates of some markers from a Google Maps layer are to be obtained. One way is to look them up in the source code of the map generation. But the information should also be in the map after construction, right? For example, all the marker items on the map contain this information. The following brief script extracts the coordinates and the title of the markers and writes them into a plain text file in a new browser window.

 
  var out = '';
  var i   = 0;
  while ( x = document.getElementById( 'mtgt_unnamed_' + i ) )
    {
    out += ( [x.__marker__.C.x, x.__marker__.C.y, x.__marker__.ca.title] ).join( ', ' ) + "\n";
    i ++;
    }
  window.open( 'data:text/plain;charset=UTF-8,' + encodeURIComponent( out ) );
 

For ease of use, the whole script can be put into a bookmark. By clicking it, it will be executed on the currently shown page. So if interested, bookmark this link: GMaps point extractor.

If more information, such as content of popup windows, is needed, a script more specific to the implementation of the map generation has to be used.

 

Public access to Ordnance Survey and IGN maps

Tuesday, 17 March 2009 08:08

Ordnance Survey (the UK mapping agency) as well as IGN (the french pendant) opened their topographic maps to the public. The two services called OS OpenSpace and API Geoportail allow for integration of high-quality up-to-date topographic maps of the UK and France into private web-sites.

This integration is in both cases based on modified versions of OpenLayers which use an authenticated WMS layer (a registration key has to be used to validate the access from a specific location) as base images. Therefore it is quite easy to build special OS and GP layers to integrate these public services into standard OpenLayers projects.

For the OpenSpace layer have a look at an example of OS integration or OpenLayers sandbox.

I have implemented an IGN Geoportail layer for OpenLayers, to be downloaded here. At the moment only the maps for the french main land are included and no satellite photos. A new new layer is created by

var layer = new OpenLayers.Layer.Geoportail( "Geoportail Main Land", key );

where key contains the API key for the web page you want to access the API from. The key is transmitted on a regular basis to ensure that subsequent requests are all authenticated.