{
function tooltipSelect(event){
var feature = event.feature;
var selectedFeature = feature;
//if there is already an opened details window, don\'t draw the
tooltip
if(feature.popup != null){
return;
}
//if there are other tooltips active, destroy them
if(tooltipPopup != null){
map.removePopup(tooltipPopup);
tooltipPopup.destroy();
if(lastFeature != null){
delete lastFeature.popup;
tooltipPopup = null;
}
}
lastFeature = feature;
var tooltipPopup = new OpenLayers.Popup("activetooltip",
feature.geometry.getBounds().getCenterLonLat(),
new OpenLayers.Size(80,12),
" "+feature.attributes.name,
true );
//this is messy, but I'm not a CSS guru
tooltipPopup.contentDiv.style.backgroundColor='ffffcb';
tooltipPopup.closeDiv.style.backgroundColor='ffffcb';
tooltipPopup.contentDiv.style.overflow='hidden';
tooltipPopup.contentDiv.style.padding='3px';
tooltipPopup.contentDiv.style.margin='0';
tooltipPopup.closeOnMove = true;
tooltipPopup.autoSize = true;
feature.popup = tooltipPopup;
map.addPopup(tooltipPopup);
}
//iffunction theretooltipUnselect(event){
are other tooltips active,var destroyfeature them= event.feature;
if(tooltipPopupfeature != null && feature.popup != null){
map.removePopup(tooltipPopupfeature.popup);
tooltipPopup.destroy();
iffeature.popup.destroy(lastFeature != null){;
delete lastFeaturefeature.popup;
tooltipPopup = null;
lastFeature = null;
}
}
lastFeature = feature;
var tooltipPopup = new OpenLayers.Popup("activetooltip",
feature.geometry.getBounds().getCenterLonLat(),
new OpenLayers.Size(80,12),
" "+feature.attributes.name,
true );
//this is messy, but I'm not a CSS guru
tooltipPopup.contentDiv.style.backgroundColor='ffffcb';
tooltipPopup.closeDiv.style.backgroundColor='ffffcb';
tooltipPopup.contentDiv.style.overflow='hidden';
tooltipPopup.contentDiv.style.padding='3px';
tooltipPopup.contentDiv.style.margin='0';
tooltipPopup.closeOnMove = true;
tooltipPopup.autoSize = true;
feature.popup = tooltipPopup;
map.addPopup(tooltipPopup);
} function tooltipUnselect(event){ var feature = event.feature; if(feature != null && feature.popup != null){ map.removePopup(feature.popup); feature.popup.destroy(); delete feature.popup; tooltipPopup = null; lastFeature = null; } }
function onMarkerSelect(event) { //unselect any previous selections tooltipUnselect(event); var feature = event.feature; var selectedFeature = feature; 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) { map.removePopup(feature.popup); feature.popup.destroy(); delete feature.popup; } } function onMarkerPopupClose(evt) { select.unselectAll(); }
//lType: Region-Type
//0=Alle, 1=Land, 2=Reg.Bezirk, 3= Kreis, 4=Gemeinde
function loadLayersByColour (lType) {
// alert("in loadLaysersByColour");
// 1.) einmaliges Erstellen der Filterliste fuer WebService Request
if (listRun == false){buildFilterLists(6,0);};
// 2.) entfernen eventuell bereits vorhandener alter Layer
if (listRun != false) {removeLayer(0);};
function onMarkerSelect(event) {
//unselect 3any previous selections
tooltipUnselect(event);
var feature = event.feature;
var selectedFeature = feature;
var popup = new OpenLayers.Popup.FramedCloud("activeAlarm",
feature.geometry.getBounds().getCenterLonLat(),
aufbauen der Layer 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) {
map.removePopup(feature.popup);
feature.popup.destroy();
delete feature.popup;
}
}
function onMarkerPopupClose(evt) {
select.unselectAll();
}
// zunächst Bundesländer
if (lType==1 || lType==0) {
// create a wfs layer with the style map
states = new OpenLayers.Layer.WFS(
lType: "Bundesländer",Region-Type
"http://myServer/geoserver/wfs"0=Alle,
{typename: "myStore:layer"}1=Land,
{isBaseLayer: false2=Reg.Bezirk, extractAttributes:3= trueKreis, styleMap:4=Gemeinde myStyleMapL}
);
function loadLayersByColour map.addLayers([states]lType); {
/*
ctrlSelectFeatures = new/ OpenLayers.Control.SelectFeaturealert(
states,
"in {loadLaysersByColour");
// 1.) einmaliges Erstellen der clickout:Filterliste true,fuer toggle:WebService false,Request
multiple:if false,(listRun hover:== false,
toggleKey: "ctrlKey"){buildFilterLists(6, // ctrl key removes from selection0);};
multipleKey: "shiftKey" // shift key adds to selection
2.) entfernen eventuell bereits vorhandener alter }Layer
if (listRun != false) {removeLayer(0);};
// map3.addControl(ctrlSelectFeatures);
aufbauen der ctrlSelectFeatures.activate();Layer
var aktLayer = 1; //index ofzunächst a vectorlayerBundesländer
if map.layers[aktLayer].events.register('featureselected', lType==1 map.layers[aktLayer],|| regFeatureSelectedlType==0);
map.layers[aktLayer].events.register('featureunselected', map.layers[aktLayer], regFeatureUnselected);{
* // create a wfs layer with the style map
states = new OpenLayers.Layer.WFS(
"Bundesländer",
"http://myServer/geoserver/wfs",
{typename: "myStore:layer"},
{isBaseLayer: false, extractAttributes: true, styleMap: myStyleMapL}
);
map.addLayers([states]);
/*
if (typeof(clickCtrl) !== 'undefined' && clickCtrl != null )ctrlSelectFeatures {= new OpenLayers.Control.SelectFeature(
alert("clickCtrl defined and not null "); states,
} else {alert("clickCtrl undefined or null");}; {
*/
// map.addControl(selectL); clickout: true, toggle: false,
// map.addControl(clickCtrl); multiple: false, hover: false,
toggleKey: "ctrlKey", // map.addControl(selectCtrlClick);ctrl key removes from selection
multipleKey: "shiftKey" // selectL.activate();shift key adds to selection
// clickCtrl.activate(); }
// selectCtrlClick.activate( );
// fuer popup
//selectedControl = new OpenLayers.Controlmap.SelectFeatureaddControl(states,ctrlSelectFeatures);
// {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect} ctrlSelectFeatures.activate();
//AENDERUNG
//add the main select (for regular select)
var selectedControlaktLayer = new OpenLayers.Control.SelectFeature(states, {
toggle: true,
1; //index of clickout:a true,vectorlayer
multiple: false,
onSelect: alertmap.layers[aktLayer].events.register("hier")'featureselected',
map.layers[aktLayer], }regFeatureSelected);
states.events.on({ "featureselected": onMarkerSelect,
"featureunselected": tooltipUnselectmap.layers[aktLayer].events.register()});
'featureunselected', //"featureunselected":map.layers[aktLayer], onMarkerUnselect}regFeatureUnselected);
//add the second select for tooltips:
var highlightCtrl = new OpenLayers.Control.SelectFeature(states, {
hover: true,
highlightOnly: true,
renderIntent: "temporary",
eventListeners: { featurehighlighted: tooltipSelect,
featureunhighlighted: tooltipUnselect } });*/
/ /the*
order in which you add these lines seemsif to(typeof(clickCtrl) matter!== 'undefined' && clickCtrl != null ) {
alert("clickCtrl defined and not null ");
} else {alert("clickCtrl undefined or null");};
*/
// map.addControl(highlightCtrlselectL);
// map.addControl(selectedControlclickCtrl);
highlightCtrl // map.addControl(selectCtrlClick);
// selectL.activate();
selectedControl // clickCtrl.activate();
// selectCtrlClick.activate();
// fuer popup
//selectedControl = new OpenLayers.Control.SelectFeature(states,
// {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});
//AENDERUNG
//add the main select (for regular select)
selectedControl = new OpenLayers.Control.SelectFeature(states, {
toggle: true,
clickout: true,
multiple: false,
onSelect: alert("hier"),
});
states.events.on({ "featureselected": onMarkerSelect,
"featureunselected": tooltipUnselect()});
//"featureunselected": onMarkerUnselect});
//add the second select for tooltips:
var highlightCtrl = new OpenLayers.Control.SelectFeature(states, {
hover: true,
highlightOnly: true,
renderIntent: "temporary",
eventListeners: { featurehighlighted: tooltipSelect,
featureunhighlighted: tooltipUnselect } });
//the order in which you add these lines seems to matter!
map.addControl(highlightCtrl);
map.addControl(selectedControl);
highlightCtrl.activate();
selectedControl.activate();
};
// Globale Variable für Merken der geladenen Layertypen setzen
lStat = lType;
};
// Globale Variable"<div fürstyle='font-size:.8em'>Feature: Merken" der+ geladenenfeature.id Layertypen+"<br />Area: setzen" + feature.geometry.getArea()+"</div>",
lStatfunction onFeatureSelect(feature) {
selectedFeature = lType;feature;
popup = new OpenLayers.Popup.FramedCloud("chicken",
};
// "Feature: " + feature.id +"
Area: " + feature.geometry.getArea()+"",
function onFeatureSelect(feature) {
selectedFeature = feature;
popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
null,
"Feature: " +"
Area: " + "",
null, true, onPopupClose);
feature.popup = popup;
map.addPopup(popup);
};
function onFeatureUnselect(feature) {
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
};
function onPopupClose(evt) { selectedControl.unselect(selectedFeature); };
function regFeatureSelected() { aktPopup = create_Popup(); var objF = this.selectedFeatures[0]; var desc = objF.attributes['gen'] ? objF.attributes['gen'] : "about:blank"; $("nodelist").innerHTML = "Selektiertes Land " + ", " + desc; }
function regFeatureUnselected() { if(aktPopup) map.removePopup(aktPopup.popup);
feature.geometry.getBounds().getCenterLonLat(),
null,
"<div style='font-size:.8em'>Feature: " +"<br />Area: " + "</div>",
null, true, onPopupClose);
feature.popup = popup;
map.addPopup(popup);
};
function onFeatureUnselect(feature) {
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
};
function onPopupClose(evt) {
selectedControl.unselect(selectedFeature);
};
function regFeatureSelected()
{
aktPopup = create_Popup();
var objF = this.selectedFeatures[0];
var desc = objF.attributes['gen'] ? objF.attributes['gen'] : "about:blank";
$("nodelist").innerHTML = "Selektiertes Land " + ", " + desc;
}
function regFeatureUnselected()
{
if(aktPopup)
map.removePopup(aktPopup.popup);
document.getElementById("nodelist").innerHTML = "selected feature description";
}
}
}
}