0
我使用小冊子+小冊子指令,並且我昨天晚上注意到,如果我平移太遠到左側或右側,它會創建一個不包含我的geojson標記的地圖的新實例。小冊子平移清除所有標記
這是一個已知的問題還是我錯過配置我的代碼? (找不到任何聯機問題)
這一個是有點難以解釋,所以我做了張專輯:
有誰知道爲什麼發生這種情況和/或如何解決它?
此外值得注意的是,如果我進一步向左平移,並輸入「實例3,4或5」(等等......),我將無法看到我的標記,直到我回到「實例1" 。
這裏是我的有關HTML &控制器代碼:
<div class="main" ng-controller="GeoJSONCenterController">
<div class="container-fluid" id="map-canvas">
<leaflet markers="markers" center="mapCenter" defaults="defaults" geojson="geojson"></leaflet>
</div>
</div>
控制器代碼:
app.controller("GeoJSONCenterController", [ '$scope', '$http', '$filter', 'leafletData', 'iconService', function($scope, $http, $filter, leafletData, iconService) {
$scope.mapCenter = {
lat: 41.152194,
lng: 6.855469,
zoom: 3,
};
$scope.defaults = {
attribution: "",
minZoom: 3,
maxZoom: 18
};
$scope.icons = iconService.local_icons;
// Get the geojson data from the USGS
$http.get("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.geojson").success(function(data, status) {
addGeoJsonLayerWithClustering(data);
});
function addGeoJsonLayerWithClustering(data) {
var markers = L.markerClusterGroup();
var geoJsonLayer = L.geoJson(data, {
pointToLayer: function(feature, latlng) {
marker = new L.marker(latlng, {icon: L.icon($scope.icons.quake_icon)});
return marker;
},
onEachFeature: function (feature, layer) {
var date = $filter('date')(feature.properties.time, "short");
var popupContent = "<p><span class=" + "event-type" + ">" + feature.properties.type + ":</span> " + "<a href=" + feature.properties.url + " target=" + "_blank" + ">" + feature.properties.title + "</a>" + "<br><span class=" + "event-time" + "> Time: </span>" + date + "</span> " + "</p>";
layer.bindPopup(popupContent);
}
});
markers.addLayer(geoJsonLayer);
leafletData.getMap().then(function(map) {
map.addLayer(markers);
//map.fitBounds(markers.getBounds());
});
}
} ]);