2

我将 Leaflet 1.0.1 与 LeafLet Draw 一起使用,但问题是无法使用 LeafLet 稳定版本单击标记层

https://jsfiddle.net/tb0pct68/2/

var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
            osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
            osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib});


        map = new L.Map('map', {center: new L.LatLng(51.505, -0.04), zoom: 13}),
        drawnItems = L.featureGroup().addTo(map);



        L.control.layers({
         //'osm':osm.addTo(map),
         "google": osm.addTo(map),
        }, {/*'drawlayer':drawnItems*/}, { position: 'topleft', collapsed: false }).addTo(map);
        map.addControl(new L.Control.Draw({
            edit: {
                featureGroup: drawnItems,
                poly : {
                    allowIntersection : false
                }
            },
            draw: {
                polygon : {
                    allowIntersection: false,
                    showArea:true
                }
            }
        }));

   function layerClick(e) {

            alert('yes its clicked');
        }

        map.on('draw:created', function(event) {
            var layer = event.layer;

      layer.on('click',layerClick);

            drawnItems.addLayer(layer);
        });

画一个矩形,它会显示警报 Dailog 但标记层单击不起作用,不知道是什么问题。

谢谢

4

1 回答 1

3

根据Github 上的这个公开问题,传单绘制插件仅支持传单 0.7.x。不过,修复它只是时间问题(我希望!)。

于 2016-10-05T16:08:12.283 回答