Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

mapStoreConfig File

Lorenzo Pini edited this page Feb 22, 2016 · 45 revisions

Global Configuration Options

Such configuration options are common for every MapStore or MapStoreManager configuration. These options can be written ones for all setting them in the global javascript file localConfig.js: /static/config/common/localConfig.js

var localConfig = {
   geoStoreBase: "http://myserver.com/geostore/rest/",
   adminUrl: "http://myserver.com/admin/",
   proxy:"/http_proxy/proxy/?url=",
   loginDataStorage : sessionStorage,
   defaultLanguage: "en",
   apikeys: {
      "Bing" : "insert-Bing-Maps-key-here"
   }
};

This file will be loaded from MapStore and MapManager and the option can be used as default or overridden by the specific configuration. (e.g. geoStoreBase in localConfig will be overridden by the geoStoreBase in mapStoreConfig.js, if present). In a typical MapStore installation, the common configuration options can be:

  • geoStoreBase: GeoStore URL for the application
  • proxy: the proxy for X-Origin Ajax calls
  • loginDataStorage: local storage for authentication data.
  • defaultLanguage: default languages supported by the application
  • header : the default header for maps and manager
  • footer : the default footer for maps and manager
  • adminUrl : the url of OpenSDI Manager
  • apikeys : the API keys to access different services ("Bing Maps" or others)

