Hallo,
ich lade via GeoJSON 2 unterschiedliche Arten von Markern.
Leider wird aber nur beim zuletzt geladenen Marker das selectControl (“map.addControl(selectControlHaltestellen);”) geladen.
D.h. beim zuletzt geladenen Marker funktioniert bsp. das Mouseover, während die erst ausgegebenen Marker nur angezeigt werden.
Gibt es eine Möglichkeit, beide selectControl zu laden, bzw zu aktivieren?
standort = new OpenLayers.Layer.Vector
(
'Standort',
{
displayInLayerSwitcher: false,
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: 'standort-osm.php',
params: {bbox: bbox.toBBOX()},
format: new OpenLayers.Format.GeoJSON()}),
eventListeners:
{
'loadend': function() {reload = setTimeout('aktualisierung()', 10000);},
'moveend': function() {if (standort){standort.protocol.params.bbox = map.getExtent().transform(map.getProjectionObject(), new OpenLayers.Projection('EPSG:4326')).toBBOX();}}
},
styleMap: new OpenLayers.StyleMap
({
'default': new OpenLayers.Style
({
externalGraphic: '${icon}.png',
graphicWidth: 26,
graphicHeight: 26
}),
'select': new OpenLayers.Style
({
backgroundGraphic: 'bg.png',
backgroundHeight: 20,
backgroundWidth: '${getBackgroundWidth}',
backgroundYOffset: 15,
label: '${ziel}',
labelYOffset: -30,
labelAlign: 'cb',
fontFamily: 'Arial',
fontSize: 15,
cursor: 'pointer'
},{
context:
{
getBackgroundWidth: function(feature)
{
String.prototype.visualLength = function()
{
var sizer = document.getElementById("sizer");
sizer.innerHTML = this;
return sizer.offsetWidth;
}
var s = feature.attributes.ziel + 10;
return(s.visualLength());
}
}
})
})
}
);
map.addLayer(standort);
var selectControlStandort = new OpenLayers.Control.SelectFeature(standort, {hover: true});
map.addControl(selectControlStandort);
selectControlStandort.activate();
haltestellen = new OpenLayers.Layer.Vector
(
'Haltestellen',
{
displayInLayerSwitcher: false,
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: 'haltestellen-osm.php',
params: {bbox: map.getExtent().transform(new OpenLayers.Projection('EPSG:4326'), map.getProjectionObject()).toBBOX()},
format: new OpenLayers.Format.GeoJSON()}),
eventListeners:
{
'moveend': function() {if (haltestellen){haltestellen.protocol.params.bbox = map.getExtent().transform(map.getProjectionObject(), new OpenLayers.Projection('EPSG:4326')).toBBOX(); haltestellen.refresh();}}
},
styleMap: new OpenLayers.StyleMap
({
'default': new OpenLayers.Style
({
externalGraphic: 'bhs14.png',
graphicWidth: '${iconSize}',
graphicHeight: '${iconSize}'
}),
'select': new OpenLayers.Style
({
backgroundGraphic: 'bg.png',
backgroundHeight: 20,
backgroundWidth: '${getBackgroundWidth}',
backgroundYOffset: 15,
label: '${title}',
labelYOffset: -30,
labelAlign: 'cb',
fontFamily: 'Arial',
fontSize: 15,
cursor: 'pointer'
},{
context:
{
getBackgroundWidth: function(feature)
{
String.prototype.visualLength = function()
{
var sizer = document.getElementById("sizer");
sizer.innerHTML = this;
return sizer.offsetWidth;
}
var s = feature.attributes.title + 10;
return(s.visualLength());
}
}
})
})
}
);
map.addLayer(haltestellen);
selectControlHaltestellen = new OpenLayers.Control.SelectFeature(haltestellen, {hover: true});
map.addControl(selectControlHaltestellen);
selectControlHaltestellen.activate();
Gruß Wayne