Technical documentation of Geoportal API

  • FR
  • UK

Index / Documentation / Technical documentation

Adding layers in actionScript

Adding a WMS layer 
Adding a WMTS layer 
Adding a WFS layer 
Adding a KML layer 
Adding a GPX layer 
Adding a GeoRSS layer 

This method shows the addition of layers in ActionScript using the "addLayer" method of Geoportail:Map.

Adding a WMS layer

In order to add a WMS layer in ActionScript, add an MXML <fx:Script> tag which allows to place actionScript code inside the <s:Application> tag (before the <geoportail:Map> tag).

<fx:Script>
    <![CDATA[
    
         import geoportal.layer.WMS;
    
         private function addWMSLayer():void{
        
          // Creating a new WMS layer
          var name:String = "Carte Géologique";
          var url:String = "http://geoservices.brgm.fr/geologie";
          var layers:String = "SCAN_F_GEOL250";
          var styles:String = "";
          var format:String = "image/png";
          var wmsLayer:WMS = new WMS(name,url,layers,styles,format);
        
                
          // Changing some properties of the layer
          wmsLayer.transparent = true;
          wmsLayer.alpha = 0.5;
            
          // Adding the layer to the map
          this.fxMap.addLayer(wmsLayer);
        }
        
    ]]>
</fx:Script>

Then execute this method once the application is loaded by filling the <s:Application> tag with the following attribute:

creationComplete="this.addWMSLayer()"

Unlike the MXML, all parameters of a WMS layer can not be filled at the creation of the layer in ActionScript. To inform these parameters, use methods that allow to to get them (getters).

These methods can be called as follows: layersName.propertiesName = value.

In the previous example, 'transparent' and 'alpha' properties have been defined in this way.

Parameters :

To set the layer's parameters, add the following attributes within the <Geoportal:WMS> tag.

  • mandatory parameters:
    • name :the layer's name. This name will be used to identify the layer in the layers manager.
    • url : the URL of the server.
    • layers : the layer's identifier to retrieve the data from the server.
    • version : protocol's version to use.
  • optionnal parameters:
    • transparent : true (the layer is transparent), false otherwise.
    • format : format of the returned image, 'image/png'for example. The default format is 'image/jpeg'.
    • alpha : opacity of the layer (between 0 and 1). Defaults to 1
    • etc...For more information browse the tutorial and technical documentation.

Adding a WMTS layer

To add an ActionScript WMTS layer in ActionScript, add an MXML <fx:Script> tag which allows to place actionScript code inside the <s:Application> tag (before the <geoportail:Map> tag).

<fx:Script>
  <![CDATA[
    import geoportal.layer.WMTS;
    
    private function addWMTS():void{
        
        // Creating a new WMTS layer
        var wmts:WMTS = new WMTS("WMTS ActionScript", 
                                 'http://tile.geobretagne.fr/gwc02/service/wmts', 
                                 "satellite", 
                                 "EPSG:900913");
                                
        //Adds the layer to the map
        this.fxMap.addLayer(wmts);
        
        // Adds the wmts to the map
        fxMap.addLayer(wmts);
            
        }
  ]]>
</fx:Script>

Then execute this method once the application is loaded by filling the <s:Application> tag with the following attribute:

creationComplete="this.addWMTS()"

Parameters :

To set the layer, add the following attributes within the <Geoportal: WMTS> tag.

  • mandatory parameters:
    • name :the layer's name. This name will be used to identify the layer in the layers manager.
    • url : the URL of the server.
    • tileMatrixSet : Type d'ensemble de données demandée.
    • layer : the layer's identifier to retrieve the data from the server.
    • format : format of the returned image, image / png 'for example. The default format is 'image/jpeg'.
  • optionnal parameters:
    • projection : Geographic projection in which the data will be requested to the service. Default to the map's projection.
    • maxExtent : Represents the maximum extent of the layer.
    • alpha : opacity of the layer (between 0 and 1). Defaults to 1.
    • etc.. For more information browse the tutorial and technical documentation.

Adding a WFS layer

To add a WFS layer in ActionScript, add an MXML <fx:Script> tag which allows to place actionScript code inside the <s:Application> tag (before the <geoportail:Map> tag).

<fx:Script>

import geoportal.layer.WFS;
import org.openscales.core.style.Style;
            
private function addWFSLayer():void{

        var wfs:WFS = new WFS(
                "WFS ActionScript", 
                'http://services.sandre.eaufrance.fr/geotest/mdo_metropole', 
                "sa:MasseDEauRiviere", 
                "1.0.0"
                            );

        wfs.style = Style.getDefaultLineStyle();
                        
        // Ajout de la couche à la carte
        this.fxMap.addLayer(wfs);
}

</fx:Script>

