[Mapserver-users] Changing Colors in Map !!

ANDY CANFIELD andy_canfield at hotmail.com
Mon Jul 19 09:19:44 EDT 2004


Yes, I believe there is a way to do what you want. I have a legend on the 
side of my maps that I generate on the fly by looping through the layers of 
the map and adding each layer to the legend as the loop progresses as check 
boxes with the layer name so the user can turn off or on the layers.

This allows the legend to be dynamic so no matter what the layers are in any 
map I always get a uniformly formatted legend with no code changes.

I have a cosmetic layer much like the layer you are describing that I use to 
copy for placing geocoded points on the map. The users are geocoding from 
multiple text files so I want different colored points for each file so they 
can compare the results of the files. That's why I use copies of that 
cosmetic layer so I can use it's symbols and only have to change the color.

I don't want the users to have access to these cosmetic layer copies that 
are created on the fly. So I make that the first layer and my loop through 
the layers starts at layer 1 rather than layer 0 so the first layer never 
shows up in the legend. You could do the same thing with as many cosmetic or 
contruction layers as you wanted just be sure to start your loop one beyond 
the last "invisible" layer.


>From: Stephen Woodbridge <woodbri at swoodbridge.com>
>To: Satyajit <satyajit.gantayat at aurovision.com>
>CC: Girish <girish.shewale at aurovision.com>,        MapServer List 
><mapserver-users at lists.gis.umn.edu>
>Subject: Re: [Mapserver-users] Changing Colors in Map !!
>Date: Mon, 19 Jul 2004 08:16:59 -0400
>
>You raise a good issue. I don't usually display legends, but have used HTML 
>Legend stuff that allows you a lot of control over your legends and I think 
>you can eliminate layers on a named basis. which might work for you.
>
>Please add a comment to the bug referenced below about this problem. I hope 
>that the developers will tackle this problem but it helps to have a 
>complete picture of the problem and issues and their work arounds.
>
>-Steve W
>
>Satyajit wrote:
>
>>
>>Hi Steve,
>>       Thanks a lot for the info. I have not tried your method yet but
>>shall try it very soon. And let you know the result. I have a question
>>in my mind though. When we add a dummy layer in our map and add classes
>>to it ( to preserve the colors ..as you said), the layer will be shown
>>in the legend in the browser. That dummy layer in the legend might
>>confuse the end user as that layer's features won't be easily visible in
>>the map and of course that layer doesn't have much meaning to it. Is
>>there any way by which I can add that layer in my map file with all the
>>classes but still make it invisible in the legend ? Thanks a lot again 
>>steve.
>>Shall get back to you after modifying my map file.
>>
>>~sat
>>
>>Stephen Woodbridge wrote:
>>
>>
>>>I think I may have created a feature and inserted a one pixel dot on the
>>>map that gets covers by later layers. Play with it and if you have a 
>>>problem let me know and I can dig through old mapfiles and find out
>>
>>how
>>
>>>I did it.
>>
>>
>>Here are some examples of preserving the colors in a symbol that were 
>>changing. The big problem with this approach is that it uses up a lot of
>>
>>layers, so you might try using one layer with lots of classes, but I'm not 
>>sure it that will work.
>>
>>The bug for this problem is:
>>    http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=306
>>I just updated it with this information.
>>
>>## dummy layer to protect symbol colors from changing
>>    LAYER
>>      NAME "color_symbol"
>>      STATUS DEFAULT
>>      TYPE point
>>      TRANSFORM false
>>      FEATURE
>>        POINTS
>>          1 1
>>        END
>>      END
>>      CLASS
>>        SYMBOL "color_symbol"
>>        COLOR 0 0 0
>>      END
>>    END
>>## protect other colors
>>    LAYER
>>      NAME blue
>>      STATUS DEFAULT
>>      TYPE point
>>      TRANSFORM false
>>      FEATURE
>>        POINTS
>>          1 1
>>        END
>>      END
>>      CLASS
>>        COLOR 0 0 255
>>      END
>>    END
>>    LAYER
>>      NAME green
>>      STATUS DEFAULT
>>      TYPE point
>>      TRANSFORM false
>>      FEATURE
>>        POINTS
>>          1 1
>>        END
>>      END
>>      CLASS
>>        COLOR 8 206 107
>>      END
>>    END
>>
>>
>>
>>_______________________________________________
>>Mapserver-users mailing list
>>Mapserver-users at lists.gis.umn.edu
>>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>>
>>
>>
>>
>
>_______________________________________________
>Mapserver-users mailing list
>Mapserver-users at lists.gis.umn.edu
>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/




More information about the mapserver-users mailing list