gisq-ol-mobile-offline
Version:
## Project setup ``` npm install ```
746 lines (646 loc) • 28.2 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('ol/proj/Projection'), require('proj4'), require('ol/proj/proj4'), require('ol/proj'), require('ol/style'), require('core-js/modules/es6.typed.uint8-array'), require('ol/format/GeoJSON'), require('core-js/modules/es6.regexp.replace'), require('core-js/modules/es6.array.index-of'), require('shpjs'), require('core-js/modules/es6.regexp.split'), require('core-js/modules/web.dom.iterable'), require('core-js/modules/es6.string.iterator'), require('core-js/modules/es6.map'), require('ol/tilegrid/TileGrid'), require('ol/source/TileImage'), require('ol/extent'), require('ol/layer/Vector'), require('ol/source/Vector'), require('ol/layer/Tile'), require('ol/layer/VectorTile'), require('ol/source/VectorTile')) :
typeof define === 'function' && define.amd ? define(['exports', 'ol/proj/Projection', 'proj4', 'ol/proj/proj4', 'ol/proj', 'ol/style', 'core-js/modules/es6.typed.uint8-array', 'ol/format/GeoJSON', 'core-js/modules/es6.regexp.replace', 'core-js/modules/es6.array.index-of', 'shpjs', 'core-js/modules/es6.regexp.split', 'core-js/modules/web.dom.iterable', 'core-js/modules/es6.string.iterator', 'core-js/modules/es6.map', 'ol/tilegrid/TileGrid', 'ol/source/TileImage', 'ol/extent', 'ol/layer/Vector', 'ol/source/Vector', 'ol/layer/Tile', 'ol/layer/VectorTile', 'ol/source/VectorTile'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.gisqOlMobile = {}, global.Projection, global.proj4, global.proj4$1, global.proj, global.style, null, global.GeoJSON, null, null, global.shp, null, null, null, null, global.TileGrid, global.TileImage, global.extent$1, global.VectorLayer, global.VectorSource, global.TileLayer, global.VectorTileLayer, global.VectorTile));
}(this, (function (exports, Projection, proj4, proj4$1, proj, style, es6_typed_uint8Array, GeoJSON, es6_regexp_replace, es6_array_indexOf, shp, es6_regexp_split, web_dom_iterable, es6_string_iterator, es6_map, TileGrid, TileImage, extent$1, VectorLayer, VectorSource, TileLayer, VectorTileLayer, VectorTile) { 'use strict';
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var Projection__default = /*#__PURE__*/_interopDefaultLegacy(Projection);
var proj4__default = /*#__PURE__*/_interopDefaultLegacy(proj4);
var GeoJSON__default = /*#__PURE__*/_interopDefaultLegacy(GeoJSON);
var shp__default = /*#__PURE__*/_interopDefaultLegacy(shp);
var TileGrid__default = /*#__PURE__*/_interopDefaultLegacy(TileGrid);
var TileImage__default = /*#__PURE__*/_interopDefaultLegacy(TileImage);
var VectorLayer__default = /*#__PURE__*/_interopDefaultLegacy(VectorLayer);
var VectorSource__default = /*#__PURE__*/_interopDefaultLegacy(VectorSource);
var TileLayer__default = /*#__PURE__*/_interopDefaultLegacy(TileLayer);
var VectorTileLayer__default = /*#__PURE__*/_interopDefaultLegacy(VectorTileLayer);
var VectorTile__default = /*#__PURE__*/_interopDefaultLegacy(VectorTile);
var gisqOlMobileProj = {};
(function () {
var gisqMobileProj = {
resolutions: {
res4490: [1.40625, 0.703125, 0.3515625, 0.17578125, 0.087890625, 0.0439453125, 0.02197265625, 0.010986328125, 0.0054931640625, 0.00274658203125, 0.001373291015625, 0.0006866455078125, 0.00034332275390625, 0.000171661376953125, 8.58306884765629E-05, 4.29153442382814E-05, 2.14576721191407E-05, 1.07288360595703E-05, 5.36441802978515E-06, 2.68220901489258E-06, 1.34110450744629E-06],
res3857: [156543.03392804097, 78271.51696402048, 39135.75848201024, 19567.87924100512, 9783.93962050256, 4891.96981025128, 2445.98490512564, 1222.99245256282, 611.49622628141, 305.748113140705, 152.8740565703525, 76.43702828517625, 38.21851414258813, 19.109257071294063, 9.554628535647032, 4.777314267823516, 2.388657133911758, 1.194328566955879, 0.5971642834779395],
res4326: [0.703913007855028, 0.35195650392751515, 0.17597825196375638, 0.08798912598187819, 0.043994562990939096, 0.021997281495469548, 0.010998640747734774, 0.005499320373868577, 0.0027496601869330985, 0.001374830093467739, 0.0006874150467326798, 0.0003437075233663399, 0.00017185376168316996, 0.00008592688084158498, 0.00004296344042198222, 0.00002148172021099111, 0.000010740860104305824, 0.0000053704300533426425, 0.000002685215025481591]
},
registerProj: function registerProj() {
proj4__default['default'].defs("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs");
proj4__default['default'].defs("EPSG:4528", "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=40500000 +y_0=0 +ellps=GRS80 +units=m +no_defs");
proj4__default['default'].defs("EPSG:4326", "+proj=longlat +datum=WGS84 +no_defs");
proj4$1.register(proj4__default['default']); //this.init();
},
transform: function transform(obj, inProj, outProj) {
return proj.transform(obj, inProj, outProj);
},
getCustomProj: function getCustomProj(code, extend, units, origin, resolutions) {
this.proj = new Projection__default['default']({
code: code,
extent: extent,
units: units,
origin: origin
});
proj.addProjection(this.proj);
this.extent = this.proj.getExtent();
this.resolutions = resolutions;
}
};
var Projection4528 = function Projection4528() {
this.proj = proj.get("EPSG:4528");
this.extent = this.proj.getExtent(); //this.center=[40500000.00,4305182.26];
};
var Projection4490 = function Projection4490() {
this.proj = new Projection__default['default']({
code: 'EPSG:4490',
extent: [-180, -90, 180, 90],
units: 'degrees',
worldExtent: [-180, -90, 180, 90]
});
proj.addProjection(this.proj);
this.extent = this.proj.getExtent();
this.resolutions = gisqMobileProj.resolutions.res4490;
};
var Projection4326 = function Projection4326() {
this.proj = new proj.get("EPSG:4326");
this.extent = this.proj.getExtent();
this.resolutions = gisqMobileProj.resolutions.res4326;
};
var Projection3857 = function Projection3857() {
this.proj = new proj.get("EPSG:3857");
this.extent = this.proj.getExtent();
this.resolutions = gisqMobileProj.resolutions.res3857;
};
gisqMobileProj.registerProj();
gisqOlMobileProj = gisqMobileProj;
var _proj4528 = new Projection4528();
var _proj4490 = new Projection4490();
var _proj4326 = new Projection4326();
var _proj3857 = new Projection3857();
gisqOlMobileProj.proj4528 = _proj4528;
gisqOlMobileProj.proj4490 = _proj4490;
gisqOlMobileProj.proj4326 = _proj4326;
gisqOlMobileProj.proj3857 = _proj3857;
})();
var gisqOlMobileProj$1 = gisqOlMobileProj;
var GisqOlMobileStyle = function () {
var vetorStyle = function vetorStyle() {
var image = new style.Circle({
radius: 5,
fill: null,
stroke: new style.Stroke({
color: 'red',
width: 1
})
});
var styles = {
'Point': new style.Style({
image: image
}),
'LineString': new style.Style({
stroke: new style.Stroke({
color: 'green',
width: 1
})
}),
'MultiLineString': new style.Style({
stroke: new style.Stroke({
color: 'green',
width: 1
})
}),
'MultiPoint': new style.Style({
image: image
}),
'MultiPolygon': new style.Style({
stroke: new style.Stroke({
color: 'yellow',
width: 2
}),
fill: new style.Fill({
color: 'rgba(255, 255, 0, 0.1)'
})
}),
'Polygon': new style.Style({
stroke: new style.Stroke({
color: 'blue',
lineDash: [4],
width: 3
}),
fill: new style.Fill({
color: 'rgba(0, 0, 255, 0.1)'
})
}),
'GeometryCollection': new style.Style({
stroke: new style.Stroke({
color: 'magenta',
width: 2
}),
fill: new style.Fill({
color: 'magenta'
}),
image: new style.Circle({
radius: 10,
fill: null,
stroke: new style.Stroke({
color: 'magenta'
})
})
}),
'Circle': new style.Style({
stroke: new style.Stroke({
color: '#ff0000',
width: 2
}),
fill: new style.Fill({
color: '#ff0000'
})
})
};
var styleFunction = function styleFunction(feature) {
return styles[feature.getGeometry().getType()];
};
vetorStyle.prototype.styles = styles;
vetorStyle.prototype.styleFunction = styleFunction;
};
return vetorStyle;
}();
var Base64Binary = {
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
/* will return a Uint8Array type */
decodeArrayBuffer: function decodeArrayBuffer(input) {
var bytes = input.length / 4 * 3;
var ab = new ArrayBuffer(bytes);
this.decode(input, ab);
return ab;
},
removePaddingChars: function removePaddingChars(input) {
var lkey = this._keyStr.indexOf(input.charAt(input.length - 1));
if (lkey == 64) {
return input.substring(0, input.length - 1);
}
return input;
},
decode: function decode(input, arrayBuffer) {
//get last chars to see if are valid
input = this.removePaddingChars(input);
input = this.removePaddingChars(input);
var bytes = parseInt(input.length / 4 * 3, 10);
var uarray;
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
var j = 0;
if (arrayBuffer) uarray = new Uint8Array(arrayBuffer);else uarray = new Uint8Array(bytes);
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
for (i = 0; i < bytes; i += 3) {
//get the 3 octects in 4 ascii chars
enc1 = this._keyStr.indexOf(input.charAt(j++));
enc2 = this._keyStr.indexOf(input.charAt(j++));
enc3 = this._keyStr.indexOf(input.charAt(j++));
enc4 = this._keyStr.indexOf(input.charAt(j++));
chr1 = enc1 << 2 | enc2 >> 4;
chr2 = (enc2 & 15) << 4 | enc3 >> 2;
chr3 = (enc3 & 3) << 6 | enc4;
uarray[i] = chr1;
if (enc3 != 64) uarray[i + 1] = chr2;
if (enc4 != 64) uarray[i + 2] = chr3;
}
return uarray;
}
};
var GisqOlMobileShp = function () {
function gisqOfflineShpLayer(options) {
this.options = {};
this.options.path = options.path;
this.options.featureName = options.featureName;
this.options.projection = options.projection;
console.log(this.options.projection);
}
gisqOfflineShpLayer.prototype.addShpLayer = function (layerSource) {
if (shp__default['default'] && typeof plus != "undefined") {
var ShpMapServiceLayer = plus.android.importClass('com.zjzs.gisq.layer.ShpMapServiceLayer');
var nativeShpLayer = new ShpMapServiceLayer(this.options.path, this.options.featureName);
var shpArrayBase64 = nativeShpLayer.getShpBinary();
var dbfArrayBase64 = nativeShpLayer.getDbfBinary();
var shpArray;
if (Base64Binary) {
shpArray = Base64Binary.decode(shpArrayBase64);
Base64Binary.decode(dbfArrayBase64);
var _projection = this.options.projection;
var resolveF = function resolveF(geojson) {
//do something with your geojson
console.log(111);
var features = new GeoJSON__default['default']({
dataProjection: _projection,
featureProjection: 'EPSG:3857'
}).readFeatures(geojson); //features.setStyle(gisqVetorStyle.styles['MultiPolygon']);
layerSource.addFeatures(features);
};
var promise = new Promise(function (resolve) {
var geojson = shp__default['default'].combine([shp__default['default'].parseShp(shpArray), []]);
console.log(geojson);
resolve(geojson);
});
promise.then(resolveF);
}
} else {
console.log("Hbuilder app and has shpjs lib?");
}
};
return gisqOfflineShpLayer;
}();
var GisqMobileMbTileSource = function () {
var GisqTileMap = new Map();
var emptyImageUrl = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';
var nativeMbTilesLayer;
var proj3857 = gisqOlMobileProj$1.proj3857;
function MbTileSource(_path, options) {
this.path = _path;
this.options = {};
var projection = proj3857.proj;
if (options) {
this.options.resolutions = options.resolutions || proj3857.resolutions;
this.options.projection = options.projection || projection;
this.options.origin = options.origin;
this.options.tileType = options.tileType;
}
if (typeof plus != "undefined" && plus != null) {
this.MbTilesMapServiceLayer = plus.android.importClass('com.zjzs.gisq.layer.MbTilesMapServiceLayer');
nativeMbTilesLayer = new this.MbTilesMapServiceLayer(this.path, "", this.options.tileType);
}
}
MbTileSource.prototype.getTileGrid = function () {
var extent = this.options.projection.getExtent(); //console.log(this.options)
var origin = this.options.origin || extent$1.getTopLeft(extent);
var tileGrid = new TileGrid__default['default']({
resolutions: this.options.resolutions,
tileSize: [256, 256],
extent: extent,
origin: origin
});
return tileGrid;
};
MbTileSource.prototype.getMbTiles = function (x, y, z) {
return new Promise(function (resolve, reject) {
if (typeof plus == "undefined" || !plus) reject(emptyImageUrl);
if (GisqTileMap && GisqTileMap.size > 1024) {
for (var i = 0; i < 512; i++) {
GisqTileMap.delete(GisqTileMap.keys().next());
}
}
var key = y + "," + x + "," + z;
if (GisqTileMap && GisqTileMap.has(key)) {
var rtile = GisqTileMap.get(key); //console.log("L.TileLayer.GisqTileMap resolve==");
resolve("data:image/png;base64," + rtile);
} else {
var rtile = plus.android.invoke(nativeMbTilesLayer, "getTile", y, x, z);
if (rtile) {
if (GisqTileMap) {
GisqTileMap.set(key, rtile);
}
resolve("data:image/png;base64," + rtile);
} else {
reject(emptyImageUrl);
} //console.log(777);
//resolve("https://iknow-base.bj.bcebos.com/zl-xingzhijihua1201.jpg");
}
});
};
MbTileSource.prototype.getTileSource = function () {
var self = this;
var tilesource = new TileImage__default['default']({
tileUrlFunction: function tileUrlFunction(tileCoord) {
var z = tileCoord[0];
var x = tileCoord[1];
var y = Math.abs(tileCoord[2]);
return x + "/" + y + "/" + z;
},
tileLoadFunction: function tileLoadFunction(imageTile, src) {
//console.log(imageTile.getImage())
if (!!src) {
var xyz = src.split("/");
if (xyz && xyz.length == 3) {
var promise = self.getMbTiles(parseInt(xyz[0]), parseInt(xyz[1]), parseInt(xyz[2]));
promise.then(function (returnTile) {
imageTile.getImage().src = returnTile; //console.log("dddd=resolve="+returnTile)
}, function (returnTile) {
imageTile.getImage().src = returnTile; //console.log("dddd=reject")
});
}
}
},
tileGrid: this.getTileGrid(),
projection: this.options.projection
});
return tilesource;
};
return MbTileSource;
}();
var GisqMobileSqliteSource = function () {
var GisqTileMap = new Map();
var emptyImageUrl = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';
var nativeTilesLayer;
var proj3857 = gisqOlMobileProj$1.proj3857;
function MbTileSource(_path, options) {
this.path = _path;
this.options = {};
var projection = proj3857.proj;
if (options) {
this.options.resolutions = options.resolutions || proj3857.resolutions;
this.options.projection = options.projection || projection;
this.options.origin = options.origin;
}
if (typeof plus != "undefined" && plus != null) {
this.SqliteMapServiceLayer = plus.android.importClass('com.zjzs.gisq.layer.SqliteMapServiceLayer');
nativeTilesLayer = new this.SqliteMapServiceLayer(this.path, "");
}
}
MbTileSource.prototype.getTileGrid = function () {
var extent = this.options.projection.getExtent(); //onsole.log(this.options)
var origin = this.options.origin || extent$1.getTopLeft(extent);
var tileGrid = new TileGrid__default['default']({
resolutions: this.options.resolutions,
tileSize: [256, 256],
extent: extent,
origin: origin
});
return tileGrid;
};
MbTileSource.prototype.getMbTiles = function (x, y, z) {
return new Promise(function (resolve, reject) {
if (typeof plus == "undefined" || !plus) reject(emptyImageUrl);
if (GisqTileMap && GisqTileMap.size > 1024) {
for (var i = 0; i < 512; i++) {
GisqTileMap.delete(GisqTileMap.keys().next());
}
}
var key = y + "," + x + "," + z;
if (GisqTileMap && GisqTileMap.has(key)) {
var rtile = GisqTileMap.get(key); //console.log("L.TileLayer.GisqTileMap resolve==");
resolve("data:image/png;base64," + rtile);
} else {
var rtile = plus.android.invoke(nativeTilesLayer, "getTile", y, x, z);
if (rtile) {
if (GisqTileMap) {
GisqTileMap.set(key, rtile);
}
resolve("data:image/png;base64," + rtile);
} else {
reject(emptyImageUrl);
} //console.log(777);
//resolve("https://iknow-base.bj.bcebos.com/zl-xingzhijihua1201.jpg");
}
});
};
MbTileSource.prototype.getTileSource = function () {
var self = this;
var tilesource = new TileImage__default['default']({
tileUrlFunction: function tileUrlFunction(tileCoord) {
var z = tileCoord[0];
var x = tileCoord[1];
var y = Math.abs(tileCoord[2]);
return x + "/" + y + "/" + z;
},
tileLoadFunction: function tileLoadFunction(imageTile, src) {
//console.log(imageTile.getImage())
if (!!src) {
var xyz = src.split("/");
if (xyz && xyz.length == 3) {
var promise = self.getMbTiles(parseInt(xyz[0]), parseInt(xyz[1]), parseInt(xyz[2]));
promise.then(function (returnTile) {
imageTile.getImage().src = returnTile; //console.log("dddd=resolve="+returnTile)
}, function (returnTile) {
imageTile.getImage().src = returnTile; //console.log("dddd=reject")
});
}
}
},
tileGrid: this.getTileGrid(),
projection: this.options.projection
});
return tilesource;
};
return MbTileSource;
}();
var GisqOfflineShpLayer = function () {
function GisqVectorLayer(options) {
options = options || {};
this.path = options.path;
this.featureName = options.featureName;
this.tilesource = new VectorSource__default['default']({
wrapX: false
});
this.projection = options.projection;
this.addShpLayerCallback = new GisqOlMobileShp({
path: this.path,
featureName: this.featureName,
projection: this.projection
});
}
GisqVectorLayer.prototype.getLayer = function () {
this.addShpLayerCallback.addShpLayer(this.tilesource);
return new VectorLayer__default['default']({
source: this.tilesource,
projection: this.projection,
style: new GisqOlMobileStyle().styleFunction
});
};
return GisqVectorLayer;
}();
var GisqOfflineMbTilesLayer = function () {
var proj3857 = gisqOlMobileProj$1.proj3857;
function TilesLayer(options) {
TilesLayer.TABLE_TYPE_MBTILES = "mbtiles";
TilesLayer.TABLE_TYPE_ARCGIS = "arcgis";
options = options || {};
this.path = options.path;
this.projection = options.projection || 'EPSG:3857';
this.resolutions = options.resolutions || proj3857.resolutions;
this.origin = options.origin;
this.tileType = options.tileType || TilesLayer.TABLE_TYPE_MBTILES;
var tilesource = new GisqMobileMbTileSource(this.path, {
projection: this.projection,
resolutions: this.resolutions,
origin: this.origin,
tileType: this.tileType
});
this.tilesource = tilesource.getTileSource();
}
TilesLayer.prototype.getLayer = function () {
return new TileLayer__default['default']({
source: this.tilesource,
projection: this.projection
});
};
function getMedata(path) {
if (typeof plus == "undefined" || !plus) return "";
var MbTilesMapServiceLayer = plus.android.importClass('com.zjzs.gisq.layer.MbTilesMapServiceLayer');
var nativeMbTilesLayer = new MbTilesMapServiceLayer(path, "");
var metaData = plus.android.invoke(nativeMbTilesLayer, "getConfig");
return metaData;
}
TilesLayer.getMedata = getMedata;
return TilesLayer;
}();
var GisqOfflineSqliteLayer = function () {
var proj3857 = gisqOlMobileProj$1.proj3857;
function TilesLayer(options) {
options = options || {};
this.path = options.path;
this.projection = options.projection || 'EPSG:3857';
this.resolutions = options.resolutions || proj3857.resolutions;
this.origin = options.origin;
var tilesource = new GisqMobileSqliteSource(this.path, {
projection: this.projection,
resolutions: this.resolutions,
origin: this.origin
});
this.tilesource = tilesource.getTileSource();
}
TilesLayer.prototype.getLayer = function () {
return new TileLayer__default['default']({
source: this.tilesource,
projection: this.projection
});
};
function getMedata(path) {
if (typeof plus == "undefined" || !plus) return "";
var SqliteMapServiceLayer = plus.android.importClass('com.zjzs.gisq.layer.SqliteMapServiceLayer');
var nativeTilesLayer = new SqliteMapServiceLayer(path, "");
var metaData = plus.android.invoke(nativeTilesLayer, "getConfig");
return metaData;
}
TilesLayer.getMedata = getMedata;
return TilesLayer;
}();
var GisqGeoJsonVectorTileSource = function () {
var proj3857 = gisqOlMobileProj$1.proj3857;
function VectorTileSource(options) {
var options = options || {};
this.path = options.path;
this.resolutions = options.resolutions || proj3857.resolutions;
this.dataProjection = options.dataProjection || 'EPSG:3857';
this.featureProjection = options.featureProjection || 'EPSG:3857';
this.sqlKey = options.sqlKey || '';
}
VectorTileSource.prototype.getTileGrid = function () {
var extent = this.featureProjection.getExtent();
var tileGrid = new TileGrid__default['default']({
resolutions: proj3857.resolutions,
tileSize: [256, 256],
extent: extent,
origin: extent$1.getTopLeft(extent)
});
return tileGrid;
};
VectorTileSource.prototype.getSources = function () {
var self = this;
var tileGeoJsonSource = new VectorTile__default['default']({
format: new GeoJSON__default['default'](),
tileUrlFunction: function tileUrlFunction(tileCoord) {
var z = tileCoord[0];
var x = tileCoord[1];
var y = Math.abs(tileCoord[2]);
return x + "/" + y + "/" + z;
},
tileLoadFunction: function tileLoadFunction(tile, src) {
var xyz = src.split("/");
if (xyz && xyz.length == 3) {
var format = tile.getFormat();
var proj = this.projection;
var promise = self.getGeoJsonTiles(parseInt(xyz[0]), parseInt(xyz[1]), parseInt(xyz[2]), format, proj);
promise.then(function (geoFeatures, prj) {
tile.onLoad(geoFeatures, prj);
}, function (error) {
console.log("error=" + error);
tile.onError();
});
} else {
tile.onError();
}
},
tileGrid: this.getTileGrid(),
projection: 'EPSG:3857'
});
return tileGeoJsonSource;
};
VectorTileSource.prototype.getGeoJsonTiles = function (x, y, z, format, projection) {
var self = this;
return new Promise(function (resolve, reject) {
if (typeof plus == "undefined" || !plus) reject("is Hbuilder app?");
var GeoJsonMapServiceLayer = plus.android.importClass('com.zjzs.gisq.layer.GeoJsonMapServiceLayer');
var nativeGeoJsonSqlLayer = new GeoJsonMapServiceLayer(self.path, self.sqlKey);
var geoJsonStr = plus.android.invoke(nativeGeoJsonSqlLayer, "getGeoJsonTile", y, x, z);
if (geoJsonStr) {
console.log("XYZ==" + x + "," + y + "," + z);
var geoFeatures = format.readFeatures(geoJsonStr, {
dataProjection: self.dataProjection,
featureProjection: projection
});
var prj = format.readProjection(geoJsonStr);
resolve(geoFeatures, prj);
} else {
reject("暂无数据");
} //console.log(777);
//resolve(emptyImageUrl);
});
};
return VectorTileSource;
}();
var GisqOfflineGeoJsonLayer = function () {
var proj3857 = gisqOlMobileProj$1.proj3857;
function GisqVectorLayer(options) {
var options = options || {};
this.path = options.path;
var _dataProjection = options.dataProjection || 'EPSG:3857';
var _featureProjection = options.featureProjection || 'EPSG:3857';
this.resolutions = options.resolutions || proj3857.resolutions;
this.layerProjection = _featureProjection;
this.jsonDataProjection = _dataProjection;
this.sqlKey = options.sqlKey || '';
}
GisqVectorLayer.prototype.getLayer = function () {
if (typeof plus == "undefined") return null;
var GeoJsonMapServiceLayer = plus.android.importClass('com.zjzs.gisq.layer.GeoJsonMapServiceLayer');
var nativeGeoJsonLayer = new GeoJsonMapServiceLayer(this.path);
var geojsonObject = plus.android.invoke(nativeGeoJsonLayer, "getGeoJson");
var geoJsonFeatures = new GeoJSON__default['default']().readFeatures(geojsonObject, {
dataProjection: this.jsonDataProjection,
featureProjection: this.layerProjection
});
var gisqVectorSource = new VectorSource__default['default']({
features: geoJsonFeatures
});
return new VectorLayer__default['default']({
source: gisqVectorSource,
projection: this.layerProjection || 'EPSG:3857',
style: new GisqOlMobileStyle().styleFunction
});
};
GisqVectorLayer.prototype.getVectorTileLayer = function () {
if (typeof plus == "undefined") throw "is Hbuilder app?";
var gisqVectorSource = new GisqGeoJsonVectorTileSource({
path: this.path,
resolutions: this.resolutions,
dataProjection: this.jsonDataProjection,
featureProjection: this.layerProjection,
sqlKey: this.sqlKey
});
return new VectorTileLayer__default['default']({
source: gisqVectorSource.getSources(),
projection: this.layerProjection || 'EPSG:3857',
style: new GisqOlMobileStyle().styleFunction
});
};
return GisqVectorLayer;
}();
exports.GisqMobileMbTileSource = GisqMobileMbTileSource;
exports.GisqMobileSqliteSource = GisqMobileSqliteSource;
exports.GisqOfflineGeoJsonLayer = GisqOfflineGeoJsonLayer;
exports.GisqOfflineMbTilesLayer = GisqOfflineMbTilesLayer;
exports.GisqOfflineShpLayer = GisqOfflineShpLayer;
exports.GisqOfflineSqliteLayer = GisqOfflineSqliteLayer;
exports.gisqOlMobileProj = gisqOlMobileProj$1;
exports.gisqOlMobileShp = GisqOlMobileShp;
exports.gisqOlMobileStyle = GisqOlMobileStyle;
Object.defineProperty(exports, '__esModule', { value: true });
})));