[mapserver-users] Dynamic 'OnMouseOver' Info generation vomPostGIS/Postgres
Steve Lime
Steve.Lime at dnr.state.mn.us
Fri Apr 3 07:06:09 PDT 2009
To do this you need some sort of an observer for the map and an image
map is
one way to do that. Here's an example:
http://www.dnr.state.mn.us/ice_out/index.html
In this case the data to be displayed are encoded in the image map
produced
by MapServer (I used the template mechanism). So, onMouseOver, a
function
is called to display the data object. You could just as easily wrap an
ajax call
in that function. You'd need to store a unique ID as part of your image
map
sufficient so that you can query postgres. Then the function is called
you
pass the ID and then use that to retrieve the additional data.
The image map will work when you have a relatively small number of
reasonably
spaced features AND you're interface is not particularly interactive. I
don't
think it's possible to combine an image map with your typical pan/zoom
operation.
Another solution is create a polling capability in your application and
tie it to
some sort of an event, such has pausing the mouse for a few seconds. If
that
event happens you do a spatial query to see if the user is hovering over
anything
and if so you do something. Here's an example site:
http://www.dnr.state.mn.us/waters/csg/index.html
If you hold your mouse over one of the points on the map you'll get
details about
that feature. At each pause a query is done behind the scenes and if
something
is found a popup is populated. It's kinda chatty but works. Watch the
above page
in FireBug so see the network communication. OpenLayers has a great
hover control
to do this sort of thing. You can also use click events, like so:
http://www.dnr.state.mn.us/waters/csg/index_copy.html
Creating the content to send back will depend on the data. In the above
cases I use
MapServer templates to build it. You could use your favorite scripting
language to do
so as well.
Hope this helps!
Steve
>>> Heiko Schröter <schroete at iup.physik.uni-bremen.de> 04/02/09 7:44 AM
>>>
Hello all,
we are displaying satellite measurement geolocations with Mapserver and
PostGIS/Postgres underneath.
I would like to add a feature (similar to the MapServer:ImagMap stuff)
that
displays some more info about the point on which the mouse is over
inside the
map. i.e. geolocation, name of datafile, value or so. These infos can be
sourced from the Postgres db. It is ok to just show these infos on the
bottom
window frame (like the MapServer:ImageMap example).
How do i create the html code (javascript or php or whatever needed)
with the
dynamic content piped back from the Postgres db ?
Sorry if this is an obvious question. I did read the ImageMap and
Template
stuff, but i cannot get grip to the logic when the data are coming from
a db.
Any pointer to more info or background knowledge deeply apreciated.
Thanks.
Heiko
_______________________________________________
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