LeafLet Draw,Marker Layer无法点击

时间:2016-10-05 14:52:27

标签: javascript maps leaflet leaflet.draw

我正在使用Leaflet 1.0.1和LeafLet Draw,但问题是无法用LeafLet稳定版本点击Marker Layer

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,但Marker图层点击不起作用,不确定是什么问题。

由于

1 个答案:

答案 0 :(得分:3)

根据这个open issue on Github,传单绘制插件仅支持小册子0.7.x.它被修复只是时间问题(我希望!)。