HSLayers.MapPortal

HSLayers.MapPortal() is MapViewer, extended with several HSLayers.Control() controls and other widgets. The OpenLayers.Map object is created automatically, and you only can give it some parameters using HSLayers.MapPortal.mapOptions parameter while initializing.

../../_images/mapportal.png

Same configuration options do apply here as well as for the HSLayers.MapViewer plus the following ones:

controls

List of keywords representing controls to be added to the map. If none are add, the default ones are used:

  • panzoombar will add HSLayers.Control.PanZoomBar() to the map
  • scaleswitcher will add HSLayers.Control.ScaleSwitcher() to the top toolbar of the HSLayers.MapPanel()
  • scaleline will add OpenLayers.Control.ScaleLine to the bottom bar of the MapPanel
  • mouseposition will add OpenLayers.Control.MousePosition to the bottom toolbar of the map
  • attribution will add HSLayers.Control.Attribution() (as copyright sign) to the bottom toolbar of the HSLayers.MapPanel()
  • permalink will add HSLayers.Permalink() button the top toolbar of the MapPanel
  • print will add button to the top toolbar of the MapPanel, which will make HSLayers.Print.PrintDialog() to run
printCfg
optional configuration for HSLayers.print.PrintDialog()
userGraphicsCfg
option configuration for HSLayers.Control.UserGraphics()
mapOptions
optional configuration for OpenLayers.Map
renderTo
Standard Ext.Panel.renderTo option
panZoomBar
Configuration options for HSLayers.Control.PanZoomBar()
projections
List of OpenLayers.Projection supported by the map
queryHandlerClass
Default is OpenLayers.Handler.Box but it can be Handler.Point as well. It is the handler class, which is used for the HSLayers.Control.Query()

For example see MapPortal example

You may see, now it’s getting to be hard. How to make this shorter? Again, use the one-file shortcut:

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

Note

It is prefered for debugging reasons, either to include MapPortal-debug.js or to build HSLayers with the -D option for the build script.

Several environment variables (see HSLayers & OpenLayers global configuration variables) have to be set at the beginning

1
2
3
4
5
6
7
8
            OpenLayers.ImgPath = "http://hslayers.org/lib/build/img/";
            HSLayers.WMCManager.getImagesURL = "wmc_logos.js";
            HSLayers.Print.printerUrl = "/hsprinter/print";
            HSLayers.statusManagerUrl = "/statusmanager/index.php";
            OpenLayers.ProxyHost = "/cgi-bin/hsproxy.cgi?toEncoding=utf-8&url=";
            OpenLayers.DOTS_PER_INCH = 90.714236728598;

            HS.setLang(HS.getLastLangCode());

Language of the map application can be taken from the previous cookie

You can create map options from particular function or create it “by hand”. See [1]

1
2
3
            var mapOptions = HSLayers.Util.getProjectionOptions("epsg:900913");
            mapOptions.controls = [];
            mapOptions.layers = [topo,gmap];

Once javascripts are set, it’s going to be easy. Create the MapPortal object and pass the configuration for OpenLayers.Map object along it:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
            geoportal = new HSLayers.MapPortal({
                    layout: "fit",
                    region: "center",
                    panels:[ "layerSwitcher", "infoPanel", "owsPanel" ],
                    panZoomBar: { 
                        dummyScales: [
                                {scale:1000000,label:"States"},
                                {scale: 200000,label:"Cities"},
                                {scale: 5000,label:"Towns"},
                                {scale: 500,label:"Parcels"}
                            ]
                    },
                    printCfg: {
                        title: OpenLayers.i18n("Print")
                        // ...
                    },
                    owsCfg: {
                        urls: [
                            ["http://bnhelp.cz/ows/crwfs","WFS"],
                            ["http://bnhelp.cz/ows/crtopo","WMS"]
                        ]
                    }
                }); 

Finally, set map to MapPortal:

1
2
            var map = new HSLayers.Map(mapOptions);
            geoportal.setMap(map);

Since HSLayers.MapPortal() is derived from Ext.Panel you can use all configuration options for that class as well.

Indicate, that the map was initialized. All layers, which are now in the map, will be considered as “base layers” – they will not be stored to WMC, they will be not store during the session, etc.

You also have to run the HSLayers.Control.InitBus, available in the map:

1
2
        geoportal.mapInitialized();
        geoportal.initBus.run();

HSLayers.MapPortal layers

MapPortal comes with several pre-defined layers, which will be always available in the map. Some of them will be visible to the user, some of them not. They can be used (and often are used) by various controls of the map.

HSLayers.MapPortal.vectorLayer – layer used for some oprations, such se measuring of
lengths and areas. This layer is cleared, when user clicks at the Clear button.
HSLayers.MapPortal.markerLayer – layer used for displaying various markers (e.g.
results of searching). This layer is cleared, when user clicks at the Clear button.
HSLayers.MapPortal.userGraphicsLayer – layer used by
HSLayers.Control.UserGraphics() for editing and drawing of user graphics.

