Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_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()
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;
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;
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;
},
.then(text => {
let reader = geo.createFileReader('jsonReader', {layer: layer});
reader.read(text, resolve);
})
.catch(error => {
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);
});
}