我使用传单+传单指令,昨晚我注意到,如果我向左或向右平移太远,它会创建一个新的地图实例,但不包含我的geojson标记。 / p>
这是一个已知问题还是我错过了配置我的代码? (无法在网上找到任何问题)
这个很难解释所以我制作了一张专辑:
有谁知道为什么会发生这种情况和/或如何修复它?
此处还值得注意的是,如果我进一步向左平移,并输入"实例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());
});
}
} ]);
答案 0 :(得分:1)
默认情况下,worldCopyJump
设置为false
。将其设置为true
时,应平移地图时移动标记。
请参阅:https://github.com/tombatossals/angular-leaflet-directive/blob/master/doc/defaults-attribute.md和