尝试使用圆形运行 getBounds() 和 contains() 时出现以下错误。
leaflet.js:7 Uncaught TypeError: Cannot read property 'layerPointToLatLng' of undefined
我可以将它与其他形状一起使用,但圆圈很顽固。我从另一个问题尝试了这个解决方案,但没有成功。
这是我对多边形和矩形形状的代码:
drawnLayers.eachLayer(function(l) {
if (type == 'circle') {
// console.log(l.getBounds().contains(layer.getBounds()));
} else {
if (l.getBounds().contains(layer.getBounds())) {
isDonut = true;
l._latlngs.push(layer.getLatLngs());
l.redraw();
$('#map-info').append("<br>New Polygon: <pre>" +
JSON.stringify(l.getLatLngs(), null, 2) + '</pre>');
}
}
});