Skip to content

No latlng properties in click event sometimes. #1613

@warrenwyf

Description

@warrenwyf

I'm not sure if it is designed as this, but for me it is not convenient.

I added some Marker features to a FeatureGroup, as well added some Polylines to it. When I click Polylines, I can get latlng properties from the click event. But if I click any Marker, the click event object is different, there is no such properties.

This is code:

        drawLayer.on('click', function(e){          
            var layer = e.layer;
            var latlng;
            if(layer && 'marker'==layer._$type){
                latlng=layer.getLatLng(); // Click marker, e.latlng is undefined
            }else if(layer && 'polyline'==layer._$type){
                latlng=e.latlng; // Click polyline
            }
        });

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions