Leaflet / Leaflet.markercluster

Marker Clustering plugin for Leaflet
MIT License
3.96k stars 998 forks source link

Leaflet.MarkerClusterGroup is not a constructor #706

Closed FbPalmabit closed 8 years ago

FbPalmabit commented 8 years ago

I'm trying to implement cluster in Ionic2:

let markersGroup = new Leaflet.MarkerClusterGroup();

I get this error: "TypeError: Leaflet.MarkerClusterGroup is not a constructor" Both libraries "leaflet" and "leaflet.markercluster" are 1.0.0

Maybe the problem is the Typings file that is for Leaflet.markercluster v0.4.0? https://github.com/DefinitelyTyped/DefinitelyTyped/blob/cc3d223a946f661eff871787edeb0fcb8f0db156/leaflet-markercluster/leaflet-markercluster.d.ts

IvanSanchez commented 8 years ago

Use the L.markerClusterGroup() factory method. Pay attention to L instead of Leaflet and first uppercase/lowercase letter.

FbPalmabit commented 8 years ago

I haven't the method markerClusterGroup() with the lowerCase. Only MarkerClusterGroup is possible.

L is my local variable import * as Leaflet from 'leaflet'

IvanSanchez commented 8 years ago

It might be a namespace problem on your side. Be aware that we the Leaflet developers handle bugs that can be easily reproducible in "vanilla" web browsers, we normally don't handle any bugs related to ionic (nor cordova, nor vue, nor react, nor ractive, nor R).

Can you publish a fiddle/codepen/playground that displays this behaviour?

cyclingzealot commented 5 years ago

In case you're using the wrong includes (script src statements), you may find some answers here: https://stackoverflow.com/questions/49333263/leaflet-markerclustergroup#49338608