问题是我在地图上只有一个弹出窗口是显示的。 我可以看到所有的点,但弹出窗口只能在列表的最后一点看到。
我从星期日开始堆积了这个问题,找不到任何可以解决我在互联网上的问题的信息:(
// create the layer
var vectorLayer = new OpenLayers.Layer.Vector("Venues");
// Define markers as "features" of the vector layer:
var feature = [];
for(var i = 0; i < 10; i++){
feature[i] = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(value.location.lng, value.location.lat).transform('EPSG:4326', 'EPSG:3857'), {
description: "Name: " + Name + "<br>Address:" + value.location.address + "<br>Likes: " + value.likes.count + "<br>Here now: " + value.hereNow.count
}, {
fillColor: '#008040',
fillOpacity: 0.8,
strokeColor: "#ee9900",
strokeOpacity: 1,
strokeWidth: 1,
pointRadius: 8
}
);
vectorLayer.addFeatures(feature);
map.addLayer(vectorLayer);
//Add a selector control to the vectorLayer with popup functions
var controls = {
selector: new OpenLayers.Control.SelectFeature(vectorLayer, {
onSelect: createPopup,
onUnselect: destroyPopup
})
};
function createPopup(feature) {
feature.popup = new OpenLayers.Popup.FramedCloud("pop",
feature.geometry.getBounds().getCenterLonLat(),
null,
'<div class="markerContent">' + feature.attributes.description + '</div>',
null,
true,
function() {
controls['selector'].unselectAll();
});
//feature.popup.closeOnMove = true;
map.addPopup(feature.popup);
}
function destroyPopup(feature) {
feature.popup.destroy();
feature.popup = null;
}
map.addControl(controls['selector']);
controls['selector'].activate();
}
答案 0 :(得分:0)
我发现当我在
中运行我的代码时