HSLayers.MapViewer

HSLayers.MapViewer() is comprehensive shortcut for HSLayers.MapPanel(), HSLayers.InfoPanel(), HSLayers.WMCManager() and other objects and controls, among others it is the HSLayers.LayerSwitcher().

It is based on Ext.Panel, with border layout, where the HSLayers.MapPanel() is based in the center region and there is also HSLayers.MapViewer.ToolsPanel() (which is a HSLayers.MapViewer.toolsPanel located in the east region of the panel.

../../_images/mapviewer.png

HSLayers.MapViewer.ToolsPanel() contains the HSLayers.LayerSwitcher(), HSLayers.InfoPanel(), HSLayers.OWSPanel() and other panels. It uses Ext.layout.AccordionLayout.

The OpenLayers.Map has to be initialized manually and set with HSLayers.MapViewer.setMap() function.

If you want to use the HSLayers.MapViewer() class, consider to include build/MapViewer.js file, which should have every dependency already included (see Build HSLayers, which describes the build system of HSLayers).

You see, that number of JavaScripts got a bit longer. Don’t worry, we will make it shorter in next step. Anyway, this is much better for debugging. Consider (as already said) using:

<script type="text/javascript" src="build/MapViewer.js"></script>

This is in one compressed file everything you need for the MapViewer. But to debug this is a hell, so as compromise, you can use:

<script type="text/javascript" src="build/MapViewer-debug.js"></script>

Which is the same, but in uncompressed form and so it is easier to debug in case error comes out (which surely will).

Note

You can use also the -D option for build.py script.

Creating a map with LayerSwitcher and InfoPanel, Printing, OWS clients is simple:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
            mapViewer = new HSLayers.MapViewer({
                width: 800,
                height:550,
                renderTo: Ext.getBody()
            });

            map = new OpenLayers.Map(mapViewer.mapPanel.body.dom.id);
            map.addLayer(new OpenLayers.Layer.WMS("MetaCarta WMS",
                       "http://labs.metacarta.com/wms/vmap0",
                       {layers: 'basic'}
                   ));
            map.zoomToMaxExtent();
            mapViewer.setMap(map);

For example see http://hslayers.org/lib/examples/MapViewer.html.

MapViewer configuration

It should be possible to pass configuration options for all underlying elements of MapViewer. You can pass the options as attributes of the configuration object of the MapViewer. Following keywords are taken into account:

layerSwitcherCfg
Configuration object of the HSLayers.LayerSwitcher() class, see HSLayers.LayerSwitcher
infoPanelCfg
Configuration object of the HSLayers.InfoPanel() class see HSLayers.InfoPanel
owsCfg
Configuration object of the HSLayers.OWSPanel() class see HSLayers.OWS
mapPanelCfg
Configuration object of the HSLayers.MapPanel() class see HSLayers.MapPanel
wmcManagerCfg
Configuration object of the HSLayers.WMCManager() class see HSLayers.WMCManager

Main Menu


Table Of Contents

Previous topic

HSLayers.Control.LayerSwitcher

Next topic

HSLayers.MapPortal

This Page