mapfish_api.js | |
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. |
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. | 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 |
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.
config.debug | set the debug mode (prod or debug) |
config.isMainApp | define is the API is an instance of the main application or of a derived application |
config.lang | set the lang |
config.baseUrl | base url of the main application |
config.initialExtent | initial extent of the map |
config.searchUrl | search url |
api = new MapFish.API({ baseUrl: '<main application url>' });
createMap: function( config )
Create and return an {OpenLayers.Map} and place a vector drawing layer {OpenLayers.Layer.Vector} on top
config.div | div where to place the map |
config.easting | center of the map, easting value |
config.northing | center of the map, northing value |
config.zoom | zoom level |
config.bbox | bbox of the initial extent |
api.createMap({ div: 'mymap1', zoom: 14, easting: 518752, northing: 147276, });
createToolbar: function( config )
Create and return an array of functions. Supported function: ‘ZoomToMaxExtent’, ‘Navigation’, ‘ZoomBox’,’LengthMeasure’, ‘AreaMeasure’, ‘NavigationHistory’,’ZoomOut’, ‘DrawFeature’, ‘ClearFeatures’
config.items | array of function to activate. Possible values: ‘ZoomToMaxExtent’, ‘Navigation’, ‘ZoomBox’,’LengthMeasure’, ‘AreaMeasure’, ‘NavigationHistory’,’ZoomOut’, ‘DrawFeature’, ‘ClearFeatures’ |
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.
layer | name of the layer |
ids | array of feature id |
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.
layer | name of the layer |
ids | array of feature id |
showMarker: function( options )
Show a marker in the map and associate a popup if an html content is provided
options.easting | position of the marker, default: map center |
options.northing | position of the marker, default: map center |
options.iconPath | path of a custom icon for the marker (url or relative), default: /mfbase/openlayers/img/marker-gold.png |
options.recenter | define if the map has to recentered at the marker position, default: false |
options.graphicHeight | height of the height, default: the icon height |
options.graphicWidth | width of the height, default: the icon width |
options.fillOpacity | opacity of the marker (from 0 to 1), default: 1 |
options.html | html content of a popup, default: null |
api.showMarker({ easting: 518752, northing: 147276, html: "Marker with popup" });
showPopup: function( options )
Shows a {GeoExt.Popup}
options.easting | position of the popup - default: map center |
options.northing | position of the popup, default: map center |
options.title | title of the window, default: “” |
options.html | html content of the popup, default: “” . If empty, no popup is shown |
options.recenter | define if the map has to recentered at the popup position, default: false |
options.width | width of the popup, default: 200 |
options.collapsible | default: false |
options.unpinnable | default: true |
options.feature | feature associated with the popup |
api.showPopup({ easting: 518752, northing: 147276, html: "<h1>Example</h1><br>Popup without marker", title: "Simple Popup" });
Create and return an {OpenLayers.Map} and place a vector drawing layer {OpenLayers.Layer.Vector} on top
createMap: function( config )
Create and return an {GeoExt.MapPanel} and create an {OpenLayers.Map} if it doesn’t exist
createMapPanel: function( config )
Create and return an {mapfish.widgets.LayerTree}
createLayerTree: function( config )
Create and return an array of functions.
createToolbar: function( config )
Show a feature tooltip.
showFeatureTooltip: function( config )
Recenter map based on list of features
recenterOnObjects: function( layer, ids )
Highlight features in the map
highlightObjects: function( layer, ids )
Recenter and highlight a list of features
showFeatures: function( layer, ids )
Show a marker in the map and associate a popup if an html content is provided
showMarker: function( options )
Shows a {GeoExt.Popup}
showPopup: function( options )
Update the permalink according to the layer tree
updateLayerTreeFromPermalink: function()