Then execute this method once the application is loaded by filling the tag <s:Application> with the following attribute :

creationComplete="this.addWFSLayer()"

Parameters :

To set the layer, add the following attributes within the <Geoportal: WFS>.

  • mandatory parameters:
    • name :the layer's name. This name will be used to identify the layer in the layers manager.
    • url : the URL of the service;
    • typename : the layer's identifier to retrieve the data from the server.
    • version : protocol's version to use.
      • style : Style object used to define the style used to display the layer.
  • optionnal parameters:
    • projection : Geographic projection in which the data will be requested to the service. Default to the map's projection.
    • maxExtent : Represents the maximum extent of the layer;
    • alpha : opacity of the layer (between 0 and 1). Defaults to 1
    • etc.. For more information browse the tutorial and technical documentation.

Adding a KML layer

To add a KML layer in ActionScript, add an MXML <fx:Script> tag which allows to place actionScript code inside the <s:Application> tag (before the <geoportail:Map> tag).

<fx:Script>

import geoportal.layer.KML;

private var kmlLayer:KML; 
        
private function addKmlLayer():void{

    // Creates a KML layer with the mandatory paramaters
   kmlLayer = new KML("Stations de Vélib à Paris","http://www.parisavelo.net/velib.kml");
    
    // Ajoute le layer à la carte
    fxMap.addLayer(kmlLayer);
}

</fx:Script>

Then execute this method once the application is loaded by filling the tag <s:Application> with the following attribute :

creationComplete="this.addKmlLayer()"

Parameters :

To set the layer, add the following attributes within the tag Geoportal:KML.

  • mandatory parameters:
    • name :the layer's name. This name will be used to identify the layer in the layers manager.
    • url : the path to the KML file.
  • optionnal parameters:
    • proxy : the OpenScales proxy server address.
    • srs : map's projection.
    • style : Style object used to define the style used to display the layer.
    • etc.. For more information browse the tutorial and technical documentation.

Adding a GPX layer

To add a GPX layer in ActionScript, add an MXML <fx:Script> tag which allows to place actionScript code inside the <s:Application> tag (before the <geoportail:Map> tag).

<fx:Script>
<![CDATA[

    import geoportal.layer.GPX;
            
    private var gpxLayer:GPX;
    
    private function addGPXLayer():void{
        
        // Creates a GPX layer with the mandatory paramaters
        gpxLayer = new GPX("CoucheGPX","1.0","http://api.ign.fr/geoportail/api/doc/data/Campomoro-Tizzano-Sartene_3029.gpx");
        
        // Ajoute le layer à la carte
        fxMap.addLayer(gpxLayer);
    }

   ]]>
</fx:Script>

Then execute this method once the application is loaded by filling the tag <s:Application> with the following attribute :

creationComplete="this.addGPXLayer()"
 will be for example 

Parameters :

Pour paramétrer la couche, ajouter les attributs suivants à l'intérieur de la balise geoportail:GPX.

  • Parameters obligatoires:
    • name :the layer's name. This name will be used to identify the layer in the layers manager.
    • url : the path to the GPX file.
  • Parameters optionnels:
    • proxy :the OpenScales proxy server address.
    • version : Version number of the standard GPX used.
    • style : Style object used to define the style used to display the layer.
    • etc.. For more information browse the tutorial and technical documentation.

Adding a GeoRSS layer

To add a GEORSS layer in ActionScript, add an MXML <fx:Script> tag which allows to place actionScript code inside the <s:Application> tag (before the <geoportail:Map> tag).

<fx:Script>
    <![CDATA[

        import geoportal.layer.GeoRss;

         // Creates a GeoRss layer with the mandatory paramaters
        private var geoRssLayer:GeoRss = new GeoRss("French Regions",
            "http://qlf-gpp3-api-ign-fr.aw.atosorigin.com/dataexample/georssdep.rss");
                
        private function addGeoRssLayer():void
        {   
            // Ajoute le layer à la carte
            fxMap.addLayer(geoRssLayer);
        }
    ]]>
</fx:Script>

Then execute this method once the application is loaded by filling the tag <s:Application> with the following attribute :

creationComplete="this.addGPXLayer()"

Parameters :

To set the layer's parameters, add the following attributes inside the <geoportail:GeoRSS>.

  • mandatory parameters:
    • name :the layer's name. This name will be used to identify the layer in the layers manager.
    • url : the URL of the service;
  • optionnal parameters:
    • refreshDelay : refresh time between two readings of the file containing GeoRSS data (in milliseconds);
    • maxExtent : Represents the maximum extent of the layer;
    • style : Style object used to define the style used to display the layer.
    • alpha : opacity of the layer (between 0 and 1). Defaults to 1
    • etc.. For more information browse the tutorial and technical documentation.