[mapserver-users] add symbol to search result
Emerson, Gabe
gemerson at WelshCo.com
Tue Dec 30 07:51:25 PST 2008
Attila:
If you're using the CGI version of Mapserver, you can insert a point via the URL to represent your search result. Check http://mapserver.osgeo.org/cgi/controls.html?highlight=map_layer (scroll down to "Changing map file parameters via a form or URL)
I use dummy layers in my mapfile that defines what the result will look like (such as an arrow, pushpin, house, etc), and how it's labeled (city name, etc).
For example, this layer defines a simple labeled arrow:
LAYER
NAME "pushpin"
STATUS off #layer must be specified ON or DEFAULT in URL for it to be drawn
TYPE point
UNITS dd
PROJECTION
"init=epsg:4326"
END
TRANSPARENCY ALPHA
#Features get inserted from URL
CLASS
NAME "Search Result" #For map legend
LABEL #Label TEXT gets inserted via URL
FONT "arial"
TYPE TRUETYPE
POSITION ur #label positioned above and to the right of pin symbol
SIZE 10
WRAP "%" #newline when % encountered in string
BUFFER 1
COLOR 0 0 0
BACKGROUNDCOLOR 255 255 255
FORCE TRUE
END
STYLE
SYMBOL "arrow" #Defined in symbolfile
COLOR 0 0 0
SIZE 75
END
END
END
The features are inserted when the CGI is called, by adding them to the URL (or through the equivalent form value). For instance, when I run an address search, I want to plot the XY coordinates of the result, along with some info about the address. In my case, I'm using two form variables in my template that reference "map_layer_pushpin", as described in the Mapserver documentation. Since they're going from a form to the URL, they need to be escaped as "<input type="hidden" name="map_layer[pushpin]" value="">
Then when I get the search result, I have a script which sets the form value:
document.form[4].value="FEATURE POINTS "+geores+" END TEXT '"+gstreet+"%"+gcity+", "+gstate+" "+gzip+"' END";
And this makes the layer visible by calling another copy of map_layer_pushpin (you can probably just include this in the first reference to the layer, I wanted to keep track of the result and it's STATUS separately from one state to the next).
document.eform[5].value="STATUS default";
When the form is submitted, Mapserver inserts the feature points, label text, and status values into the appropriate parts of the dummy layer, and draws a labeled symbol on the map at the point set in my "geores" variable. You can define your own vector symbol in the symbolfile, or reference it to a raster image.
Hope that helps.
-Gabe
-----Original Message-----
From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Borbás Attila
Sent: Monday, December 29, 2008 5:05 AM
To: mapserver-users at lists.osgeo.org
Subject: [mapserver-users] add symbol to search result
Hello,
I want to add a symbol to my search result. I have a mysql table with
city names and coordinates. If I search the map zoom onto city and I
want to add a symbol that shows the search result. How can i do this?
Thanx for answers.
Attila
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
More information about the MapServer-users
mailing list