mapfish_api.js

Summary
mapfish_api.js
Properties
map{OpenLayers.Map}: map component
drawLayer{OpenLayers.Layer.Vector}: drawing layer over the map
baseConfigbaseConfig of the api
apiIdIndex of current API instance.
searcherInstance of {MapFish.API.Search} class
debugFlag indicating if debug mode is active.
treeInstance of {mapfish.widgets.LayerTree} class
isMainAppBoolean to tell if API is used within main application or in external mode.
recenterUrlURL part relative to config baseUrl: URL of recentering service
highlightUrlURL part relative to config baseUrl: URL of highlighting service
layerTreeNodesArray storing checked layers ids according to permalink
selectCtrlInstance of {OpenLayers.Control.SelectFeature}
Functions
MapFish.API(config)Create and return an instance of the MapFish API
createMap(config)Create and return an {OpenLayers.Map} and place a vector drawing layer {OpenLayers.Layer.Vector} on top
createMapPanel(config)Create and return an {GeoExt.MapPanel} and create an {OpenLayers.Map} if it doesn’t exist
createLayerTree(config)Create and return an {mapfish.widgets.LayerTree}
createToolbar(config)Create and return an array of functions.
showFeatureTooltip(config)Show a feature tooltip.
recenterOnObjects(layer, ids)Recenter map based on list of features
highlightObjects(layer, ids)Highlight features in the map
showFeatures(layer, ids)Recenter and highlight a list of features
showMarker(options)Show a marker in the map and associate a popup if an html content is provided
showPopup(options)Shows a {GeoExt.Popup}
updateLayerTreeFromPermalink()Update the permalink according to the layer tree

Properties

map

{OpenLayers.Map}: map component

drawLayer

{OpenLayers.Layer.Vector}: drawing layer over the map

baseConfig

baseConfig of the api

apiId

Index of current API instance.  Useful when several instances coexist.

searcher

Instance of {MapFish.API.Search} class

debug

Flag indicating if debug mode is active.

tree

Instance of {mapfish.widgets.LayerTree} class

isMainApp

Boolean to tell if API is used within main application or in external mode.

recenterUrl

URL part relative to config baseUrl: URL of recentering service

highlightUrl

URL part relative to config baseUrl: URL of highlighting service

layerTreeNodes

Array storing checked layers ids according to permalink

selectCtrl

Instance of {OpenLayers.Control.SelectFeature}

Functions

MapFish.API(config)

Create and return an instance of the MapFish API

MapFishAPI is an API based on the MapFish framework.  It provides a convenient way to rapidly setup map applications using standardized classes and public methods.

Parameters

config.debugset the debug mode (prod or debug)
config.isMainAppdefine is the API is an instance of the main application or of a derived application
config.langset the lang
config.baseUrlbase url of the main application
config.initialExtentinitial extent of the map
config.searchUrlsearch url

Example

api = new MapFish.API({
        baseUrl: '<main application url>'
});

createMap(config)

createMap: function(config)

Create and return an {OpenLayers.Map} and place a vector drawing layer {OpenLayers.Layer.Vector} on top

Parameters

config.divdiv where to place the map
config.eastingcenter of the map, easting value
config.northingcenter of the map, northing value
config.zoomzoom level
config.bboxbbox of the initial extent

Example

api.createMap({
         div: 'mymap1',
         zoom: 14,
         easting: 518752,
         northing: 147276,
});

createMapPanel(config)

createMapPanel: function(config)

Create and return an {GeoExt.MapPanel} and create an {OpenLayers.Map} if it doesn’t exist

Parameters

config.mapfinfomap config object (see createMap(config))
config.showToolsdefine is the tools are shown in the MapPanel
config.renderTorenderTo

createLayerTree(config)

createLayerTree: function(config)

Create and return an {mapfish.widgets.LayerTree}

Parameters

config.divdiv where to place the LayerTree
config.layerslayers in the tree
config.titletitle of the tree
config.showWmsLegenddefine is te WMS legend is shown

createToolbar(config)

createToolbar: function(config)

Create and return an array of functions.  Supported function: ‘ZoomToMaxExtent’, ‘Navigation’, ‘ZoomBox’,’LengthMeasure’, ‘AreaMeasure’, ‘NavigationHistory’,’ZoomOut’, ‘DrawFeature’, ‘ClearFeatures’

Parameters

