[OpenLayers-Users] preload layers

bradleyspencer brad at cubewerx.com.au
Thu Oct 11 09:19:10 EDT 2007


If you do not wish to load overlayed layers at startup you can load them via
your own layer control mechanism when the user wants to see them.

http://demo.cubewerx.com.au/OSDM/interopDemo01.html

In this demo, I load no layers other than the base. I then build a Layer
control of my own that shows all selected layers in the LayerSwitcher as
well. If you have loaded the layer once the cache remember the tiles and is
faster on a redisplay. Works well for me.

Cheers,

Brad

-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]On
Behalf Of R. Ortner
Sent: Thursday, 11 October 2007 10:44 PM
To: users at openlayers.org
Subject: Re: [OpenLayers-Users] preload layers



This is what OpenLayers is supposed to do. If something else is
happening, it is either a misconfiguration or a bug. Can you share the
HTML this is happening with?

Regards,
--
Christopher Schmidt
MetaCarta
_______________________________________________


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <style type="text/css">
        #map {
            width: 100%;
            height: 100%;
            border: 1px solid black;
        }
    </style>
    <script src="http://172.21.18.45/openlayers/lib/OpenLayers.js"></script>
    <script type="text/javascript">
        var map;
        function init(){
                    var options = { scales: [600000, 250000, 12500, 75000,
30000, 10000]
};
            map = new OpenLayers.Map('map', {'projection':'EPSG:31258',
'units':'m',
                     'maxExtent': new OpenLayers.Bounds(390730, 119473,
594760, 238680),
                     'maxResolution': "auto" }, { controls: [] });

                        //map.addControl(new
OpenLayers.Control.PanZoomBar());
                        map.addControl(new
OpenLayers.Control.MouseToolbar());
                        //map.addControl(new
OpenLayers.Control.MousePosition());
                        //map.addControl(new
OpenLayers.Control.OverviewMap());
                        map.addControl(new OpenLayers.Control.Scale());

// --------------------------------------------- Layer
------------------------------------------------------//

                        //
----------------------------------------------------------------------------
--------------------
                        // ---------------------------------- WMS
---------------------------------------------------------
                        //
----------------------------------------------------------------------------
--------------------

                        var oek50_wms = new OpenLayers.Layer.WMS( "OEK50
WMS",
                        "http://172.21.18.45/cgi-bin/mapserv?",
                        {layers:
'OEK50',map:'/usr/share/ka-map-1.0-20070205/htdocs/geoland_test.map',
transparent: 'true', format: 'png'}, {'isBaseLayer':false}, {projection:
"EPSG:31258"});
                        oek50_wms.setVisibility(false)

                        var ortho_wms = new OpenLayers.Layer.WMS(
"Orthophotos WMS",
                        "http://172.21.18.45/cgi-bin/mapserv?",
                        {layers:
'Orthofotos',map:'/usr/share/ka-map-1.0-20070205/htdocs/geoland_test.map',
format: 'png24'}, {'isBaseLayer':false}, {projection: "EPSG:31258"});
                        ortho_wms.setVisibility(false)

                        var land_wms = new OpenLayers.Layer.WMS( "Land WMS",
                        "http://172.21.18.45/cgi-bin/mapserv?",
                        {layers:
'Land',map:'/usr/share/ka-map-1.0-20070205/htdocs/geoland_test.map',
transparent: 'true', format: 'png'}, {'isBaseLayer':false}, {projection:
"EPSG:31258"});
                        land_wms.setVisibility(false)

                        var bezirk_wms = new OpenLayers.Layer.WMS( "Bezirk
WMS",
                        "http://172.21.18.45/cgi-bin/mapserv?",
                        {layers:
'Bezirk',map:'/usr/share/ka-map-1.0-20070205/htdocs/geoland_test.map',
transparent: 'true', format: 'png'},{projection: "EPSG:31258"},
{'isBaseLayer':false});
                        bezirk_wms.setVisibility(false)

                        var gemeinde_wms = new OpenLayers.Layer.WMS(
"Gemeinde WMS",
                        "http://172.21.18.45/cgi-bin/mapserv?",
                        {layers:
'Gemeinde',map:'/usr/share/ka-map-1.0-20070205/htdocs/geoland_test.map',
transparent: 'true', format: 'png'},{projection: "EPSG:31258"},
{'isBaseLayer':false});
                        gemeinde_wms.setVisibility(false)

                        //
----------------------------------------------------------------------------
--------------------
                        // -------------------------------- ka-Map
--------------------------------------------------------
                        //
----------------------------------------------------------------------------
--------------------


                        //var ortho_kamap = new OpenLayers.Layer.KaMap(
"Orthophotos ka-Map",
            //"http://172.21.18.45/ka-map/tile.php", {g: 'Orthophotos', map:
'/usr/share/ka-map-1.0-20070205/htdocs/geoland_test.map', transparent:
'true', i: 'png'}, {'isBaseLayer':false});
                        //ortho_kamap.setVisibility(false)

                        var oek50_kamap = new OpenLayers.Layer.KaMap( "OEK50
ka-Map",
            "http://172.21.18.45/ka-map/tile.php", {g: 'OEK50', map:
'/usr/share/ka-map-1.0-20070205/htdocs/geoland_test.map', transparent:
'true', i: 'png'}, {'isBaseLayer':false});
                        oek50_kamap.setVisibility(false)

                        var land_kamap = new OpenLayers.Layer.KaMap( "Land
ka-Map",
            "http://172.21.18.45/ka-map/tile.php", {g: 'Land', map:
'/usr/share/ka-map-1.0-20070205/htdocs/geoland_test.map', transparent:
'true', i: 'png'}, {'isBaseLayer':true});
                        land_kamap.setVisibility(true)

                        var bezirk_kamap = new OpenLayers.Layer.KaMap(
"Bezirk ka-Map",
            "http://172.21.18.45/ka-map/tile.php", {g: 'Bezirk', map:
'/usr/share/ka-map-1.0-20070205/htdocs/geoland_test.map', transparent:
'true', i: 'png'}, {'isBaseLayer':false});
                        bezirk_kamap.setVisibility(true)

                        var gemeinde_kamap = new OpenLayers.Layer.KaMap(
"Gemeinde ka-Map",
            "http://172.21.18.45/ka-map/tile.php", {g: 'Gemeinde', map:
'/usr/share/ka-map-1.0-20070205/htdocs/geoland_test.map', transparent:
'true', i: 'png'}, {'isBaseLayer':false});
                        gemeinde_kamap.setVisibility(false)

                        map.addLayers([ortho_wms, oek50_wms, oek50_kamap,
land_wms, bezirk_wms,
bezirk_kamap, gemeinde_wms, gemeinde_kamap, land_kamap]);
                        map.addControl(new
OpenLayers.Control.LayerSwitcher());
            map.zoomToMaxExtent();
        }
    </script>
  </head>
  <body onload="init()">
  <!--  <h1>Orthophotos</h1> -->
    <div id="map"></div>
  </body>
</html>
--
View this message in context:
http://www.nabble.com/preload-layers-tf4605757.html#a13154913
Sent from the OpenLayers Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list