简体   繁体   中英

LeafLet Draw, Marker Layer can't be Clicked

I'm using Leaflet 1.0.1 with LeafLet Draw, but the problem is Marker Layer can't be clicked with the LeafLet stable version

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);
        });

Draw a rectangle, it will show alert Dailog but Marker layer click is not working, not sure what is the problem.

Thanks

According to this open issue on Github , the leaflet draw plugin supports only leaflet 0.7.x. It is only a matter of time before it gets fixed though (I hope!).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM