首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >平移传单清除所有标记。

平移传单清除所有标记。
EN

Stack Overflow用户
提问于 2017-05-06 17:55:57
回答 1查看 193关注 0票数 0

我正在使用传单+传单指令,昨晚我注意到,如果我向左或向右移动太远,它会创建一个新的地图实例,它不包含我的geojson标记。

这是已知的问题还是我错过了配置我的代码?(在网上找不到任何问题)

这张专辑很难解释,所以我制作了一张专辑:

http://imgur.com/a/T6Kfc

有人知道为什么会发生这种情况和/或如何解决吗?

这里还值得注意的是,如果我向左移动,并输入“实例3、4或5”(等等……)我将无法看到我的标记,直到我回到“实例1”。

下面是我的相关HTML和Controller代码:

代码语言:javascript
运行
复制
<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>

控制器代码:

代码语言:javascript
运行
复制
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());
      });
  }   

} ]);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-18 23:16:02

默认情况下,worldCopyJump设置为false。将其设置为true时,应在平移地图时移动标记。

见:https://github.com/tombatossals/angular-leaflet-directive/blob/master/doc/defaults-attribute.md

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43823674

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档