.. _layer_manager: ``madrona.layer_manager`` 2D Data Layer Management ==================================================== This document outlines data layers are handled in 2D/OpenLayers versions of Madrona. Server side data model ************************** The data layers are configured through django models: `layer_manager.model.Layer` and `layer_manager.model.Theme`. Layers describe a 2D data source from one of the following sources: * XYZ tiles * WMS * Geojson * UTFGrid json These can be organized into one or more Themes. All configuration can be done through the django admin interface at `/admin/layer_manager/`. If you want to load up the full catalog of data layers found in the demo, there is a fixture which can be loaded:: python manage.py loaddata base_layers Client side elements ************************* The client side of the layer_manager app includes five UI elements that can be added to the page: * `data` list; Accordion-style list of themes and layers * `search` box; Allows type-ahead search of all data layers * `active` list; opacity, z-layer and visibility controls for active layers * `legend`: legend images for active layers * `description`: brief abstract of selected info layer Client side configuration ************************** In order to incorportate the nice 2D layer management interface, you'll need to follow some simple setup guidelines on the client side. The functionality depends on OpenLayers, Bootstrap, jQuery and knockout. Include the css:: Include the required javascript sources:: Create an OpenLayer.Map object:: And add the elements of the user interface to your page using `include` tags::
{% include "layer_manager/active.html" %}
{% include "layer_manager/legend.html" %}
{% include "layer_manager/search.html" %}
{% include "layer_manager/data.html" %}
{% include "layer_manager/description.html" %}
Finally, and most importantly, you must set up a global javascript namespace, load the layer_manager javascript files and bind the viewModel to the entire DOM:: Example interface *************************** See `layer_manager/templates/layer_manager/demo.html` for a minimal example of the javascript, css and html markup required to set up the client side.