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 am using the following code and wanted to know how I can change it from click event to hover or mousemove event. I know there is a eventListner but I am unable to locate the click event where I must change it to mousemove event.

info = new OpenLayers.Control.WMSGetFeatureInfo({
            url: 'http://localhost:8080/geoserver/iPlant/wms', 
            title: 'Identify features by clicking',
            queryVisible: true,
            eventListeners: {
                getfeatureinfo: function(event) {
                    map.addPopup(new OpenLayers.Popup.FramedCloud(
                        "chicken", 
                        map.getLonLatFromPixel(event.xy),
                        null,
                        event.text,
                        null,
                        true
                    ));
                }
            }
        });
        map.addControl(info);
        info.activate();

Update 2.0

I made the changes and also added the PopUp, but only the click function is being recognized.

info = {
            click: new OpenLayers.Control.WMSGetFeatureInfo({
            url : 'http://niles.iplantcollaborative.org:8080/geoserver/wms',
            title : 'Identify features by clicking',
            queryVisible : true,
            eventListeners : {
            getfeatureinfo : function(event) {
            deletePopUp();
            popup = new OpenLayers.Popup.FramedCloud("popInfo", map.getLonLatFromPixel(event.xy), null, event.text, null, true);
            map.addPopup(popup);}}
            }),
            hover: new OpenLayers.Control.WMSGetFeatureInfo({
            url : 'http://niles.iplantcollaborative.org:8080/geoserver/wms',
            title : 'Identify features by clicking',
            queryVisible : true,
                    hover : true,
            eventListeners : {
            getfeatureinfo : function(event) {
            deletePopUp();
            popup = new OpenLayers.Popup.FramedCloud("popInfo", map.getLonLatFromPixel(event.xy), null, event.text, null, true);
            map.addPopup(popup);
            }}
            })
            };
            map.addControl(info.hover);
            info.hover.activate();
share|improve this question
    
Oh got it just needed to add hover : true –  Sam007 Jun 6 '12 at 17:56
add comment

1 Answer 1

up vote 2 down vote accepted

you can add your code in object and then call whatever you want as following code.. actually OpenLayers.Control.WMSGetFeatureInfo has hover properties which enough for to solve your problem.

       info = {
        click: new OpenLayers.Control.WMSGetFeatureInfo({
            url: 'http://demo.opengeo.org/geoserver/wms', 
            title: 'Identify features by clicking',
            layers: [layer],
            queryVisible: true
        }),
        hover: new OpenLayers.Control.WMSGetFeatureInfo({
            url: 'http://demo.opengeo.org/geoserver/wms', 
            title: 'Identify features by clicking',
            layers: [layer],
            hover: true,                
            formatOptions: {
                typeName: 'water_bodies', 
                featureNS: 'http://www.openplans.org/topp'
            },
            queryVisible: true
        })
    };
     map.addControl(info.hover);
     info.hover.activate();

hover

{Boolean} Send GetFeatureInfo requests when mouse stops moving. Default is false.

i hope it helps you..

share|improve this answer
    
I updated the code, not able to created a PopUp on hover but on click –  Sam007 Jun 5 '12 at 20:49
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.