MapStore Configuration Options

  • geoStoreBase: Geostore URL (if empty http://<server>:<port>/geostore/rest/ is used)

  • proxy:proxy URL

  • defaultLanguage: default language code,

  • actionToolScale: Allow to change the actions buttons dimension, possible values are: small, medium, large.

  • gsSources: Sources for getCapabilities: example:

      {
    "mapquest": {
    	"ptype": "gxp_mapquestsource"
    }, 
    "osm": { 
    	"ptype": "gxp_osmsource"
    },
    "google": {
    	"ptype": "gxp_googlesource" 
    },
    "bing": {
    	"ptype": "gxp_bingsource" 
    }, 
    "ol": { 
    	"ptype": "gxp_olsource" 
    }
           }
    

    Below a possible use case example:

    "geosolutions": {
    	"ptype": "gxp_wmssource",
    	"url": "http://localhost:8080/geoserver/ows",
    	"title": "GeoSolutions GeoServer",
    	"authParam": "authkey",
    	"version":"1.1.1",
    	"useScaleHints":"denominator",
        "layersCachedExtent": [
    		-20037508.34,-20037508.34,
    		20037508.34,20037508.34
    	],
    	"layerBaseParams":{
    		"FORMAT":"image/png8",
    		"TILED":true
    	}
    }
    
    • ptype: the type of the tool
    • url: the URL of the WMS source
    • title: the name of the WMS source visible in other MapStore's tools (if missing the one existing in WMS Capabilities is used)
    • authParam: the Authentication param (setted on GeoServer, i.e. 'authkey') in order to reflect
      authorizations settings on MapStore's map.
    • version: the version to use for the WMS
    • layersCachedExtent: during the GeoServer/GeoWebCache integration this property is used to align the extent used from MapStore with the defined Gridset in GWC(GeoServer WMS capabilities returns in this case only 4326 as SRS for the bbox of the layers, and the coordinate conversion to the map's SRS performed by proj4js is not aligned with the GWC Gridset, so tiles are not created properly).
    • layerBaseParams: the base params to use for each WMS GetMap request.
    • useScaleHints : Uses WMSCapabilities scaleHints or scaleDenominator (depending on the version) to avoid not useful requests when layer is not visible. Values are:
      • "udp" Use scalehints and transform the value from udp to denominator
      • "denominator": Use scaleHints or denominator
      • null (default): Doesn't use scaleHints or scaleDenominator
    • loadingProgress: if true, a loading spinner icon is shown on the layer tree node when the layer is loading and an error icon when one or more tiles cannot be loaded (available from version 1.7)
    • useCapabilities: if false, the source doesn't use WMS capabilities to load layers data, speeding up MapStore start; to be used for layers that can be completely configured statically. Depending on the properties configured on each layer some functionalities will not be available (for example if a bbox is not given, zoom to layer will not work) (available from version 1.7)
    • apiKey: Supported only on Bing Source, the API key to be used to access the Bing Maps service
  • proj4jsDefs: additional proj4js Definitions example:

      {"EPSG:3003":"+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +units=m +no_defs"}
    
  • map Map Configuration. Example:

    { "projection": "EPSG:900913", "units": "m", "center": [1250000.000000, 5370000.000000], "zoom":5, "maxExtent": [ -20037508.34, -20037508.34, 20037508.34, 20037508.34 ], "layers": [{ "source": "mapquest", "title": "MapQuest OpenStreetMap", "name": "osm", "group": "background" }] }

  • transitionEffect & zoomMethod: These properties values can be customized using a proper configuration object inside the map configuration. For example in order to disable these you can use the configuration below:

      "animatedZooming": {
      	"zoomMethod": null,
      	"transitionEffect": null
      }
    
  • tools:Optional Array of tools configurations. If present, overrides the configuration in Composer.js.

  • viewerTools: Optional Array of tools that overrides the default tools for the Viewer. If you want to customize the viewer with other custom layer selector, you can remove the LayerChooser from the toolbar adding disableLayerChooser:true to this configuration. NOTE:This options is not tested yet with configuration saving on GeoStore.

  • removeTools: Optional Array of tools to be removed from standard configuration. It can be a list of ids (of the standard plugins) or a list of objects with name - value matching properties (for example to remove all plugins of a certain ptype). Each standard plugin has an id that looks like <plugintype>_plugin. You can also remove standard separators, whose id is the combination of following plugin's id with a separator suffix (e.g. zoombox_separator). Some examples:

                     "removeTools":["googleearth_plugin", "googleearth_separator"]
    

    or

                     "removeTools":[{
                         "ptype": "gxp_googleearth"
                     }]
    
  • customTools: Optional Array of tools configurations. MapStore provides a default list of plugin used for the viewer. Using customTools you can provide an additional plugin configuration list to the default one.By default you cannot have two configuration of the same plugin. So that defined in customTools override the default one. In order to override this behavior MapStore allows you to specify a forceMultiple (setted to true) for the additional plugin configuration. In this way you can have multiple plugin’s instances. Below an example, to set a custom extent for the Zoom To Max Extent plugin:

      	"customTools":[
      	{
                  "ptype": "gxp_zoomtoextent",
                  "actionTarget": {"target": "paneltbar", "index": 1},
      	    "extent":[ 1046403.2 , 5200006.1,  1413757.5 ,   5544708.1]
      	},
      	{
                  "ptype": "gxp_zoomtoextent",
                  "forceMultiple":true,
                  "actionTarget": {"target": "paneltbar", "index": 13}
                  
      	}
      	/...
    

This configuration will change the extent of the default plugin (first config) and will add another one,using the forceMultiple attribute, with the default values instead.

  • portalConfig: Optional configuration to override gxp Viewer configuration.
    The configuration can be any configuration for Ext.Panel or Ext.Viewport.
    See here for more details.

  • customPanels: Optional Array of Ext.Panel configurations. If present allows to introduce additional panels to the viewport.

  • georeferences: Array of regions. If present, overrides the default georeferences_data variable defined in data/georeferences.js.

  • tab : Force to use Tabs visualization for the viewport.

Complete Example:

		{
		"geoStoreBase":"http://localhost:8080/geostore/rest/",
		"proxy":"/http_proxy/proxy/?url=",
		"defaultLanguage": "en",
		"gsSources":{ 

			"mapquest": {
				"ptype": "gxp_mapquestsource"
			}, 
			"osm": { 
				"ptype": "gxp_osmsource"
			},
			"google": {
				"ptype": "gxp_googlesource" 
			},
			"bing": {
				"ptype": "gxp_bingsource",
				"apiKey": "insert-API-key-here"
			}, 
			"ol": { 
				"ptype": "gxp_olsource" 
			}
		},
		"map": {
			"projection": "EPSG:900913",
			"units": "m",
			"center": [1250000.000000, 5370000.000000],
			"zoom":5,
			"maxExtent": [
				-20037508.34, -20037508.34,
				20037508.34, 20037508.34
			],
			"layers": [
				{
					"source": "bing",
					"title": "Bing Aerial",
					"name": "Aerial",
					"group": "background"
				}, {
					"source": "osm",
					"title": "Open Street Map",
					"name": "mapnik",
					"group": "background"
				},{
					"source": "mapquest",
					"title": "MapQuest OpenStreetMap",
					"name": "osm",
					"group": "background"
				},{
					"source": "google",
					"title": "Google Roadmap",
					"name": "ROADMAP",
					"group": "background"
				},{
					"source": "google",
					"title": "Google Terrain",
					"name": "TERRAIN",
					"group": "background"
				},{
					"source": "google",
					"title": "Google Hybrid",
					"name": "HYBRID",
					"group": "background"
				}
			]
		
		},
		"customTools": [
				{
				ptype: "gxp_googleearth",
				actionTarget: {target: "paneltbar", index: 24}
				}
		]
	}

Examples

In this section we show some useful configuration tricks.

Configure an empty background layer

To add an empty background to the backgrounds list, add the following configuration to the map layers array:

   {
        "source": "ol",
        "group": "background",
        "fixed": true,
        "type": "OpenLayers.Layer",
        "visibility": false,
        "args": [
            "None", {"visibility": false}
        ]
   }

Enable loading / error icons (from 1.7)

Using the loadingProgress flag on a wms source it is possible to show loading and error icons on layer tree nodes for layers contained in the specific source.

{
	"ptype": "gxp_wmssource",
	"url": "http://localhost:8080/geoserver/ows",
	"title": "GeoSolutions GeoServer",
	"version":"1.1.1",
	"layerBaseParams":{
		"FORMAT":"image/png8",
		"TILED":true
	},
	"loadingProgress": true
}

Add Custom panels directly from configuration

The customPanels attribute is an Array that can contain many Ext.Component configuration object that will be placed inside MapStore.

They can be used to wrap plugins, contain custom html or also other custom panels. One exemple of the use of custom panels is the markerEditor.

http://localhost:8081/viewer?config=markerEditor

The customPanelSample configuration is an ad hoc exemple to help you to use this useful configuration option. It shows nested panel definition, plugin placement, custom html, and also an IFrame.

http://localhost:8081/?config=customPanelSample

NOTE: if you want to place some custom panels inside other custom panel (e.g. some panels inside a tab), you have to place the container before the other panels in the array.

Custom panels can have the target attribute (String) . If present, the panel will be placed inside the container with this string as id (for exemple, the tab panel that contains the layer tree and the legend has west as id). If target is not present the panel will be placed inside the portalPanel.

This is an extract from customPanelSample.js

"customPanels":[
        {
            "xtype":"panel",
            "id":"additionalTab", 
	    "target": "west",
	    "title": "my New Tab",
            "layout":"accordion"
        },{
		"target":"additionalTab",
		"html":"This is a custom panel. Both this and 'my New Tab' are custom panels.",
		"title": "Panel 1"
	},{
		"target":"additionalTab",
		"html":"insert your plugin here",
		"title": "Panel 2"
	},{
            "xtype":"tabpanel",
            "id":"east", 
            "region": "east",
            "width": 570,
            "minWidth":550,
		"activeTab": 0,
		"border":false,
            "collapseMode": "mini" ,
	    "items":{
		"xtype":"panel",
		"id":"editor",
		"title":"editor",
		"layout":"fit",
		"target":"east"
			
	    }
        },{
	    "xtype":"panel",
            "id":"south", 
	    "region":"south",
	    "html":"another custom panel....",
	    "height":100
	},{
	    "target":"east",
	    "html":"<iframe style='width:100%;height:100%' src='http://mapstore.geo-solutions.it' ><iframe/>",
	    "layout":"fit",
            "itemId":"startTab",
	    "title": "MapStore WebSite"
	}
    ],
//....
"customTools":[
//...
{
	"ptype": "gxp_marker_editor",
	"outputTarget":"editor",
        "toggleGroup":"toolGroup"
}]

###Use a TabPanel to contains MetadataExplorer and FeatureGrid //... "customPanels":[ { "xtype": "tabpanel", "title": "Data Viewer", "border": false, "id": "south", "region": "south", "split":true, "height": 330, "collapsed": true, "collapsible": true, "activeItem": 0, "header": true, "hideMode": "offsets", "items": [ { "xtype": "container", "title": "Feature Grid", "border": false, "layout": "fit", "id": "featuregrid" },{ "xtype": "container", "title": "Metadata Explorer", "iconCls": "csw-viewer",
"border": false, "layout": "fit", "id": "metadata" } ] }, //...

Enable 45 degrees view with Google Aerial/Hybrid backgrounds

In MapStore, Google Maps 45 degrees view is disabled by default.
To enable it, you can set the useTiltImages flag to true in the google source:

"google": {
   "ptype": "gxp_googlesource",
   "useTiltImages": true
},

Enable display of localized Google Map layers and related onmap messages (from 1.5)

In MapStore google layers are displayed by default using the browser locale. To use the current MapStore locale instead, using the following configuration snippet:

"google": {
   "ptype": "gxp_googlesource",
   "localized":true
},
Clone this wiki locally