On the last line of code I get the following trace:
react-dom.production.min.js:196 ReferenceError: shp is not defined
at NewClass.addFileData (leaflet.shpfile.js:38)
at NewClass.initialize (leaflet.shpfile.js:25)
at new NewClass (leaflet-src.js:300)
at Object.L.shapefile (leaflet.shpfile.js:67)
at Map.createLayerGroups (main.js_+_3_modules:342)
at Map.componentDidMount (main.js_+_3_modules:186)
at ik (react-dom.production.min.js:251)
at exports.unstable_runWithPriority (scheduler.production.min.js:18)
at fg (react-dom.production.min.js:120)
at Yj (react-dom.production.min.js:244)
The console.log statement on the line immediately above succeeds, showing that some function shp is defined. I cannot, then, explain why I get the reference error shp is not defined on the line that comes immediately next.
(also posted in https://stackoverflow.com/q/60265760/274677) I am following the Leaflet essentials book, on how to load shapefiles. The book's instructions are:
I've followed the above instructions with slight changes since I'm on Webpack. Here's what I 've done:
shpjs
withnpm i shpjs --S
leaflet.shpfile.js
from github and placed it insrc/
*.js
file I require bothshpjs
andleaflet.shpfile.js
with the following code:I then access the shapefile as instructed:
On the last line of code I get the following trace:
The
console.log
statement on the line immediately above succeeds, showing that some functionshp
is defined. I cannot, then, explain why I get the reference errorshp is not defined
on the line that comes immediately next.