config.itemsarray of function to activate.  Possible values: ‘ZoomToMaxExtent’, ‘Navigation’, ‘ZoomBox’,’LengthMeasure’, ‘AreaMeasure’, ‘NavigationHistory’,’ZoomOut’, ‘DrawFeature’, ‘ClearFeatures’

showFeatureTooltip(config)

showFeatureTooltip: function(config)

Show a feature tooltip.  Experimental.

Parameters

config.layername of the layer
config.idid of the object

recenterOnObjects(layer, ids)

recenterOnObjects: function(layer,
ids)

Recenter map based on list of features

This method requires a server-side controller located at baseUrl+recenterUrl returning either a JSONified bbox in AJAX mode or some JS code like: mapFishApiPool.apiRefs[2].recenterOnBboxCb({“rows”: [{“bbox”: [672518.0, 267450.23999999999, 697695.0, 295935.0]}], “results”: 1}); in cross-domain mode.  See Ext.data.ScriptTagProxy doc.

Parameters

layername of the layer
idsarray of feature id

highlightObjects(layer, ids)

highlightObjects: function(layer,
ids)

Highlight features in the map

This method requires a server-side controller located at baseUrl+highlightUrl returning some JS code like: mapFishApiPool.apiRefs[2].highlightObjectsCb({“rows”: [{“features”: {“type”: “FeatureCollection”, “features”: [{“geometry”: {“type”: “MultiPolygon”, “coordinates”: [[[[672518.0, 267450.23999999999], [672518.0, 295935.0], [697695.0, 295935.0], [697695.0, 267450.23999999999]]]]}, “type”: “Feature”, “properties”: {}}]}}], “results”: 1}); See Ext.data.ScriptTagProxy doc.

Parameters

layername of the layer
idsarray of feature id

showFeatures(layer, ids)

showFeatures: function(layer,
ids)

Recenter and highlight a list of features

Parameters

layername of the layer
idsarray of feature id

showMarker(options)

showMarker: function(options)

Show a marker in the map and associate a popup if an html content is provided

Parameters

options.eastingposition of the marker, default: map center
options.northingposition of the marker, default: map center
options.iconPathpath of a custom icon for the marker (url or relative), default: /mfbase/openlayers/img/marker-gold.png
options.recenterdefine if the map has to recentered at the marker position, default: false
options.graphicHeightheight of the height, default: the icon height
options.graphicWidthwidth of the height, default: the icon width
options.fillOpacityopacity of the marker (from 0 to 1), default: 1
options.htmlhtml content of a popup, default: null

Example

api.showMarker({
         easting: 518752,
         northing: 147276,
         html: "Marker with popup"
});

showPopup(options)

showPopup: function(options)

Shows a {GeoExt.Popup}

Parameters

options.eastingposition of the popup - default: map center
options.northingposition of the popup, default: map center
options.titletitle of the window, default: “”
options.htmlhtml content of the popup, default: “” . If empty, no popup is shown
options.recenterdefine if the map has to recentered at the popup position, default: false
options.widthwidth of the popup, default: 200
options.collapsibledefault: false
options.unpinnabledefault: true
options.featurefeature associated with the popup

Example

api.showPopup({
         easting: 518752,
         northing: 147276,
         html: "<h1>Example</h1><br>Popup without marker",
         title: "Simple Popup"
});

updateLayerTreeFromPermalink()

updateLayerTreeFromPermalink: function()

Update the permalink according to the layer tree

Works only if layertree is a mapfish.widgets.LayerTree and has id attributes for all of its nodes.

createMap: function(config)
Create and return an {OpenLayers.Map} and place a vector drawing layer {OpenLayers.Layer.Vector} on top
createMapPanel: function(config)
Create and return an {GeoExt.MapPanel} and create an {OpenLayers.Map} if it doesn’t exist
createLayerTree: function(config)
Create and return an {mapfish.widgets.LayerTree}
createToolbar: function(config)
Create and return an array of functions.
showFeatureTooltip: function(config)
Show a feature tooltip.
recenterOnObjects: function(layer,
ids)
Recenter map based on list of features
highlightObjects: function(layer,
ids)
Highlight features in the map
showFeatures: function(layer,
ids)
Recenter and highlight a list of features
showMarker: function(options)
Show a marker in the map and associate a popup if an html content is provided
showPopup: function(options)
Shows a {GeoExt.Popup}
updateLayerTreeFromPermalink: function()
Update the permalink according to the layer tree
Close