How to use the geojs.createFileReader function in geojs

To help you get started, we’ve selected a few geojs 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 OpenGeoscience / jupyterlab_geojs / src / geojsbuilder.ts View on Github external
_loadGeoJSONObject(layer:any, data: any): Promise {
    // console.dir(layer);
    // console.dir(data);

    let reader: any = geo.createFileReader('jsonReader', {layer: layer});
    return new Promise((resolve, reject) => {
      try {
        reader.read(data, resolve);
      }
      catch (error) {
        console.error(error);
        reject(error);
      }
    })  // new Promise()
  }  // loadGeoJSONData()
github Kitware / minerva / web_external / views / adapters / GeometryRepresentation.js View on Github external
init(container, dataset, visProperties, data) {
        this.geoJsLayer = container.createLayer('feature');
        dataset.geoJsLayer = this.geoJsLayer;

        // force selection api on all features for this layer
        var _createFeature = this.geoJsLayer.createFeature;
        this.geoJsLayer.createFeature = function (name, arg) {
            if (!arg) {
                arg = {};
            }
            arg.selectionAPI = true;
            return _createFeature.call(this, name, arg);
        };

        try {
            var reader = geo.createFileReader(this.readerType, { layer: this.geoJsLayer });
            this._prepareColorLegendMeta(dataset, container, data, visProperties, data.summary);
            if (!data.series) { // not a timeseries
                this._injectStyle(data, visProperties, data.summary || {});
                reader.read(data, _.bind(function (features) {
                    this._processFeatures(visProperties, features);
                }, this));
            } else { // a timeseries
                var lastFeature = 0;
                var curframe = 0;
                _.each(data.series, function (entry, index) {
                    this._injectStyle(entry.geojson, visProperties, data.summary || {});
                    reader.read(entry.geojson, _.bind(function (features) {
                        this._processFeatures(visProperties, features);
                    }, this));
                    entry.features = this.geoJsLayer.features().slice(lastFeature);
                    lastFeature = this.geoJsLayer.features().length;
github Kitware / minerva / web_external / views / adapters / Adapters.js View on Github external
this.init = function (container, dataset, visProperties, data) {
        this.geoJsLayer = container.createLayer('feature');
        dataset.geoJsLayer = this.geoJsLayer;

        // force selection api on all features for this layer
        var _createFeature = this.geoJsLayer.createFeature;
        this.geoJsLayer.createFeature = function (name, arg) {
            if (!arg) {
                arg = {};
            }
            arg.selectionAPI = true;
            return _createFeature.call(this, name, arg);
        };

        try {
            var reader = geo.createFileReader(this.readerType, { layer: this.geoJsLayer });
            this._prepareColorLegendMeta(dataset, container, data, visProperties, data.summary);
            if (!data.series) {  // not a timeseries
                this._injectStyle(data, visProperties, data.summary || {});
                reader.read(data, _.bind(function (features) {
                    this._processFeatures(visProperties, features);
                }, this));
            } else {    // a timeseries
                var lastFeature = 0;
                var curframe = 0;
                _.each(data.series, function (entry, index) {
                    this._injectStyle(entry.geojson, visProperties, data.summary || {});
                    reader.read(entry.geojson, _.bind(function (features) {
                        this._processFeatures(visProperties, features);
                    }, this));
                    entry.features = this.geoJsLayer.features().slice(lastFeature);
                    lastFeature = this.geoJsLayer.features().length;
github OpenGeoscience / pointcloud_viewer / web_client / GeoJsView.js View on Github external
render: function () {
        this.$el.html(template());
        this.$('.g-geojs-map-overlay-topleft').text(this.model.name());

        this._map = geojs.map({
            node: this.$('.g-geojs-map-container'),
            center: {
                x: -98,
                y: 39
            },
            zoom: 3
        });
        this._map.createLayer('osm');

        var layer = this._map.createLayer('feature');
        var reader = geojs.createFileReader('jsonReader', {'layer': layer});

        reader.read(this.model.downloadUrl());
        this._map.draw();

        return this;
    },
github OpenGeoscience / jupyterlab_geojs / src / geojsbuilder.ts View on Github external
.then(text => {
          let reader = geo.createFileReader('jsonReader', {layer: layer});
          reader.read(text, resolve);
        })
        .catch(error => {
github OpenGeoscience / jupyterlab_geojs / packages / geojson-extension / src / index.tsx View on Github external
return new Promise((resolve, reject) => {
      this._map = geojs.map({
        node: this.node,
        center: {
          x: -98,
          y: 39
        },
        zoom: 3
      });
      this._map.createLayer('osm');
      var layer = this._map.createLayer('feature');
      var reader = geojs.createFileReader('jsonReader', {'layer': layer});
      reader.read(data);
      this._map.draw();
      resolve(undefined);
    });
  }