1
我的問題很簡單 - 我使用Dojo(但不是Dojox openlayers模塊)創建一個映射項目。我已經關注網絡上的例子,爲元數據和集羣創建一些懸停氣泡。我目前正試圖繪製一組由傳感器記錄的100多個觀測值(從不移動,因此每個觀測值都有相同的經度/緯度)。選擇對象時,觸發的事件不包含feature.cluster對象。在任何縮放級別,只有頂級功能出現,我無法訪問任何其他數據。我究竟做錯了什麼?OpenLayers聚類 - 聚類數據不會出現在event.feature對象中
drawObservations: function(data){
console.info("drawing observatoins", data);
if (this.observationLayer !== null){
this.map.removeLayer(this.observationLayer);
}
console.info("building features");
var features = [];
for (var i in data.observations){
//console.info("working on observation: ", data.observations[i]);
var point = new OpenLayers.Geometry.Point(data.observations[i].longitude, data.observations[i].latitude);
//console.info("point: ", point);
features[i] = new OpenLayers.Feature.Vector(point, {
id : data.observations[i].id,
startTime: data.observations[i].startTime,
endTime: data.observations[i].endTime
}, {
fillColor : '#008040',
fillOpacity : 0.8,
strokeColor : "#ee9900",
strokeOpacity : 1,
strokeWidth : 1,
pointRadius : 8
});
}
console.info("features size: ", features.length);
console.info("building vectors");
this.observationLayer = new OpenLayers.Layer.Vector("Observations", {
projection: "EPSG:4326",
strategies: [
new OpenLayers.Strategy.Cluster()
],
eventListeners:{
'featureselected':function(evt){
console.info("feature selected: ", evt);
console.info("this: ", this);
var feature = evt.feature;
var popup = new OpenLayers.Popup.FramedCloud("popup",
OpenLayers.LonLat.fromString(feature.geometry.toShortString()),
null,
"<div style='font-size:.8em'><h3>Observation - " + feature.attributes.id + "</h3><hr/><b>Start Time: </b>" + feature.attributes.startTime + "<br/><b>End Time: </b>" + feature.attributes.endTime + "</div>",
null,
true
);
feature.popup = popup;
this.map.addPopup(popup);
},
'featureunselected':function(evt){
console.info("feature unselected: ", evt);
var feature = evt.feature;
this.map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
}
}
});
console.info("adding features to vector", this.observationLayer);
this.observationLayer.addFeatures(features);
this.map.addLayer(this.observationLayer);
var selector = new OpenLayers.Control.SelectFeature(this.observationLayer,{
hover:true,
autoActivate:true
});
this.observationLayer.events.on({
"featureselected": this.display
});
this.map.addControl(selector);
},
display: function(event){
console.info("event: ", event);
}