timwis/leaflet-choropleth

var L = require('leaflet') is not defined

Closed this issue · 7 comments

Trying to use the leaflet plugin but I get errors at" choropleth.js:1" Uncaught ReferenceError: require choropleth.js:1 is not defined. Error shows up here "var L = require('leaflet')".

I have no clue why.
I am using chrome with the developer tools
printscreen 2018-01-01 kl 22 01 08

Thanks

Are you using browserify/webpack or just a <script> tag? If the latter, make sure you're pointing to the version inside dist/ not src/.

Did you try changing it to point to the dist/ file instead of the src/ file like I suggested?

I did copy the dist to the basic folder the error is gone but a new one turned up...
Is there a way to get around this problem? It seems to be a browser problem, I use a local server MAMP and Chrome. Thanks
printscreen 2018-01-03 kl 17 28 41

OK, I was able to deactivate Cross-Origin under developer tool in Safari, I see what I can do in Chrome...

It looks like you're trying to load your webpage as a file rather than via a local web server. The problem you're experiencing would happen with any module, and is not specific to leaflet-choropleth. I recommend you run a local web server on your computer for your development. The three.js docs have a good write-up about how to run things locally. Three.js has nothing to do with leaflet, but the problem you're describing is one faced by every web developer when they're getting started, so they cover it in their docs too. Hope that helps.