Please help me to understand,
I want to build an html page with an interactive map (don't we all). So I have some shapes with geometries and data attached to them. I am serving them as wms. Now I'd like to use that data for forming an html request when clicking the geometry. I just can't figure out how to get some useful out of that. I tried to use OpelLayers's getFullRequestString in order to get the GetFeatureInfo out of the shape. It works but I only can get preformatted text or html which can be embed into web page as a neat table. Or I get gml with which I don't know what to do.
Are there any examples how to utilize GetFeatureInfo or other similar like requests?
mika
Lehtonen, Mika ha scritto:
Please help me to understand,
I want to build an html page with an interactive map (don't we all). So I have some shapes with geometries and data attached to them. I am serving them as wms. Now I'd like to use that data for forming an html request when clicking the geometry. I just can't figure out how to get some useful out of that. I tried to use OpelLayers's getFullRequestString in order to get the GetFeatureInfo out of the shape. It works but I only can get preformatted text or html which can be embed into web page as a neat table. Or I get gml with which I don't know what to do.
Are there any examples how to utilize GetFeatureInfo or other similar like requests?
GetFeatureInfo does just that for the moment, html, txt or GML.
What were you looking for? JSON?
We have a jira for that already, but no one has worked on it
(feel free to post a patch):
http://jira.codehaus.org/browse/GEOS-1294
Anyways, you know you can customize the GetFeatureInfo HTML output
using Freemarker templates?
http://geoserver.org/display/GEOSDOC/GetFeatureInfo+templates
http://geoserver.org/display/GEOSDOC/Freemarker+templates
Cheers
Andrea
Hi Mika,
On Fri, 2008-04-11 at 09:35 +0300, Lehtonen, Mika wrote:
Are there any examples how to utilize GetFeatureInfo or other similar
like requests?
The solution to your problem might be closer than you think: [1].
GeoServer provides an out of the box example how to use GetFeatureInfo.
Just go to your geoserver installation, click 'Demo', then 'Map Preview'
and choose 'topp:states' (OpenLayers) for example.
When you click on any of the states, you'll get the feature info you
need.
Regards, Roald
[1]
http://localhost:8080/geoserver/wms?bbox=-127.61950064999999,23.7351786,-64.08177035,50.592523400000005&styles=&Format=application/openlayers&request=GetMap&layers=topp:states&width=800&height=317&srs=EPSG:4326
--
Roald de Wit
Software Engineer
roald.dewit@anonymised.com
Commercial Support for Open Source GIS Software
http://lisasoft.com/LISAsoft/SupportedProducts/
Hi Roald,
I already knew that. The question was how to get something else out of it than those preformatted tables e.g. how to get variables out of it and use them for creating something new related to the object you clicked. I got answer for that. You can modify your Freemarker templates and put them, if I recall right, in three different places. Like I created my own content.ftl and put it into featureType directory. Now when I click a certain region, a new html page related to that region, is embeded into current page. So the outcome is the map and sort of a description of the chosen region.
Related to this application, some new questions came up. If I have a map (html page), which has regions (wms from shp or postgis), is there any straightforward way of changing the style of the chosen region. I mean if 'map.event.register(click ....' is triggered, how could I simply change the color of the chosen region?
regards,
mika
Roald de Wit kirjoitti:
Hi Mika,
On Fri, 2008-04-11 at 09:35 +0300, Lehtonen, Mika wrote:
Are there any examples how to utilize GetFeatureInfo or other similar like requests?
The solution to your problem might be closer than you think: [1].
GeoServer provides an out of the box example how to use GetFeatureInfo.
Just go to your geoserver installation, click 'Demo', then 'Map Preview'
and choose 'topp:states' (OpenLayers) for example.
When you click on any of the states, you'll get the feature info you
need.
Regards, Roald
[1]
http://localhost:8080/geoserver/wms?bbox=-127.61950064999999,23.7351786,-64.08177035,50.592523400000005&styles=&Format=application/openlayers&request=GetMap&layers=topp:states&width=800&height=317&srs=EPSG:4326
Lehtonen, Mika ha scritto:
Hi Roald,
I already knew that. The question was how to get something else out of it than those preformatted tables e.g. how to get variables out of it and use them for creating something new related to the object you clicked. I got answer for that. You can modify your Freemarker templates and put them, if I recall right, in three different places. Like I created my own content.ftl and put it into featureType directory. Now when I click a certain region, a new html page related to that region, is embeded into current page. So the outcome is the map and sort of a description of the chosen region.
So did you solve your problem or not? If you still need to get only
the attributes in a parsable way, you could enable WFS and use a GetFeature request, that supports the JSON output that a javascript
client can easily parse into a javascript object.
Related to this application, some new questions came up. If I have a map (html page), which has regions (wms from shp or postgis), is there any straightforward way of changing the style of the chosen region. I mean if 'map.event.register(click ....' is triggered, how could I simply change the color of the chosen region?
I'd suggest you ask for the layer twice, use a different style for the
second layer, and use the GeoServer filter vendor parameters to leave
the first layer untouched while filtering the second one so that only
the selected features do show up.
Cheers
Andrea