Open jcpatac opened 6 years ago
copy over the shp.js file leaflet.shapefile.js files into your vendors folder, or really just any folder in your app and then require them (require shp first) this was written way before I know about bundlers or anything
Okay, so I did just that. Inside shp.js, in the binaryAjax function, I also tweaked the ajax.addEventListener because it did not trigger or something like that. So I changed it into ajax.onreadystatechange. The logic/function is still the same but I still got an error. The error is on return resolve(new Buffer(ajax.response)); It seems like the response is null. Any thoughts on this?
change new Buffer(ajax.response)
to Buffer.from(ajax.response)
more generally the shapefile to geojson library is available on npm as shpjs
and should work, it's only this leaflet plugin that isn't working, you might be better off just using shpjs directly and then using the built in leaflet geojson stuff.
So I changed new Buffer(ajax.response)
to Buffer.from(ajax.response)
but the same error occurred. When I log the response value to the console, it says null. I don't know why though. I think it's because I'm fetching the file locally? I am also in a localhost development server.
yup local would be the issue, run a server so it's on local host npm install -g server && serve
will do the trick
I already did this and the error still occurred. I don't know what went wrong really
as I said above, this shapefile plugin for leaflet is pretty old, you might be better off using the shapefile to geojson library directly
So I want to use this module for my leaflet map but I'm developing it on ionic. How can I use this module?