Geoportal Extension for OpenLayers API Reference

Class: LayerImport

ol.control.LayerImport

LayerImport Control. Allows users to add geographical data in standards formats from their own sources to the map.

new LayerImport(options)

OpenLayers/Controls/LayerImport.js, line 87
Name Type Description
options Object

options for function call.

Name Type Default Description
collapsed Boolean false optional

Specify if LayerImport control should be collapsed at startup. Default is true.

layerTypes Array ["KML", "GPX", "GeoJSON", "WMS", "WMTS"] optional

data types that could be imported : "KML", "GPX", "GeoJSON", "WMS" and "WMTS". Values will be displayed in the same order in widget list.

webServicesOptions Object {} optional

Options to import WMS or WMTS layers

Name Type Description
proxyUrl String optional

Proxy URL to avoid cross-domain problems. Mandatory to import WMS and WMTS layer.

noProxyDomains Array.<String> optional

Proxy will not be used for this list of domain names. Only use if you know what you're doing.

vectorStyleOptions Object optional

Options for imported vector layer styling (KML, GPX, GeoJSON)

Name Type Description
KML Object optional

Options for KML layer styling

Name Type Default Description
extractStyles Boolean true optional

Extract styles from the KML. Default is true.

showPointNames Boolean true optional

Show names as labels for KML placemarks which contain points. Default is true.

defaultStyle Object optional

default style to be applied to KML imports in case no style is defined. defaultStyle is an ol.style.Style object.

GPX Object optional

Options for GPX layer styling

Name Type Description
defaultStyle Object optional

default style to be applied to GPX imports in case no style is defined. defaultStyle is an ol.style.Style object.

GeoJSON Object optional

Options for GeoJSON layer styling

Name Type Description
defaultStyle Object optional

default style to be applied to GeoJSON imports in case no style is defined. defaultStyle is an ol.style.Style object.

Example
var LayerImport = new ol.control.LayerImport({
     collapsed : false,
     layerTypes : ["KML", "GPX"],
     webServicesOptions : {
         proxyUrl : "http://localhost/proxy/php/proxy.php?url=",
         noProxyDomains : []
     },
     vectorStyleOptions : {
         KML : {
             extractStyles : true,
             defaultStyle : new ol.style.Style({
                 image : new ol.style.Icon({
                      src : "data:image/png;base64....",
                      size : [51, 38],
                 }),
                 stroke : new ol.style.Stroke({
                      color : "#ffffff",
                      width : 7
                 }),
                 fill : new ol.style.Fill({
                      color : "rgba(255, 183, 152, 0.2)"
                 }),
                 text : new ol.style.Text({
                     font : "16px Sans",
                     textAlign : "left",
                     fill : new ol.style.Fill({
                         color : "rgba(255, 255, 255, 1)"
                     }),
                     stroke : new ol.style.Stroke({
                         color : "rgba(0, 0, 0, 1)",
                         width : 2
                     })
                 })
             })
         },
         GPX : {
             defaultStyle : new ol.style.Style({
                 image : new ol.style.Icon({
                      src : "path/to/my/icon.png",
                      size : [51, 38],
                 }),
                 stroke : new ol.style.Stroke({
                      color : "#ffffff",
                      width : 7
                 })
             })
         }
     }
 });

Extends

  • ol.control.Control

Members

collapsed

{Boolean} specify if reverseGeocoding control is collapsed (true) or not (false)

Methods

getCollapsed(){Boolean}

OpenLayers/Controls/LayerImport.js, line 167

Returns true if widget is collapsed (minimized), false otherwise

Returns:
- true if widget is collapsed

getServiceImportContent(){String}

OpenLayers/Controls/LayerImport.js, line 206

Returns content of a service import (GetCapabilities)

Returns:
- content service

getStaticImportContent(){String}

OpenLayers/Controls/LayerImport.js, line 197

Returns content of a static import (KML, GPX or GeoJSON)

Returns:
- content static

setCollapsed(collapsed)

OpenLayers/Controls/LayerImport.js, line 176

Collapse or display widget main container

Name Type Description
collapsed Boolean

True to collapse widget, False to display it