How to use the shpjs function in shpjs

To help you get started, we’ve selected a few shpjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plotly / react-chart-editor / src / components / widgets / UploadShapefile.js View on Github external
message: ErrorMessages.UPLOAD_SHAPE_FILE.PARSING_ERROR,
        });
      };

      if (fileExtension === "json") {
        try {
          this.props.onUpload(JSON.parse(contents));
        } catch (error) {
          showErrorState(error);
        }
      } else {
        /* shp accepts shapefiles and GeoJSON zipped files:
                 * https://github.com/calvinmetcalf/shapefile-js/blob/gh-pages/lib/index.js#L59
                */

        shp(contents)
          .then(geojson => {
            this.props.onUpload(geojson);
            /*
                     * remain in the "loading" state until the value comes
                     * back to the component in componentWillReceiveProps
                     */
          })
          .catch(showErrorState);
      }
    };
github ibi-group / datatools-ui / lib / editor / actions / map / index.js View on Github external
reader.onload = e => {
      const arrayBuff = reader.result
      shp(arrayBuff).then(geojson => {
        console.log(geojson)
        geojson.key = Math.random()
        dispatch(receivedRoutesShapefile(feedSource, geojson))
      })
    }
    reader.readAsArrayBuffer(file)
github terrestris / react-geo / src / Util / FileUtil / FileUtil.jsx View on Github external
reader.addEventListener('loadend', () => {
      const blob = reader.result;
      shp(blob).then(json => {
        FileUtil.addGeojsonLayer(json, map);
      });
    });
  }
github terrestris / ol-util / src / FileUtil / FileUtil.js View on Github external
reader.addEventListener('loadend', () => {
      const blob = reader.result;
      shp(blob).then(json => {
        FileUtil.addGeojsonLayer(json, map);
      });
    });
  }
github OpenDroneMap / WebODM / app / static / app / js / classes / TempLayer.js View on Github external
reader.onload = function () {
        if (reader.readyState != 2 || reader.error) {
          return;
        } else {
          shp(reader.result).then(function (geojson) {
            addLayer(geojson);
          }).catch(function (err) {
            err.message = "Not a proper zipped shapefile " + file.name;
            cb(err);
          })
        }
      }
      reader.readAsArrayBuffer(file);

shpjs

Load shapefiles in pure JavaScript

MIT
Latest version published 4 months ago

Package Health Score

74 / 100
Full package analysis