HSLayers.MapPortal

HSLayers.MapPortal is MapViewer, extended with several HSlayers.Control controls. It is also placed into Ext.Viewport, means it is rendered to entire content of the web page. The OpenLayers.Map object is created automatically, and you only can give it some parameters using mapOptions parameter while initializing.

Example: http://dev.bnhelp.cz/wwwlibs/hslayers/branches/editace/examples/MapPortal.html

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
        <script type="text/javascript" src="../source/HS.js"></script>
        <script type="text/javascript" src="../source/HSLayers.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Util.js"></script>
        <script type="text/javascript" src="../source/HSLayers/MapPortal.js"></script>
        <script type="text/javascript" src="../source/HSLayers/MapViewer.js"></script>
        <script type="text/javascript" src="../source/HSLayers/InfoPanel.js"></script>
        <script type="text/javascript" src="../source/HSLayers/OWS.js"></script>
        <script type="text/javascript" src="../source/HSLayers/OWS/WMS.js"></script>
        <script type="text/javascript" src="../source/HSLayers/OWS/WFS.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Printer.js"></script>
        <script type="text/javascript" src="../source/HSLayers/MapPanel.js"></script>
        <script type="text/javascript" src="../source/HSLayers/MapPanel/HistoryButtons.js"></script>
        <script type="text/javascript" src="../source/HSLayers/MapPanel/WMCButtons.js"></script>
        <script type="text/javascript" src="../source/HSLayers/MapPanel/WMCForm.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Control/LayerSwitcher.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Control/ProjectionSwitcher.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Control/ScaleSwitcher.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Control/Measure.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Control/DrawControls.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Control/Query.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Control/Click.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Control/Pin.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Control/ArgParser.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Control/Permalink.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Control/State.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Layer/MapServer.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Layer/WMS.js"></script>
        <script type="text/javascript" src="../source/HSLayers/Layer/WarpedWMS.js"></script>

You 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>

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
            var mapOptions = HSLayers.Util.getProjectionOptions("epsg:102067",2000000,500);
            mapOptions.initialExtent = new OpenLayers.Bounds(-821745,-1101336,-622249,-1035719);
            geoportal = new HSLayers.MapPortal({
                mapOptions: mapOptions,
                //projections: ["epsg:102067","epsg:900913","epsg:4326"]
                projections: ["epsg:102067"]

            });

Create some map layer and add it to map

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
    var topoLayer = new HSLayers.Layer.MapServer("HS-RS (HSRSMapServer)",
                        "http://www.bnhelp.cz/mapserv/hsmap/hsmap.php",
                        {project:"cr_hslayers",layers:"hrady_g zamky_g"},
                        {visibility:false,
                        saveWMC: false,
                        isBaseLayer: false,buffer:2});



        geoportal.map.addLayers([cuzk_pk,cuzk_kn,topoLayer]);
            geoportal.map.zoomToMaxExtent();

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 manager
  • Advaced LayerSwitcher
  • Advanced Query tool (both WMS and MapServer)
  • Accepts ows=http://foo/bar parameter in the url and calls the OWS manager immediately
  • Area and line measurements
  • 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.vlayer and HSLayers.MapPortal.mlayer 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.

Table Of Contents

Previous topic

HSLayers.MapViewer

Next topic

HSLayers.Control

This Page