[OpenLayers-Users] Re: Limit features returned by hover event on Vector Layer?

Planet)x andrew.stewart at reddeer.ca
Thu Mar 3 14:46:15 EST 2011


Ok nevermind I looked at the example you suggested and a previous forum post
and got it working, here is my code that works -

  //Add Vector Layers to Map
       map.addLayer(hydrants);
       
       //Select Control (Hotspot)
       var selectCtrl = new OpenLayers.Control.SelectFeature(hydrants,
{toggle:true,clickout:true});
       
        hydrants.events.on({ "featureselected": onHydrantSelect});

       //Hover Control (Tooltip)
       var hoverCtrl = new OpenLayers.Control.SelectFeature(hydrants, { 
           hover: true, highlightOnly: true, renderIntent: "temporary",
           eventListeners: { featurehighlighted: showTooltip} 
           });

        map.addControl(hoverCtrl);
        map.addControl(selectCtrl);
        hoverCtrl.activate();
        selectCtrl.activate();

        //support functions
        var lastFeature = null;
        var tooltipPopup = null;

        function showTooltip(event){
        var feature = event.feature;
        
        //Display Tooltip
        tooltip.destroy();
	    tooltip = new Ext.ToolTip({
        html: 'Hydrant' + '
' +  'wt' + feature.attributes.ATS_Desc + '-' +
feature.attributes.trig_Label_INF_Hydrant + '
' + '(' + feature.attributes.Year_Install + ')',
        dismissDelay: 3000
        });
        tooltip.targetXY = [(x_pos + -50),(y_pos - 70)];
        tooltip.show(); 
        }
 

    function onHydrantSelect(event) {
    var feature = event.feature;
    alert(feature.attributes.Year_Install);
    }
   
Once again, thanks!

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Limit-features-returned-by-hover-event-on-Vector-Layer-tp6085625p6086125.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list