[OpenLayers-Users] Re: Hover + Popup FAILURE
    shitake83 
    shitake83 at googlemail.com
       
    Wed Mar  2 06:50:18 EST 2011
    
    
  
I have managed to change my script in a way that when i hover the feature,
the hover gets accepted,the popup pops up and if i leave the feature the
popup closes.
so far the only thing im in need of now is a way to stop the popup from
showing up without me having clicked the feature.
the other issue im facing is that whenever i hover in map inwards the old
feature popup wont close anymore and it stays floating where it was (i only
tested features that where close to the edge so i would only hover  one
feature).
and im not able to close the popup with the little red x if it stays on the
map.
heres some code (dont care if you find missing braces or anything i just cut
the code, its working, compiled code, im just having usage issues) :
if (lType==1 || lType==0) {
  alert("loadLayersByColour::loading:Bundeslaender");
		// create a wfs layer with the style map
		states = new OpenLayers.Layer.WFS(
				"Bundesländer",
				"http://111.111.111.111:1111/geoserver/wfs",
				{typename: "MyCard:mystuff"},
				{isBaseLayer: false, extractAttributes: true, styleMap: myStyleMapL}
		);      
		map.addLayers([states]);
    
highlightControl = new OpenLayers.Control.SelectFeature(states,
 {hover: true,
 highlighOnly: true,
 renderIntent: "myStyleMapR",
 eventListeners: {
                    beforefeaturehighlighted: report,
                    featurehighlighted: report,
                    featureunhighlighted: report
}});
var selectedControl = new OpenLayers.Control.SelectFeature(states,
                {clickout: true}
            );
//the order in which you add these lines seems to matter!
map.addControl(selectedControl);
map.addControl(highlightControl);
highlightCtrl.activate();
selectedControl.activate();
// THE DIV UPDATE PART
//this works perfect on another layer on its own		
/*
        states.events.on({"featureselected": function(evt) {
            var feature = evt.feature;
            var regscore =
getregidQ(feature.attributes["rs"].substr(0,2),1,1)
            var promptText = "Land = " + feature.attributes.gen + ", Anzahl
= " +regscore ;
            $("nodelist").innerHTML = promptText;
        }});
		 */
	};
 function onMarkerSelect(event) {
        //unselect any previous selections
        tooltipUnselect(event);
        var feature = event.feature;
        var selectedFeature = feature;
        alert("marker selected DEBUG");
        var popup = new OpenLayers.Popup.FramedCloud("activeAlarm",
                    feature.geometry.getBounds().getCenterLonLat(),
                    new OpenLayers.Size(100,100),
                    "Loading...",
                    null, true, onMarkerPopupClose );
        feature.popup = popup;
        popup.setOpacity(0.7);
        map.addPopup(popup);
        //call ajax to get the data
        loadDetails(feature.attributes.description);
    }
    function onMarkerUnselect(event) {
        var feature = event.feature;
        if(feature.popup) {
        alert("marker unselected DEBUG");
            map.removePopup(feature.popup);
            feature.popup.destroy();
            delete feature.popup;
        }
    }
    function onMarkerPopupClose(evt) {
        select.unselectAll();
    }
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Hover-Popup-FAILURE-tp6080261p6080528.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
    
    
More information about the Users
mailing list