Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a many polygons on my map serving through WMS from geoserver. I want to implement the task such that when the user clicks on a particular polygon , he should be directed to a html page about that polygon. Like if I click on my CSE Dept I should be directed to my cse dept home page.

Need help in achieving this...

I have followed http://lyceum.massgis.state.ma.us/wiki/doku.php?id=generate_imagemap as but when I try "http://localhost:8080/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=IITKanpur:halls&styles=iitk_halllinks&bbox=80.226,26.504,80.235,26.512&width=512&height=455&srs=EPSG:4326&format=text/html" I am not getting anything.

My iitk_halllinks sld is :

<Rule> <Name>href</Name> <PointSymbolizer><Graphic><Size>16</Size></Graphic></PointSymbolizer> <TextSymbolizer><Label><PropertyName>halls_link</PropertyName></Label></TextSymbolizer> </Rule>

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

You can install the imagemap extension and follow the the example http://docs.geoserver.org/latest/en/user/extensions/imagemap.html which allows you to request the map using text/html. This will provide the ability to click on a polygon

share|improve this answer
add comment

Use this example: http://openlayers.org/dev/examples/getfeatureinfo-popup.html

But instead of doing this:

    eventListeners: {
        getfeatureinfo: function(event) {
            map.addPopup(new OpenLayers.Popup.FramedCloud(
                "chicken", 
                map.getLonLatFromPixel(event.xy),
                null,
                event.text,
                null,
                true
            ));
        }
    }

replace the above for something like this:

eventListeners: {
    getfeatureinfo: function(event) {
        window.open("http://mydomain.com/polygoninfo.php?polygonid=" + event.feature.attributes.id, "window_name","location=1,status=1,scrollbars=1,resizable=no,width=650,height=650");
    }
}
share|improve this answer
    
this works for a single polgon, but I have multiple polygons in my layer –  Vikash Talanki Jun 4 '11 at 10:11
    
@user1795 > no, this works with one or N polygons. That's why the script is passing the id dynamically –  simo Jun 6 '11 at 12:08
    
@user: like simo said, this will work with any amount of polygons. Just pass the polygon id in the URL on the click event (event.feature.attributes.id) and your polygoninfo.php page can query that ID for all of it's information. –  CaptDragon Jun 6 '11 at 13:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.