我正在为我们的 Angular 项目使用 ui-leaflet。我们也有 Leaflet.heat 来创建热图。
问题是每当数据更新时,圆圈标记上的事件就会停止工作。
我面临的其他小问题是热图不会更新,除非我使用超时。不知道我做错了什么,任何帮助表示赞赏。
我创建了一个示例jsfiddle。http://jsfiddle.net/srs/13s1fy02/2/
heatMapData = [
[60.265625, -121.640625], [60.671875, -96.328125]
]
heatMapData_1 = [
[37.265625, -121.640625], [38.671875, -96.328125]
]
circleData = {
'features': [
{
'geometry': {
'type': 'Point',
'coordinates': [-120.9998241, 39.7471494]
},
'type': 'Feature',
'properties': {
'popupContent': 'This is popup 1'
}
}
]
};
circleData_1 = {
'features': [
{
'geometry': {
'type': 'Point',
'coordinates': [-100.9998241, 39.7471494]
},
'type': 'Feature',
'properties': {
'popupContent': 'This is popup2'
}
}
]
};
onEachFeature = function(feature, layer) {
return layer.bindPopup(feature.properties.popupContent);
};
$scope.updateData = function() {
if($scope.layers.overlays.hasOwnProperty('heat')){
delete $scope.layers.overlays['heat'];
}
$scope.geojson = {};
//setTimeout(function(){ buildMap(heatMapData_1, circleData_1) }, 300);
buildMap(heatMapData_1, circleData_1);
}
buildMap = function(heatMapData, circleData){
$scope.geojson = {
data: circleData,
onEachFeature: onEachFeature,
pointToLayer: function(feature, latlng) {
return L.circleMarker(latlng, style);
}
};
$scope.layers.overlays = {
heat: {
name: 'Heat Map',
type: 'heat',
data: heatMapData,
layerOptions: {
radius: 10,
scaleRadius: true,
maxZoom: 7,
minOpacity: .5,
max: 1,
gradient: {
.4: 'green',
.6: 'yellow',
1: 'red'
}
},
visible: true
}
};
}
buildMap(heatMapData, circleData)