cgxp.plugins.ContextualData

ptype
cgxp_contextualdata
class cgxp.plugins.ContextualData(config)

Contextual Data Display

Add right-click popup and/or mouse-over popup with contextual data corresponding to current cursor coordinates.

This plugin may works with web service to retrieve additional data.

Config Options

Configuration properties.

actionConfig

Object Configuration object for the action created by this plugin.

actionTooltipText

String The text displayed as qtips on the tool button (i18n).

enabledAction

String the type of action triggering the context data query and display. possible values are: ‘all’, ‘mouseover’, ‘rightclick’. ‘mouseover’ enable a tool in the toolbar which allow to display the context data popup on mouseover on the map. ‘rightclick’ allow to display the context data popup on right-click on the map. ‘all’ enable both behavior. default is ‘all’

mouseoverWindowConfig

Object Allow to override the default values of the mouseover window

mouseoverWindowConfig: {
  width: 245
}
rasterLayers

Array(String) Array of raster layers to query. If not set (default), all raster layers defined in the c2cgeoportal config.yaml.in will be queried.

rightclickWindowConfig

Object Allow to override the default values of the rightclick window

rightclickWindowConfig: {
  width: 500
}
streetViewLink

Boolean enable or disable the streeView link in right-click context menu. true to enable, false to disable, default is true.

tpls

Object Allow to override the Ext.Template used for mouseover, rightclick or both window content. The variable between curly brackets are automaticaly replaced with the values recovered from server side. Example:

tpls: {
    allTpl: "Local Coord. Label : {coord_x} {coord_y}<br />" +
        "WGS Coord. Label : {wgs_x} {wgs_y}<br />" +
        "Elevation Label (Terrain) : {mnt_value} [m]<br />" +
        "Elevation Label (Surface) : {mns_value} [m]<br />" +
        "Height (Surface-Terrain) : {elevation_dhm} [m]<br />"
}

or

tpls: {
    mouseoverTpl: "...some text/html...",
    rightclickTpl: "...some text/html..."
}
url

String URL of the webservice used to retrieve the json data to be displayed in the plugin window. Typically set to "${request.route_url('raster')}" for altimetric data.

Public Methods

Public methods.

ContextualData.handleServerData()

Method intended to be overriden at config level, so users can specify specific treatments on server data

By default, all parameters other than mnt and mns are automatically set as <parameter_name>_value with the label <parameter_name>_label.

Parameters:dataObject JavaScript literal created from the JSON response.
Returns:Object

Full config example:

{
   ptype: "cgxp_contextualdata",
   url: "${request.route_url('raster')}",
   actionTarget: "center.tbar",
   tpls: {
       allTpl: "Local Coord. Label : {coord_x} {coord_y}<br />" +
               "WGS Coord. Label : {wgs_x} {wgs_y}<br />" +
               "Elevation Label (Terrain) : {mnt_value} [m]<br />" +
               "Elevation Label (Surface) : {mns_value} [m]<br />" +
               "Height (Surface-Terrain) : {elevation_dhm} [m]<br />" +
               "{custom_data_label} : {custom_data_value}"
   },
   handleServerData: function(data) {
       if (data.some_data) {
           // do some treatments ....

           return {
               'custom_data_value': data.some_data,
               'custom_data_label': OpenLayers.i18n('custom_data_label')
           };
       }
   }
}

Table Of Contents

Previous topic

cgxp.plugins.AddKMLFile

Next topic

cgxp.plugins.Disclaimer

This Page

Fork me on GitHub