Technical documentation of Geoportal API

  • FR
  • UK

Index / Documentation / Technical documentation

Coordinate reference systems

Re-projecting coordinates

It is worth noting that displayed data are in IGNF:GEOPORTALxxx projection (Equidistant cylindrical, xxx is the territory code) and displayed control data (such as mouse coordinates) are in the underlying geographic reference system of the projection.

To get access to the map's projection, use the following code snippet :

var map_projection= myMap.getMap().getProjection();

To get access to the controls' projection, use the following code snippet :

var ctrl_projection= myMap.getMap().getDisplayProjection();

Most OpenLayers widgets supports re-projection through the use of the transform(OpenLayers.Projection ini,OpenLayers.Projection fin) method. Have a look at the OpenLayers API for more information.

Thus for re-projecting GPS geographical coordinates into map coordinates, one could use the following code snippet :

var p= new OpenLayers.LonLat(longitude, latitude);
p.transform(OpenLayers.Projection.CRS84, myMap.getMap().getProjection());

Accessing unsupported CRS

The API only supports in its extended release more than 200 CRSs.

If one wants to use an unsupported CRS, it is necessary to add a proxy as the API uses Ajax to get access to the Spatial Reference web site. For more information about proxy setting, see Layer access.

Eventually, one can directly add the CRS definition in the web page as follows :

<!DOCTYPE html>
<html>
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  </head>
  <body>
    <div id="viewerDiv" style="width:800px;height:600px;"></div>
    <script type="text/javascript"><!--//--><![CDATA[//><!--
        window.onload= function() {
            Geoportal.load("viewerDiv", {
                ['YOUR_LICENSE'],
                null,
                null, {
                    onBeforeView: function() {
                        //add new projection
                        Proj4js.defs['EPSG:32630']=
'+proj=utm +zone=30 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +title=UTM North Zone 30 - France';
                    }
                }
            )
        };
    //--><!]]></script>
    <script type="text/javascript" src="http://api.ign.fr/geoportail/api/js/VERSION/Geoportal.js" charset="utf-8">
    <!--//--><![CDATA[//><!--
    //--><!]]>
    </script>
  </body>
</html>