Closed MadMartinR closed 5 years ago
I guess my question wasn't very clear - I want to be able to use shapefile-js AND proj4 without the need to load Proj4 twice. In other words I would like to load shapefile-js and access the Proj4 library that is within shapefile-js. For example it would be useful to be able to access shp.proj4(....)
it depends on how you are loading this library, if you are using browserify or webpack then you should be able to just require/import it like any other library and as long as you request the same version it will be deduped
Calvin, thanks for the quick response. I am just loading the shp.min.js file directly within the web page in conjunction with leaflet.js and a few other libraries. I was hoping there was a simple proj4 object within the shapefile-js that I could call. I will look at using browserify or webpack and see if I can sort it that way.
Solved: In case anyone finds this post I followed Calvin's advice and used browserify to re-browserify the shp.js file after adding shp.proj4 = proj4 to the second to last line of the index.js file.
This means I can now include shp.js in my web page and access proj4 in my javascript code using shp.proj4
Is it possible to access the shapefile-js Proj4 library directly? I have a need to re-project coordinates within my JavaScript and do not want to have to load the library twice (ie once within shapefile-js and also directly as a script)