Using http://playground-leaflet.rhcloud.com/ or any other jsfiddle like site.
I was trying the latest version of leaflet 1.02 to use in an app. Leaflet 1.0.2 works no problem if I build the app in plain javascript. Use leaflet 1.0.2 in a Typescript app breaks with: this.callInitHooks is not a function as soon as I add a Control plugin like GeoSearch to the map.
Is leaflet 1.0.2 ES6 / Typescript compatable?
There shouldn't be anything in particular stopping you from using Leaflet with TypeScript (there are definitions for it: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/leaflet/index.d.ts) and ES6.
Feel free to provide an example on http://playground-leaflet.rhcloud.com/, jsfiddle or similar if you think there's any particular issue with Leaflet that prevents this.
You Are absolutely right. I too has no problems using Leaflet in my app with Typescript. It just are the plugins that don’t work.
running the plugins can’t find kookinit().
Op 3 jan. 2017, om 14:57 heeft Per Liedman notifications@github.com het volgende geschreven:
There shouldn't be anything in particular stopping you from using Leaflet with TypeScript (there are definitions for it: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/leaflet/index.d.ts https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/leaflet/index.d.ts) and ES6.
Feel free to provide an example on http://playground-leaflet.rhcloud.com/ http://playground-leaflet.rhcloud.com/, jsfiddle or similar if you think there's any particular issue with Leaflet that prevents this.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/Leaflet/Leaflet/issues/5224#issuecomment-270119252, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZlpz5axhLON3LzzdbHZIgG4DYx4-Gnks5rOlPMgaJpZM4LXtMC.
I think you should file an issue with the plugin in question, unfortunately the Leaflet team has limited insight into plugins by other authors, and also our time and resources prevent us from debugging issues outside of Leaflet's core.
I don't know if this helps, but I just had the same issue. But it was my error. I was calling L.TilelLayer and not L.tileLayer() , perhaps add this to the documentation as common blunders :-( see also https://github.com/mWater/offline-leaflet-map/issues/18
Just in case someone has the same error, instead of
var positron = L.TileLayer(...)
you should write:
var positron = new L.TileLayer(...)
The new keyword is missing in your playground link @pcrombach
Just to make explicit what the issue is - Leaflet uses classes, and also has factory methods for creating new objects. The classes are captialized and need to be called with new
, while the factory methods are lowercase and should not. The documentation uses factory methods, so I cannot say whether directly instantiating class instance is supported, although the factories simply call new
anyway. The following are therefore equivalent, though only the first is documented.
// Small t, calling factory method
const positron = L.tileLayer(...);
// Capital T, instantiating a new instance directly
const positron = new L.TileLayer(...);
the same issue exists in react as well
Most helpful comment
Just in case someone has the same error, instead of
var positron = L.TileLayer(...)
you should write:
var positron = new L.TileLayer(...)
The new keyword is missing in your playground link @pcrombach