== GIS API ==
Developers need to be able to embed maps within their Modules & display Features.
They don't want to have to become GIS experts for this - they just want to be able to call a documented mapping API:
* A function which returns all the HTML needed to insert a map on the page, with the following customizations:
* Be able to define which locations get placed on this map. This might include a number of different types (groups?) of locations. For each type/group we can specify:
* The Marker (default from gis module).
* A function to call to return the size/colour of the marker, based on the location id. (advanced)
* A form which get displayed as the pop-up for the markers (along with the location_id as a arg/var, so can customize the display)
* Be able to define the default size of the map
* It would be good to be able to pass additional layers (or turn current layers off) to the map via JS, so that the map can be controlled dynamically using external controls. Although this probably represents a great deal of complexity and may need to be reconsidered.
We can pass information in 3 different ways:
1. Argument
2. Global variable (e.g. request.s3.gis_*) <- Not Advised
3. Config in Database <- Not efficient
* {{{gis.read_config()}}}
Here is the API from the original PHP version:
* http://wiki.sahanafoundation.org/doku.php/dev:gisapi
This is the current API used by the FRP application:
{{{
http://127.0.0.1:8000/frp/gis/map_viewing_client?
kml_name=Programmes&
kml_feed=http://127.0.0.1:8000/frp/or/programme/report.kml?
from=2010-04-23&
until=2010-04-23&
mode=programme
}}}
The pr/person/presence includes a link to embedding a map within a page:
{{{
View All on Map
}}}
!MapFish have an API in !JavaScript to allow their apps to be embedded in CMSs:
* http://mapfish.org/doc/contribs/mapfishapi.html
=== Proposed API ===
Draft - work in progress!
==== Embed a map within a Page ====
{{{
gis.show_map(
height = None,
width = None,
lat = None,
lon = None,
zoom = None,
feature_overlays = {},
catalogue_overlays = False,
catalogue_toolbar = False,
toolbar = False,
mgrs = False,
window = False):
"""
height - int - height of map in pixels
width - int - width of map in pixels
lat - double - Initial map center point
lon - double - Initial map center point
zoom - int - the initial zoom level of the map
feature_overlays - list of dictionaries:
{
feature_group: db.gis_feature_group.name,
filter : None, # A query to limit which features from the feature group are loaded
active : True, # Is the feed displayed upon load or needs ticking to load afterwards?
popup_url : , # The URL which will be used to fill the pop-up. it will be appended by the Location ID.
marker : # The icon used to display the feature. Can be a lambda to vary icon (size/colour) based on attribute levels.
}
catalogue_overlays - bool - whether or not to display the overlays enabled in the Map Service Catalogue
[- list of ints - The external overlays (WMS/KML/GeoRSS/etc) to display on the map. Hard-coding this is Ugly! Can we not just make it Bool & use Map Service Catalogue for more control?]
catalogue_toolbar - bool - whether or not to display the Map Service Catalogue toolbar
toolbar - bool - whether or not to display the GeoExt toolbar
mgrs - bool - whether or not to enable the MGRS PDF finder control
window - bool - whether or not to have the map pop out into a resizable window
base_layers - list of ints - base layers used for map. Hard-coding this is Ugly! Can we not just use Map Service Catalogue for this? Maybe creating separate configurations for separate use-cases, so can call e.g. db.gis_config.3 instead of the default
internal_layertree - bool - whether or not to display the menu to turn on and off the internal_layers
external_layertree - bool - whether or not to display the menu to turn on and off the external_layers
Will return the HTML to embed a map with the specified options.
"""
}}}
==== Produce Custom Overlay ====
This would produce a custom overlay with either:
* polygons highlighted
* variable sized markers (image, circle, bar)
I'm not sure if this is the right way to do it. But this is the sort of functionality I'd want.[[BR]]
In fact, this function should be included with the API above, or I think that parts of the API above should be included with this.
{{{
Args:
Locations - list of dicts - [{ location_id: ..., code_id: ..., value:...}, {}, ...]
code_id - used to lookup the marker/colour from the code_values list for this location_id.
value - used to define the size of the marker.
Type - Fill-Colour (for polygons only) / Marker / Circle / Bar Graph.
Code Values - list - either of marker images to use, or colour values. *Predefined code values could be included in the code.
popup_url = , # The URL which will be used to fill the pop-up. it will be appended by the Location ID.
}}}
Want to be able to change the selection of Features without reloading the map.
* Suggests that there is a single Feature Layer defined
* The controls to filter need to hook directly into the Map to reload the Features Layer over the (static) Base Layer
* Catch Event & call [http://dev.openlayers.org/releases/OpenLayers-2.9.1/doc/apidocs/files/OpenLayers/Map-js.html#OpenLayers.Map.removeLayer map.removeLayer()] then a new [http://dev.openlayers.org/releases/OpenLayers-2.9.1/doc/apidocs/files/OpenLayers/Map-js.html#OpenLayers.Map.addLayer map.addLayer()]
* Filters in main HTML & hence using jQuery: http://api.jquery.com/change/ or
* Filters in map window & hence using Ext: http://www.extjs.com/deploy/dev/docs/source/Observable.html#method-Ext.util.Observable-addListener
* Example app: http://mkgeomatics.com/apps/ajax_dev/Working052809/logged_in.html
* Also includes nice example of clustering!
----
[wiki:BluePrintGeographicInformationSystems GIS BluePrints]