我創建了一個非常簡單的codepen,但是在嘗試創建繪圖控件時出現錯誤。Leaflet Draw 0.4.9控制不能使用Leaflet 1.1.0?
參見:https://codepen.io/DrYSG/pen/QgmVZg
我以爲它是簡單的東西,我做錯了。但我看了看我現在用的是CDN,我什麼也看不到明顯的:
https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/0.4.9/leaflet.draw-src.js
這些都是我在控制檯中看到的錯誤:
Util.js:15 Uncaught TypeError: Cannot add property segmentsIntersect, object is not extensible
at Object.extend (Util.js:15)
at LineUtil.Intersect.js:6
at EditToolbar.Delete.js:145 extend @ Util.js:15 (anonymous) @ LineUtil.Intersect.js:6 (anonymous) @ EditToolbar.Delete.js:145 pen.js:11 Uncaught TypeError: L.Control.Draw is not a constructor
at pen.js:11
var map = L.map("root").setView([42, -71], 7);
L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution:
'© <a href="http://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors'
}).addTo(map);
var drawnItems = new L.FeatureGroup();
map.addLayer(drawnItems);
var drawControl = new L.Control.Draw({
edit: {
featureGroup: drawnItems
}
});
map.addControl(drawControl);
謝謝,我想設置此codepen以顯示測量(距離測量)的問題,但正如您可以看到這也是一個問題:https://github.com/Leaflet/Leaflet.draw/issues/735 #issuecomment-313232837 –