[mapserver-users] turning on layers at a particular zoom level

sunny74 sb.ray at hotmail.com
Wed Sep 2 09:04:04 EDT 2009


Hi,

Thanks for ur reply.
1)What is the syntax for send request against a Group?
2)If I just write the name of the group within  layer then will it be placed
against the group?
3) What is the syntax for checking the zoom level of a map so that once a
zoom level is reached I can call a group of layers?

Regards.

Rahkonen Jukka wrote:
> 
> Hi,
> 
> Collect the layers to one GROUP, and send requests against the GROUP
> instead of the original scale dependent layers.  Mapfile may have
> something like this inside:
> 
> LAYER
>     GROUP "group"  
>     NAME "scale1"
>     MAXSCALEDENOM 100000
>     .
>     .
>     .
>  END 
>    
> LAYER
> GROUP "group"  
>       NAME "scale2"
>       TYPE POLYGON
>       MAXSCALEDENOM 1000000
>       MINSCALEDENOM 100000
>       .
>       .
>       .
>  END
> 
> 
> sunny74 wrote:
>> 
>> 
>> Hi,
>> 
>> Thanks for the reply.
>> 
>> 1) Can u tell me how to sandwich all the layers and make one 
>> WMS call to the server and request all of the layers in one 
>> image/call.
>> Presently I am calling the layers separately as below:
>> 
>> function init() {
>> 
>>          //alert("in init");
>>          map = new OpenLayers.Map('<%=map.ClientID%>');
>> 
>>          //
>>          layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
>>                 
>> "http://172.16.128.173:8085/cgi-bin/mapserv.exe?", { map:
>> 'Shape/newwr1.map', layers: 'STATE', 'format': 'png' });
>> 
>>          layer1 = new OpenLayers.Layer.WMS("Rail Main",
>>                 
>> "http://172.16.128.173:8085/cgi-bin/mapserv.exe?", { map:
>> 'Shape/newwr1.map', transparent: 'true', layers: 'Railwayline' });
>> 
>> //         layer2 = new OpenLayers.Layer.WMS("Rail WaterBody",
>> //                
>> "http://172.16.128.173:8085/cgi-bin/mapserv.exe?", { map:
>> 'Shape/newwr1.map', transparent: 'true', layers: 'WaterBody' });
>> 
>> //         layer3 = new OpenLayers.Layer.WMS("Rail Rail_Buffer",
>> //                
>> "http://172.16.128.173:8085/cgi-bin/mapserv.exe?", { map:
>> 'Shape/newwr1.map', transparent: 'true', layers: 'Rail_Buffer' });
>> 
>> //         layer4 = new OpenLayers.Layer.WMS("Roads",
>> //                
>> "http://172.16.128.173:8085/cgi-bin/mapserv.exe?", { map:
>> 'Shape/newwr1.map', transparent: 'true', layers: 'Roads' });
>> 
>> //         layer5 = new OpenLayers.Layer.WMS("Diversions",
>> //                   
>> "http://172.16.128.173:8085/cgi-bin/mapserv.exe?", {
>> map: 'Shape/newwr1.map', transparent: 'true', layers: 'Diversions' });
>> 
>> //         layer6 = new OpenLayers.Layer.WMS("Rail Side_Line",
>> //                   
>> "http://172.16.128.173:8085/cgi-bin/mapserv.exe?", {
>> map: 'Shape/newwr1.map', transparent: 'true', layers: 
>> 'Rail_Side_Line' });
>> //         layer7 = new OpenLayers.Layer.WMS("LANDMARKS",
>> //                   
>> "http://172.16.128.173:8085/cgi-bin/mapserv.exe?", {
>> map: 'Shape/newwr1.map', transparent: 'true', layers: 'LANDMARKS' });
>>          layer8 = new OpenLayers.Layer.WMS("RailwayStations",
>>                    
>> "http://172.16.128.173:8085/cgi-bin/mapserv.exe?", { map:
>> 'Shape/newwr1.map', transparent: 'true', layers: 'RailwayStations' });
>> //         layer9 = new OpenLayers.Layer.WMS("Bridges_Minor",
>> //                   
>> "http://172.16.128.173:8085/cgi-bin/mapserv.exe?", {
>> map: 'Shape/newwr1.map', transparent: 'true', layers: 
>> 'Bridges_Minor' });
>> //         layer10 = new OpenLayers.Layer.WMS("Bridge_Major",
>> //                   
>> "http://172.16.128.173:8085/cgi-bin/mapserv.exe?", {
>> map: 'Shape/newwr1.map', transparent: 'true', layers: 
>> 'Bridge_Major' });
>> //         layer11 = new OpenLayers.Layer.WMS("LC_Gate",
>> //                   
>> "http://172.16.128.173:8085/cgi-bin/mapserv.exe?", {
>> map: 'Shape/newwr1.map', transparent: 'true', layers: 'LC_Gate' });
>>          
>> //                   
>>                  
>>          highlight = new OpenLayers.Layer.Vector("highlight", { style:
>> vector_style });
>>          choice_features = new 
>> OpenLayers.Layer.Vector("choice_features", {
>> style: v_style });
>>          distline = new OpenLayers.Layer.Vector("distline", { style:
>> vector_style });
>>          //GML = new OpenLayers.Layers.GML("GML", { style: v_style });
>> 
>>          //
>>          map.addLayers([layer, layer1, layer8, highlight,distline]);
>>          //         markers = new OpenLayers.Layer.Markers("markers");
>>          //         map.addLayer(markers);
>> 
>>          //         map.OpenLayers.Control.PanZoom.destroy();
>>          //         map.OpenLayers.Control.MouseToolbar.destroy();
>>          map.zoomToMaxExtent();
>>          map.setCenter(new OpenLayers.LonLat(73.25, 20.35), 7);
>> 
>>          map.addControl(new OpenLayers.Control.PanZoomBar());
>>          //map.addControl(new OpenLayers.Control.MouseToolbar());
>>          map.addControl(new OpenLayers.Control.LayerSwitcher());
>>          map.addControl(new OpenLayers.Control.MousePosition());
>> 
>>          map.addControl(new OpenLayers.Control.OverviewMap());
>>          map.addControl(new OpenLayers.Control.Scale());
>> 
>> }
>> 
>> 2) Is there a way by which the layers will load at certain 
>> zoom level bec'
>> in case of MAXSCALEDENOM /MINSCALEDENOM the layers are 
>> loading at PageLoad while only visible at that zoom level.
>> 
>> 3)If I use TileCache layer instead of Wms then will it load faster.
>> 
>> Regards.
>> 
>> Fawcett, David wrote:
>> > 
>> > 1.  You can use MINSCALEDENOM and MAXSCALEDENOM at either 
>> the layer or 
>> > class level (on a current version of MapServer).  So, it looks like 
>> > they are in an appropriate place.  The real test is to use 
>> MapServer 
>> > to draw the layer for you.  Does it turn on and off at the 
>> scales that 
>> > you want it to?
>> > 
>> > 2.  Yes, it can apply to both the layer or class 
>> properties.  I assume 
>> > that you looked here:  
>> > http://www.mapserver.org/mapfile/class.html#class
>> > 
>> > 3.  MapServer has nothing to do with when things load.  This all 
>> > happens on your client.  It sounds like you modified your client to 
>> > request each layer individually.  If you just want to sandwich them 
>> > all together, why not just make one WMS call to the server 
>> and request 
>> > all of the layers in one image/call.  This question is really more 
>> > appropriate for the OpenLayers list.
>> > 
>> > 4.  I would consult the TileCache or OpenLayers list for this one.
>> > 
>> > David.
>> > 
>> > 
>> > -----Original Message-----
>> > From: mapserver-users-bounces at lists.osgeo.org
>> > [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf 
>> Of sunny74
>> > Sent: Saturday, August 29, 2009 2:01 AM
>> > To: mapserver-users at lists.osgeo.org
>> > Subject: RE: [mapserver-users] turning on layers at a 
>> particular zoom 
>> > level
>> > 
>> > 
>> > 
>> > Hi David,
>> > 
>> > Thanks for your reply.
>> > I wanted to have 3 layers displayed b/w scale of 1.2M and 
>> 1.15M and so 
>> > I have added set MAXSCALEDENOM /MINSCALEDENOM as follows:
>> > 
>> >  LAYER
>> >     NAME 'WaterBody'
>> >     TYPE POLYGON
>> >     DATA 'C:\ms4w\Apache\cgi-bin\Shape\WaterBody.shp'
>> >     METADATA
>> >       'wms_title' 'WaterBody'
>> >     END
>> >     STATUS OFF
>> >     TRANSPARENCY 100
>> >     PROJECTION
>> >     'proj=longlat'
>> >     'ellps=WGS84'
>> >     'datum=WGS84'
>> >     'no_defs'
>> >     ''
>> >     END
>> >     CLASS
>> >        NAME 'WaterBody' 
>> >        MAXSCALEDENOM 2000000
>> >        MINSCALEDENOM 1500000
>> >        STYLE
>> >          SYMBOL 0 
>> >          SIZE 2 
>> >          OUTLINECOLOR 0 0 0
>> >          COLOR 150 123 90
>> >        END
>> >     END
>> >   END
>> > 
>> > 1)Pls tell me whether I hav added the things at the correct place.
>> > 2) Can I also add it within the layer properties?
>> > 3) I find that the layers are being added at PageLoad.This 
>> I found out 
>> > by looking at the number of items being added at the bottom left 
>> > corner of IE. The number of items has nearly doubled due to the 
>> > addition of the 3 layers. Is there any way by which I can stop the 
>> > layers from being added at PageLoad i.e they should be 
>> added only when 
>> > the desired scale is reached.
>> > 
>> > 4) How to use TileCache or GeoWebCache i.e js code?
>> > 
>> > Thanks again.
>> > 
>> > Fawcett, David wrote:
>> >> 
>> >> I assume the 'M' stands for million.
>> >> 
>> >> If you want the layer to be only visible when 'zoomed in' beyond 
>> >> 1:2M, I would set a MAXSCALEDENOM of 2000000.
>> >> 
>> >> If you want the layer to be only visible when 'zoomed out' beyond 
>> >> 1:2M, I would set a MINSCALEDENOM of 2000000.
>> >> 
>> >> If you only want the layer to be visible between resolutions of 
>> >> 1:100000 and 1:200000, you would set:  both MINSCALEDENOM 
>> 100000 and 
>> >> MAXSCALEDENOM 200000
>> >> 
>> >> These values go in either a LAYER or CLASS of LAYER in 
>> your MapServer map
>> >> file.   
>> >> 
>> >> 
>> >> -----Original Message-----
>> >> From: mapserver-users-bounces at lists.osgeo.org
>> >> [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf 
>> Of sunny74
>> >> Sent: Friday, August 28, 2009 8:45 AM
>> >> To: mapserver-users at lists.osgeo.org
>> >> Subject: Re: [mapserver-users] turning on layers at a 
>> particular zoom 
>> >> level
>> >> 
>> >> 
>> >> 
>> >> Hi,
>> >> 
>> >> Thanks for your reply.
>> >> I went thru the link and read about 
>> MAXSCALEDENOM/MINSCALEDENOM. So 
>> >> MINSCALEDENOM is the minimum scale level at which a layer 
>> will become 
>> >> visible. But I am a bit confused.When the map loads for the first 
>> >> time it has a zoom level of 7 as given in the code below.
>> >> 
>> >> map.setCenter(new OpenLayers.LonLat(74.25, 20.35), 7);
>> >> 
>> >> In terms of scale it is showing 1:3M.
>> >> What is M? 
>> >> If I increase the zoom level i.e do zoom in, scale becomes 
>> 1:856K and 
>> >> 1:256K etc i.e scale decreases. So If want a layer to be 
>> visible at a 
>> >> scale level of 1:2M what do I write in the mapfile?
>> >> 
>> >> How to use TileCache or GeoWebCache?Pls give the js code.
>> >> 
>> >> 
>> >> Rahkonen Jukka wrote:
>> >>> 
>> >>> Hi,
>> >>> 
>> >>> Mapserver is somehow documented, about adjusting visibility 
>> >>> according to scale, try to find MAXSCALEDENOM/MINSCALEDENOM from
>> >>> http://www.mapserver.org/mapfile/layer.html#index-21
>> >>> 
>> >>> Mapserver does not do caching but you can use for examply 
>> TileCache 
>> >>> or GeoWebCache between your clients and Mapserver.
>> >>> 
>> >>> -Jukka Rahkonen-
>> >>> 
>> >>> 
>> >>> 
>> >>>> -----Alkuperäinen viesti-----
>> >>>> Lähettäjä: mapserver-users-bounces at lists.osgeo.org
>> >>>> [mailto:mapserver-users-bounces at lists.osgeo.org] Puolesta sunny74
>> >>>> Lähetetty: 28. elokuuta 2009 14:53
>> >>>> Vastaanottaja: mapserver-users at lists.osgeo.org
>> >>>> Aihe: [mapserver-users] turning on layers at a particular zoom 
>> >>>> level
>> >>>> 
>> >>>> 
>> >>>> DEar Friends,
>> >>>> 
>> >>>> I have 12 layers in my map and it is taking tooooo long to 
>> >>>> load.Therefore I decided to turn on only 2 layers at Page Load.
>> >>>> 
>> >>>> Rest of the layers I want to turn on  at a particular zoom 
>> >>>> level.How can I check the zoom level and turn on these layers.
>> >>>> 
>> >>>> How can make the map load faster especially on page 
>> reload? Is it 
>> >>>> possible to cache the map or is there some other technique?
>> >>>> 
>> >>>> Thanks for ur reply.
>> >>>> 
>> >>>> --
>> >>>> View this message in context: 
>> >>>> http://n2.nabble.com/turning-on-layers-at-a-particular-zoom-le
>> >>>> vel-tp3534156p3534156.html
>> >>>> Sent from the Mapserver - User mailing list archive at 
>> Nabble.com. 
>> >>>> _______________________________________________
>> >>>> mapserver-users mailing list mapserver-users at lists.osgeo.org 
>> >>>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>> >>>> 
>> >>> _______________________________________________
>> >>> mapserver-users mailing list
>> >>> mapserver-users at lists.osgeo.org
>> >>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>> >>> 
>> >>> 
>> >> 
>> >> --
>> >> View this message in context:
>> >> 
>> http://n2.nabble.com/turning-on-layers-at-a-particular-zoom-level-tp3
>> >> 534156p3534743.html Sent from the Mapserver - User mailing list 
>> >> archive at Nabble.com.
>> >> _______________________________________________
>> >> mapserver-users mailing list
>> >> mapserver-users at lists.osgeo.org
>> >> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>> >> _______________________________________________
>> >> mapserver-users mailing list
>> >> mapserver-users at lists.osgeo.org
>> >> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>> >> 
>> >> 
>> > 
>> > --
>> > View this message in context:
>> > 
>> http://n2.nabble.com/turning-on-layers-at-a-particular-zoom-level-tp35
>> > 34156p3540787.html Sent from the Mapserver - User mailing 
>> list archive 
>> > at Nabble.com.
>> > _______________________________________________
>> > mapserver-users mailing list
>> > mapserver-users at lists.osgeo.org
>> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
>> > _______________________________________________
>> > mapserver-users mailing list
>> > mapserver-users at lists.osgeo.org
>> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
>> > 
>> > 
>> 
>> --
>> View this message in context: 
>> http://n2.nabble.com/turning-on-layers-at-a-particular-zoom-le
>> vel-tp3534156p3566414.html
>> Sent from the Mapserver - User mailing list archive at Nabble.com.
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>> 
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> 
> 

-- 
View this message in context: http://n2.nabble.com/turning-on-layers-at-a-particular-zoom-level-tp3534156p3566575.html
Sent from the Mapserver - User mailing list archive at Nabble.com.


More information about the mapserver-users mailing list