Angularjs geojson的有角小叶标记聚类
我想在地图上显示传单MarkerCluster,问题在于从GeoJSON检索数据:Angularjs geojson的有角小叶标记聚类,angularjs,geojson,markerclusterer,angular-leaflet-directive,Angularjs,Geojson,Markerclusterer,Angular Leaflet Directive,我想在地图上显示传单MarkerCluster,问题在于从GeoJSON检索数据: { "type": "FeatureCollection", "features": [ { "type": "Feature", "id": "sto", "properties": { "name": "Stoke" },
{
"type": "FeatureCollection",
"features":
[
{
"type": "Feature",
"id": "sto",
"properties": {
"name": "Stoke"
},
"geometry": {
"type": "Point",
"coordinates": [
-0.0731,
51.5615
]
}
},
{
"type": "Feature",
"id": "dal",
"properties": {
"name": "Dalston"
},
"geometry": {
"type": "Point",
"coordinates": [
-0.070,
51.545
]
}
},
{
"type": "Feature",
"id": "wan",
"properties": {
"name": "Wandsworth"
},
"geometry": {
"type": "Point",
"coordinates": [
-0.1924,
51.4644
]
}
},
{
"type": "Feature",
"id": "batt",
"properties": {
"name": "Battersea"
},
"geometry": {
"type": "Point",
"coordinates": [
-0.1677,
51.4638
]
}
}
]
}
我试图在两个例子中再现同样的情况:
有人知道为什么第二个示例中的MarkerCluster没有显示吗?
我是否遗漏了geojson中的某些属性?您可以尝试以下内容(讨论和代码片段)
您可以尝试以下内容(讨论和代码片段)
他们在我这边都展示了同样的东西不幸的是,在开始的时候,他们在我这边展示了同样的东西不幸的是,在开始的时候,情况并非如此
// Get the countries geojson data from a JSON
$http.get("test.geojson").success(function(data, status) {
addGeoJsonLayerWithClustering(data);
function addGeoJsonLayerWithClustering(data) {
var markers = L.markerClusterGroup();
var geoJsonLayer = L.geoJson(data, {
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.Nome.value);
}
});
markers.addLayer(geoJsonLayer);
leafletData.getMap().then(function(map) {
map.addLayer(markers);
map.fitBounds(markers.getBounds());
});
}
});