我在 ui 传单插件中遇到了圆形标记的问题。当有人单击一个圆圈时,我会弹出弹出窗口,但是如果我在地图中的圆圈之外单击,然后尝试再次单击圆圈,则不会出现弹出窗口。
你能建议可能是什么问题吗?有什么解决方法吗?
重现步骤
- 在地图中单击一个圆圈标记
- 将圆圈标记移出地图范围
- 然后尝试单击不会出现弹出窗口的任何其他标记
- 如果我在圆圈外单击并再次单击圆圈,则会再次出现弹出窗口
以下是代码片段,如果您需要完整代码,请访问此 github 链接
https://github.com/Umamaheswaran1990/learningleaflet
HTML
<!DOCTYPE html>
<html ng-app="demoapp">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../bower_components/angular/angular.min.js"></script>
<script src="../bower_components/leaflet/dist/leaflet.js"></script>
<script src="../bower_components/angular-simple-logger/dist/angular-simple-logger.js"></script>
<script src="../bower_components/ui-leaflet/dist/ui-leaflet.min.js"></script>
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
<script src="app.js"></script>
</head>
<body ng-controller="LayersSimpleController as vm">
<leaflet center="center" tiles="tiles" paths="paths" width="50%" height="480px"></leaflet>
</body>
</html>
JS
var app = angular.module("demoapp", ['ui-leaflet']);
app.controller("LayersSimpleController", ["$scope", function ($scope) {
var vm = this;
$scope.$on('leafletDirectiveMap.map.load', function (event, data) {
var map = data.leafletObject;
map.attributionControl.setPrefix(false);
});
$scope.$on('leafletDirectiveMap.moveend', function (event, data) {
activate();
});
var map = [
{ "lat": 30.7559, "lon": -96.489 },
{ "lat": 41.8887, "lon": -111.769 }];
angular.extend($scope, {
center: {
lat: 39.774769,
lng: -98.789062,
zoom: 4,
minZoom: 4,
zoomControl: true,
},
events: {},
tiles: {
url: 'http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
options: {
subdomains: ['otile1', 'otile2', 'otile3', 'otile4']
},
layers: {},
defaults: {
}
}
});
activate();
function activate() {
$scope.paths = {};
angular.forEach(map, function (value, key) {
if (value.lat !== null && value.lon !== null) {
$scope.paths['circle' + key] = {
type: 'circleMarker',
className: 'testClass',
fillColor: 'DarkSlateGray',
color: '#000000',
weight: 0,
opacity: 1,
message: 'This is a test marker',
fillOpacity: 0.8,
stroke: false,
clickable: true,
latlngs: [parseFloat(value.lat), parseFloat(value.lon)],
radius: 20
};
}
});
}
}]);