1
getBounds()とcontains()をCircleシェイプで実行しようとすると、以下のエラーが表示されます。Circle getBounds()とcontains()を使用するとエラーが発生する
leaflet.js:7 Uncaught TypeError: Cannot read property 'layerPointToLatLng' of undefined
他の形でも使用できますが、円は頑固です。私はこれを試しましたsolution別の質問から、しかし成功しません。
ここでは、多角形や四角形形状のために私が持っているコードです:
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>');
}
}
});
https://github.com/Leaflet/Leaflet/issues/4978を参照してください – IvanSanchez