HSLayers.MapPortal attributes

Config option: constrols – list of strings (keywords). This controls will be added to the map (already described earlyer on this page). Default are panzoombar, scaleswitcher, scaleline, mouseposition, attribution, permalink, print

MapPortal will have following control attributes, which can be accessed and modified later to your needs:

Note

In following text, only relevant attributes of MapPortal from the user’s point of view are dicussed. For more detailed description please refer the API documentation

HSLayers.MapPortal.mapToolBar is a instance of OpenLayers.Control.Panel

and it is the toolbar on the top of the map, where various map-related tools can be placed.

../../_images/toolbar.png
HSLayers.MapPortal.initBus is a instance of HSLayers.InitBus().
This class is to be used for registering steps, which will be performed one-after-one (based on event or some function). New function can be assigned using HSLayers.InitBus.register() function. After geoportal is initialized, HSLayers.InitBus.run() is to be called.
HSLayers.MapPortal.mapControls list of

OpenLayers.Controls, which are available in the map. They can be configured with controls. Default controls are described earlier in this chapter.

HSLayers.MapPortal.mapControls.permalink
instance of HSLayers.Permalink(). Enables to the user to share URL with curent map state.
HSLayers.MapPortal.mapControls.scaleline
instance of OpenLayers.Control.ScaleLine. Displays scale line with scale of current map extent.
HSLayers.MapPortal.mapControls.mouseposition
instance of OpenLayers.Control.MousePosition. Displays current position of map pointer while pointing somewhere on the map.
HSLayers.MapPortal.mapControls.attribution
instance of HSLayers.Control.Attribution(). There will be link in the map, which will open window (on click) with copyright information of displayed layers.
HSLayers.MapPortal.mapControls.print
This is a button, which will start instance of HSLayers.Print.PrintDialog(), this will enable printing of current map layers.
HSLayers.MapPortal.mapControls.navigation
instance of OpenLayers.Control.Navigation - mouse navigation on the map.
HSLayers.MapPortal.mapControls.zoomHistory
instance of OpenLayers.Control.NavigationHistory - two arrows in the map for previous/next zoom extends.
HSLayers.MapPortal.mapControls.userGraphics
instance of HSLayers.Control.userGraphics for measuring lines, areas and drawing custom vector features.
HSLayers.MapPortal.mapControls.query
instance of HSLayers.Control.Query() WMS GetFeatureInfo and MapServer queries, as well as attributes of displayed vector layers.
HSLayers.MapPortal.selectFeatureControl
instance of HSLayers.Control.SelectFeature() used for trigger featureselected event, when clicking on some vector feature. Every vector layer added to the map will automatically be added to this control and the event will be generated on click.
HSLayers.MapPortal.readStateControl
instance of HSLayers.Control.ReadState stores automatically content of the map to the server (on reload or on closing the page), for later restoring.
HSLayers.MapPortal.saveStateControl
instance of HSLayers.Control.SaveState() restores automatically content of the map from previous session.
HSLayers.MapPortal.initBus

instance of HSLayers.InitBus() call stack of functions, one-by-one, like

  • getting status from the server
  • parse additional URL parameters
  • ...

User can register his custom functions and add the to the bus.

HSLayers.MapPortal.map
instance of OpenLayers.Map – this is the map.

Some notes to the MapPortal

MapPortal is lying on the top of HSLayers. It uses all it’s components and bunch of server scripts. It has (among others) following functionalities:

  • Can remember your last state and restore the application in the form, you left it
  • Printing of hardcopy maps
  • WMS and WFS, WCS, KML and other data types client
  • Advaced LayerSwitcher
  • Advanced Query tool (both WMS and MapServer)
  • Accepts wms=http://foo/bar parameter in the url and calls the OWS manager immediately
  • Area and line measurements, user graphics
  • There is one base layer already defined in the portal, it is 1x1 pixel big transparent image. All your layers should be overlays and if you want to indicate them in the layerswitcher to be at the bottom, use isBaseGroup instead (more on this in the LayerSwitcher description).
  • There is already HSLayers.MapPortal.vectorLayer and HSLayers.MapPortal.markerLayer layers defined in the portal, so you can use them for rendering of temporary vector or marker features in the map. Features are removed, when the Clear button in the HSLayers.Control.InfoPanel is clicked.

  • Vector editing

In next sections, we will be talking about several HSLayers.Controls and HSLayers.Layer components more detaily.

[1]See OpenLayers.Map Contructor documentation

Main Menu


Table Of Contents

Previous topic

HSLayers.MapViewer

Next topic

HSLayers.Control

This Page