Legend, Layers, and Scale

Paul Spencer pagameba at MAGMA.CA
Thu Oct 28 17:16:28 PDT 2004


Jennifer ... answers inline ...

Jennifer Zeisloft wrote:
> Hello All...
>
> I am a very new user of MapServer, Chameleon, etc. and I have a few
> questions I have not yet been able to answer with the documentation
> and archives.  I would really appreciate any help that you offer.
>
> First, I have a couple layers in my map that I do not want to show in
> the legend, or that I would like in the legend, but without the option
> to turn them off.  I am using a legend template, a legend object in
> the map file, and a chameleon template.  I have been able to figure
> out how to place permanent checks in the layer on/off checkbox (or get
> rid of it entirely), how to get rid of the select layer radio buttons,
> and how to delete layers from the legend without deleting them from
> the map.  However, as soon as the map refreshes, the layers not in the
> legend or those without a layer on/off checkbox also disappear from
> the map.  If the layer on/off check is removed from a layer that I
> wish to be on permanently and the map is refreshed, the check remains
> in the box, but the layer still disappears.  I've attached the legend
> template and map file to this email.  The chameleon template I am
> using is essentially the "sample_enhanced" template that comes with
> the tutorial (it doesn't seem to me that altering anything in this
> would help with my legend problems).

you can do this by outputting

<input type="hidden" name="legendlayername[]" value="[leg_layer_name]">

instead of the checkbox.  PHP will add this layer's name to the array of
layer names that it 'thinks' were checked in the interface and all will
proceed according to plan, we hope :)

>
> Second, the names of the classes in my legend appear in a different
> font and size than those of the layers.  Adding classes also changes
> the alignment of the layer names.  I was able to change the font and
> size of the class names, but not of the layer names.  I also attempted
> to change the alignment in Dreamweaver, but this didn't seem to
> accomplish anything.  I searched for a style sheet, but I have been
> able to determine where the font and alignment are defined for the
> various legend components.

there is a <span class="label"> around the legend layer names.  You can
change "label" to some other name (say myLabel) and then declare a style
for it:

<style>
.myLabel {
     font-family: arial;
     font-weight: bold;
     font-size: 12px;
     /* etc, etc */
}
</style>

Chameleon automatically adds some stylesheets to the template for its
own built in styling.  You can usually replace these styles with your
own, especially when you control the html as is the case with the legend
template.

>
> Third, and finally… I would like the map to initially appear zoomed in
> to a certain area.  Basically, I want to keep the entire extent
> available, but when it first loads, I would like it panned and zoomed
> to a specific location.  I've played with EXTENT and SCALE, but
> without the desired results.  Is it possible to do this somehow?

set the initial extents in the map file to be the extents you want to be
shown initially.  Next, add your full extents to the metadata of the web
object as follows:

MAP

   # ...

   WEB
       METADATA
         "original_projection"  "init=epsg:42101"
         "original_extents"     "-2594561,-2312631,3467361,2240000"
       END
   END

   # ...
END

projection is not necessary unless the projection of the original
extents is different from the starting projection.  NOTE the extents are
comma separated, unlike the MAP EXTENTS which are space separated.

Normally, Chameleon initializes this metadata when the map is first
loaded.  However, if this metadata is already set, then it will not set
it.  These are the extents that are then used by the ZoomFullExtents widget.

Cheers,

Paul

>
> Again, I really appreciate any help or hints that are offered.  Thanks
> in advance.
>
> Jennifer Zeisloft
>
>
> ------------------------------------------------------------------------
>
> [leg_layer_html order=ascending opt_flag=15]
> [if name=show oper=eq value=1]
>   <tr bgcolor="#ffffff">
>   [if name=radio oper=eq value=1]
>     <td><input type="radio" name="my_legend" onclick="CWCSelectLayer('[leg_layer_name]', true)"[if name=selected value=1] CHECKED[/if] ></td>
>   [/if] [if name=check oper=eq value=1]
>     <td align="center" width=20><input type="checkbox" name="legendlayername[]"
> value="[leg_layer_name]"
>         [if name=alwayson oper=eq value=1]CHECKED[/if]
>     [if name=layer_status oper=eq  value=1]CHECKED[/if]
>     [if name=layer_status oper=eq value=2]CHECKED[/if]></td>
>     <td><img src="[leg_icon width=20 height=18]" width="20" height="20"</td>
>         [/if]
>     [if name=wms_name oper=isnull]
>     <td><a href="#" onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span class="label">[leg_layer_name]</span></a></td>
>   </tr>
>     [/if]
>     [if name=wms_name oper=isset]
>     <td><a href="#" onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span class="label">[metadata name=WMS_TITLE]</span></a></td>
>   </tr>
>     [/if]
>         [/if]
> [/leg_layer_html]
> [leg_class_html opt_flag=15]
> [if name=classes oper=eq value=1]
> <tr>
> <td width=15></td>
> <td><img src="[leg_icon width=20 height=10]" width=20 height=10></td>
> <td>[leg_class_name]</td>
> </tr>
> [/if]
> [/leg_class_html]
>
>
>

--
  -----------------------------------------------------------------
|Paul Spencer                           pspencer at dmsolutions.ca   |
|-----------------------------------------------------------------|
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
  -----------------------------------------------------------------



More information about the MapServer-users mailing list