[OpenLayers-Users] Clicking on a polygon-opening a page/link

Nicholas Efremov-Kendall n.e.kendall at gmail.com
Sat Jun 4 17:43:14 EDT 2011


Hi Vikash,

You could try adding the href you wanted to the attributes of the features
in your WMS layer. You could then have the href embedded in a popup. You
could modify the following code which just pulls attribute data in as text.
Don't forget to add selectedFeature, selectControl, selectedFeature as
variables before you call the function. I'm sure there's another way to
implement this, but it's beyond my skillz.

//Popups
function onPopupClose(evt) {
            selectControl.unselect(selectedFeature);
        }

function onFeatureSelect(evt) {
            selectedFeature = evt.feature;
            popup = new OpenLayers.Popup.FramedCloud("chicken",

 evt.feature.geometry.getBounds().getCenterLonLat(),
                                     null,
                                     "<div style='font-size:.8em'>Site_ID: "
+ evt.feature.attributes.SITE_ +"<hr />Locality: " +
evt.feature.attributes.location1+"<br/>Interpretation: " +
evt.feature.attributes.interp+"<br/> </div>",

                                     null, true, onPopupClose);
            evt.feature.popup = popup;
            map.addPopup(popup);
        }
  function onFeatureUnselect(evt) {
            map.removePopup(evt.feature.popup);
            evt.feature.popup.destroy();
            evt.feature.popup = null;

On Sat, Jun 4, 2011 at 4:33 PM, Vikash Talanki <vikashtalanki at gmail.com>wrote:

> Hi,
>
> 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...
>
> --
> View this message in context:
> http://osgeo-org.1803224.n2.nabble.com/Clicking-on-a-polygon-opening-a-page-link-tp6440300p6440300.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110604/8303f870/attachment.html


More information about the Users mailing list