x

Re: select und select-hover gleichzeitig auf Feature Elemente


Geschrieben von Lamce (Gast) am 28. April 2013 21:16:26: [flux]

Als Antwort auf: select und select-hover gleichzeitig auf Feature Elemente geschrieben von Lamce (Gast) am 04. April 2013 17:09:

Habe schlussendlich eine Version bei der es ohne mucken möglich ist hover und select Event auf einem Feature laufen zu lassen.

Hoffe ich kann einigen damit helfen und eine menge Zeit ersparen.

mouseoverfeature␣=␣new␣OpenLayers.Control.SelectFeature(kml,␣{
hover:true,
highlightOnly:␣false,
eventListeners:{
featurehighlighted:onFeatureOver,
featureunhighlighted:onFeatureOut
}
});
map.addControl(mouseoverfeature);
mouseoverfeature.activate();
mouseselectfeature␣=␣new␣OpenLayers.Control.SelectFeature(kml,␣{
clickout:false,
onSelect:␣onFeatureSelect
});
map.addControl(mouseselectfeature);
mouseselectfeature.activate();
function␣onFeatureOver(evt)␣{
var␣feature␣=␣evt.feature;
kml.removeFeatures(feature);
if(!feature.popup){
var␣popup␣=␣new␣OpenLayers.Popup.FramedCloud(feature.attributes.name,
feature.geometry.getBounds().getCenterLonLat(),
new␣OpenLayers.Size(100,100),
"<h2>"+feature.attributes.name␣+␣"</h2>"␣+␣feature.attributes.description,
new␣OpenLayers.Icon("bla",new␣OpenLayers.Size(18,40),new␣OpenLayers.Pixel(0,-20)),␣true
);
popup.calculateRelativePosition␣=␣function␣()␣{
return␣'tr';
}
feature.popup␣=␣popup;
map.addPopup(popup);
}
kml.addFeatures(feature);
}
function␣onFeatureOut(evt)␣{
var␣feature␣=␣evt.feature;
if(feature.popup)␣{
map.removePopup(feature.popup);
feature.popup.destroy();
delete␣feature.popup;
}
}
function␣onFeatureSelect(feature)␣{
if(feature.popup)␣{
map.removePopup(feature.popup);
feature.popup.destroy();
delete␣feature.popup;
}
//mach␣irgendwas␣bei␣klick
}