-
Notifications
You must be signed in to change notification settings - Fork 5
Customization
The XVM was created with the main idea of having an easy-to-deploy highly customizable viewer. Thus we decided to provide a few key places where we could configure the XVM, and build it with a modular approach that created as least coupling as possible between all the classes.
Right now, all this is indirectly managed through XVM.js (because it's the facade of our whole system), which contains the following working configurable attributes:
- DIVNAME: name of the html div where the map will be rendered. By default it's 'map'.
- CONFIGFILE: path to the map options yaml file that contains the options for the OpenLayers Map (see Map Options below). It can be either relative (from the html file loaded) or absolute. Its default value is 'config/map.options.yaml'.
- LAYERSFILE: path to the layers description yaml file that contains the description of the layers we wish to load in our map (see Map Layers below). Default value is 'map.layers.yaml'.
- CONTROLSFILE: path to the controls yaml file that lists the controls we want to create and add to our map (see Map Controls below). It's set to 'config/map.controls.yaml' by default.
- CONTROLSFOLDER: path to the folder where we will store the code for the XVM Controls we wish to add to our map (the ones listed in CONTROLSFILE). Default value is 'src/Control'.
The yaml file with the map options (by default 'config/map.options.yaml') is the place where we define both the general parameters for the viewer and the parameters we want for the OpenLayers Map created inside our Map class.
General parameters must be stored inside a 'general' structure, and we currently support:
- lang: language we want to use for the viewer's GUI messages.
- height_map: height (in pixels) we want for our viewer when rendering it.
- width_map: the same, but this time regarding its width (in pixels).
- margin: margin (in pixels) we want to apply to our viewer's div. OpenLayers Map parameters are stored inside 'map_settings', see OpenLayers Map api for more details.
Parameters for configuring our OpenLayers Map (see OpenLayers Map api for more details) are included inside 'map_settings':
- epsg: the code of projection of our map (e.g. 'EPSG:23029').
- units: the base length unit for our map (e.g. 'm').
- bounds: here we can specify the bounds of our map by providing the coordinates of the bottom left and top right corners.
- resolutions: zoom levels can be defined here with an array of numeric values (map units per pixel). If both options are specified, bounding box will prevail. Finally, 'view_settings' stores parameters for defining our initial view in the map. We have two options for doing this:
- bbox: here we should define an array with four numeric values, which will be the coordinates of the bounding box's bottom left and upper right corners.
- zoom & center: we define the coordinates of the center of our view, and with which zoom level we want to start with (see resolutions above). You can have a look at our map.options.yaml file for an example.
All the parameters specified in the yaml file can be overwritten by providing them by GET (e.g. <xvm_url>?zoom=5&bounds=460000,4625000,690000,4855000). It's important to keep in mind as of now it only works with the map options specified above, and that they must exist in the file in order to be overwritten.
The yaml file that contains the list of controls we wish to create for our map (by default 'config/map.controls.yaml'). It simply includes a list of strings with the name of our controls, which should be in a subfolder with their name inside the XVM CONTROLSFOLDER path (see XVM Class above). For details onto the files each control needs, check Creating New Controls. For example, with the default values, if we include 'ZoomIn' inside the yaml file we should have a folder 'Control/ZoomIn' with the control's files.
Panel controls are added to the panel in the order they are listed here, which means prior controls are the upper ones in the vertical panel. We can overwrite this default position by providing the field position in their yaml file.
You can have a look at our map.controls.yaml file for an example.
The yaml file in which we describe the layers we want to load into our map (by default 'map.layers.yaml'). We can configure our layers by providing an urlServiceLayer or, if its value is '' or null, with an array of layer objects with the following supported attributes:
- layer_name: the name we will assign to the layer inside the XVM.
- type: how the layer is loaded. Its values can be 'wms' (WMS layers), 'geojson' (static GeoJson layers), 'ajax' (dynamically generated GeoJson layers) or 'google' (Google Maps layers).
- wms_layer: in case our layer type is 'wms', we must specify its name for the WMS service.
- url: the url where we are loading it from.
OpenLayers Layer parameters are stored inside 'parameters' (check OpenLayers Layer api for more details). Some of these parameters are important for our viewer:
- group_name: here we specify the layer group under which we will put our layer in the TOC. Using the Tree TOC allows us to specify multi-level grouping by separating them with '/' (e.g. 'group1/subgroup1').
- isBaseLayer: whether our layer is a base one or not.
- projection: the projection the layer is supplied with.
- layer_position: lets us configure the order in which the layers are rendered onto the map. A lower value means under other layers.
- type: this parameter is used only with Google Maps layers, and it describes the map we want. Its value can be 'satellite', 'terrain', 'hybrid' or 'roadmap'.
You can have a look at our map.layers.yaml file for an example.