Charmatzis / react-leaflet-shapefile

React-Leaflet-Shapefile | This repo is obsolete. Plz, use https://github.com/TA-Geoforce/react-leaflet-shapefile
https://github.com/TA-Geoforce/react-leaflet-shapefile
MIT License
12 stars 22 forks source link

Uncaught Error createLeafletElement() must be implemented #1

Open uptonking opened 7 years ago

uptonking commented 7 years ago

I used this lib and run the example demo:

git clone https://github.com/Charmatzis/react-leaflet-shapefile.git
npm install
npm run example

the map dispalys successfully, but When I upload the sample .zip, the error shows in developer console.

Uncaught Error: createLeafletElement() must be implemented
    at ShapeFile.createLeafletElement (MapLayer.js:54)
    at ShapeFile.componentWillMount (MapLayer.js:66)
    at ShapeFile.componentWillMount (ShapeFile.js:12)
    at ReactCompositeComponent.js:348
    at measureLifeCyclePerf (ReactCompositeComponent.js:75)
    at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js:347)
    at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:258)
    at Object.mountComponent (ReactReconciler.js:46)
    at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js:371)
    at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:258)

It seems to be the problem with the change react-leaflet api, would you please update react-leaflet-shapefile to react-leafletv1.1.0 or later. thanks

Charmatzis commented 7 years ago

Well, as far as I remember the upload of the zip file happens with a worker, https://github.com/Charmatzis/react-leaflet-shapefile/blob/master/src/leaflet.shpfile.js#L18

so if you want to load a shp file at default, you have to change it so when the page initializes the worker will load the data.

uptonking commented 7 years ago

@Charmatzis , thanks a lot. that solved my 2nd questions. Would you please update the react-leaflet from 1.0.1 to 1.1.0 in package.json, the api has a sight change so the examples didn't work.