0

I am building an online map app, using Openlayers, which enables popup information by clicking on features. The info was brought by wms getfeatureinfo.

I wonder if there is a simple way to change the mouse cursor to, say, hand when the mouse hovers over the selectable feature. This is to help users identify that the features are clickable and info can be retrieved.

The attached is my current code. Thanks!

shelter_info = new OpenLayers.Control.WMSGetFeatureInfo ({
    url:"****",
    title: 'Identify evacuation centres by clicking',
    layers:[evacuation_center],
    queryVisible: true,
    hover: true,
    eventListeners:{
        getfeatureinfo: function(event){
            if (event.text.indexOf("<b>") != -1){    //only display popup when selected the WMS object.   
                var popup = new OpenLayers.Popup.FramedCloud(
                    "shelter_popup",
                    map.getLonLatFromPixel(event.xy),
                    null,
                    event.text,
                    null,
                    true,
                    null
                );
                popup.autoSize = true;
                popup.minSize = new OpenLayers.Size(180,180);
                //feature.popup = popup;
                map.addPopup(popup);                        
            }
        }                          
    }
});
sfletche
  • 47,248
  • 30
  • 103
  • 119
CathyCao
  • 11
  • 3
  • There is an OpenLayers article on custom cursors: http://trac.osgeo.org/openlayers/wiki/OpenLayersCursors Not sure it that will help you. The general idea is to concatenate the css class and event in a custom style. – John Powell May 14 '14 at 08:41
  • Thanks @JohnBarça, that article is helpful, a little bit. Now I changed cursor to pointer by styling the css for the displayClass of the WMSGetFeatureInfo control. But the cursor is set when the control is active, which starts from the initiation of the map. But I want the cursor to change when the mouse is on a selectable feature. so with the hover on for the GetFeatureInfo, when hover over a wms feature (determined by the if condition), it should change cursor. I don't know how to implement this using displayClass. – CathyCao May 15 '14 at 14:12

0 Answers0