aratcliffe / Leaflet.contextmenu

A context menu for Leaflet.
MIT License
368 stars 107 forks source link

Problem with valid GeometryCollection type #111

Closed ozgursarikamis closed 1 year ago

ozgursarikamis commented 6 years ago

I am having trouble with GeometryCollection. When I try to display this type of data on the map I get this error:

TypeError: layer.bindContextMenu is not a function

Here is my full code:

var geoJsonLayer = new L.geoJSON(parsedGeoJson, {
            style: jsonLayerStyle,
            pointToLayer: function(data, latLng) {

            },
            onEachFeature: function(feature, layer) {
                layer.bindContextMenu({
                    contextmenu: false,
                    contextmenuWidth: 240,
                    contextmenuInheritItems: false,
                    contextmenuItems: [
                        {
                            text: "<i class='fa fa-map-marker'></i> Coordinates",
                            callback: showCoordinates
                        },
                        {
                            text: "<i class='fa fa-align-center'></i> Center",
                            callback: centerMap
                        },
                        "-",
                        {
                            text: "<i class='fa fa-search-plus'></i> Zoom In",
                            callback: zoomIn
                        },
                        {
                            text: "<i class='fa fa-search-minus'></i> Zoom Out",
                            callback: zoomOut
                        },
                        {
                            text: "<i class='fa fa-times'></i> Cancel",
                            callback: function() { return; }
                        }
                    ]
                });
            }
        }).addTo(map); 

here is my data:

Thank you.