mirror of https://gitee.com/antv-l7/antv-l7
feat: 发布打包代码调整 (#1117)
* fix: 修复 mouseup 失效 * chore: update version 2.8.35 -> 2.8.36 * fix: fix bboxPolygon conflict * fix: fix bboxPolygon conflict * feat: add utils turf dependencies * fix: change rollup build config * feat: 替换 turf/bbox-polygon 的引入方式 * feat: add turf bboxpolygon dependencies * feat: change TileLoadParams interface export * style: lint style * feat: change TilesetManagerOptions interface export * style: lint style * feat: rename tilebboxPolygon -> bboxPolygon * feat: rename tilebboxPolygon -> bboxPolygon * fix: 解决 rollup 打包问题 Co-authored-by: yunji <yunji.me@outlook.com>
This commit is contained in:
parent
2b9c850183
commit
00005f1147
15
lerna.json
15
lerna.json
|
@ -1,14 +1,21 @@
|
||||||
{
|
{
|
||||||
"packages": ["packages/*"],
|
"packages": [
|
||||||
|
"packages/*"
|
||||||
|
],
|
||||||
"command": {
|
"command": {
|
||||||
"publish": {
|
"publish": {
|
||||||
"ignoreChanges": ["*.md"],
|
"ignoreChanges": [
|
||||||
"allowBranch": ["publish", "docs"],
|
"*.md"
|
||||||
|
],
|
||||||
|
"allowBranch": [
|
||||||
|
"publish",
|
||||||
|
"docs"
|
||||||
|
],
|
||||||
"message": "chore: publish",
|
"message": "chore: publish",
|
||||||
"registry": "https://registry.npmjs.org"
|
"registry": "https://registry.npmjs.org"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"version": "2.8.35",
|
"version": "2.8.36",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"useWorkspaces": true,
|
"useWorkspaces": true,
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-component",
|
"name": "@antv/l7-component",
|
||||||
"version": "2.8.35",
|
"version": "2.8.36",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -25,8 +25,8 @@
|
||||||
"author": "lzxue",
|
"author": "lzxue",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7-core": "^2.8.35",
|
"@antv/l7-core": "^2.8.36",
|
||||||
"@antv/l7-utils": "^2.8.35",
|
"@antv/l7-utils": "^2.8.36",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"eventemitter3": "^4.0.0",
|
"eventemitter3": "^4.0.0",
|
||||||
"inversify": "^5.0.1",
|
"inversify": "^5.0.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-core",
|
"name": "@antv/l7-core",
|
||||||
"version": "2.8.35",
|
"version": "2.8.36",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/async-hook": "^2.1.0",
|
"@antv/async-hook": "^2.1.0",
|
||||||
"@antv/l7-utils": "^2.8.35",
|
"@antv/l7-utils": "^2.8.36",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"ajv": "^6.10.2",
|
"ajv": "^6.10.2",
|
||||||
"element-resize-event": "^3.0.3",
|
"element-resize-event": "^3.0.3",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7",
|
"name": "@antv/l7",
|
||||||
"version": "2.8.35",
|
"version": "2.8.36",
|
||||||
"description": "A Large-scale WebGL-powered Geospatial Data Visualization",
|
"description": "A Large-scale WebGL-powered Geospatial Data Visualization",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -25,13 +25,13 @@
|
||||||
"author": "antv",
|
"author": "antv",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7-component": "^2.8.35",
|
"@antv/l7-component": "^2.8.36",
|
||||||
"@antv/l7-core": "^2.8.35",
|
"@antv/l7-core": "^2.8.36",
|
||||||
"@antv/l7-layers": "^2.8.35",
|
"@antv/l7-layers": "^2.8.36",
|
||||||
"@antv/l7-maps": "^2.8.35",
|
"@antv/l7-maps": "^2.8.36",
|
||||||
"@antv/l7-scene": "^2.8.35",
|
"@antv/l7-scene": "^2.8.36",
|
||||||
"@antv/l7-source": "^2.8.35",
|
"@antv/l7-source": "^2.8.36",
|
||||||
"@antv/l7-utils": "^2.8.35",
|
"@antv/l7-utils": "^2.8.36",
|
||||||
"@babel/runtime": "^7.7.7"
|
"@babel/runtime": "^7.7.7"
|
||||||
},
|
},
|
||||||
"gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31",
|
"gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31",
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
const version = '2.8.35';
|
const version = '2.8.36';
|
||||||
export { version };
|
export { version };
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-layers",
|
"name": "@antv/l7-layers",
|
||||||
"version": "2.8.35",
|
"version": "2.8.36",
|
||||||
"description": "L7's collection of built-in layers",
|
"description": "L7's collection of built-in layers",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -23,9 +23,9 @@
|
||||||
"author": "xiaoiver",
|
"author": "xiaoiver",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7-core": "^2.8.35",
|
"@antv/l7-core": "^2.8.36",
|
||||||
"@antv/l7-source": "^2.8.35",
|
"@antv/l7-source": "^2.8.36",
|
||||||
"@antv/l7-utils": "^2.8.35",
|
"@antv/l7-utils": "^2.8.36",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"@mapbox/martini": "^0.2.0",
|
"@mapbox/martini": "^0.2.0",
|
||||||
"@turf/meta": "^6.0.2",
|
"@turf/meta": "^6.0.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-map",
|
"name": "@antv/l7-map",
|
||||||
"version": "2.8.35",
|
"version": "2.8.36",
|
||||||
"description": "l7 map",
|
"description": "l7 map",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "thinkinggis <lzx199065@gmail.com>",
|
"author": "thinkinggis <lzx199065@gmail.com>",
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/antvis/L7#readme",
|
"homepage": "https://github.com/antvis/L7#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7-utils": "^2.8.35",
|
"@antv/l7-utils": "^2.8.36",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"@mapbox/point-geometry": "^0.1.0",
|
"@mapbox/point-geometry": "^0.1.0",
|
||||||
"@mapbox/unitbezier": "^0.0.0",
|
"@mapbox/unitbezier": "^0.0.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-maps",
|
"name": "@antv/l7-maps",
|
||||||
"version": "2.8.35",
|
"version": "2.8.36",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -27,9 +27,9 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@amap/amap-jsapi-loader": "^0.0.3",
|
"@amap/amap-jsapi-loader": "^0.0.3",
|
||||||
"@antv/l7-core": "^2.8.35",
|
"@antv/l7-core": "^2.8.36",
|
||||||
"@antv/l7-map": "^2.8.35",
|
"@antv/l7-map": "^2.8.36",
|
||||||
"@antv/l7-utils": "^2.8.35",
|
"@antv/l7-utils": "^2.8.36",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"@types/amap-js-api": "^1.4.6",
|
"@types/amap-js-api": "^1.4.6",
|
||||||
"@types/mapbox-gl": "^1.11.2",
|
"@types/mapbox-gl": "^1.11.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-mini",
|
"name": "@antv/l7-mini",
|
||||||
"version": "2.8.35",
|
"version": "2.8.36",
|
||||||
"description": "A Large-scale WebGL-powered Geospatial Data Visualization",
|
"description": "A Large-scale WebGL-powered Geospatial Data Visualization",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -25,11 +25,11 @@
|
||||||
"author": "antv",
|
"author": "antv",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7-core": "^2.8.35",
|
"@antv/l7-core": "^2.8.36",
|
||||||
"@antv/l7-layers": "^2.8.35",
|
"@antv/l7-layers": "^2.8.36",
|
||||||
"@antv/l7-maps": "^2.8.35",
|
"@antv/l7-maps": "^2.8.36",
|
||||||
"@antv/l7-scene": "^2.8.35",
|
"@antv/l7-scene": "^2.8.36",
|
||||||
"@antv/l7-utils": "^2.8.35",
|
"@antv/l7-utils": "^2.8.36",
|
||||||
"@babel/runtime": "^7.7.7"
|
"@babel/runtime": "^7.7.7"
|
||||||
},
|
},
|
||||||
"gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31",
|
"gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-renderer",
|
"name": "@antv/l7-renderer",
|
||||||
"version": "2.8.35",
|
"version": "2.8.36",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
"gl": "^4.4.0"
|
"gl": "^4.4.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7-core": "^2.8.35",
|
"@antv/l7-core": "^2.8.36",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"inversify": "^5.0.1",
|
"inversify": "^5.0.1",
|
||||||
"l7regl": "^0.0.20",
|
"l7regl": "^0.0.20",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-scene",
|
"name": "@antv/l7-scene",
|
||||||
"version": "2.8.35",
|
"version": "2.8.36",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -23,12 +23,12 @@
|
||||||
"author": "xiaoiver",
|
"author": "xiaoiver",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7-component": "^2.8.35",
|
"@antv/l7-component": "^2.8.36",
|
||||||
"@antv/l7-core": "^2.8.35",
|
"@antv/l7-core": "^2.8.36",
|
||||||
"@antv/l7-layers": "^2.8.35",
|
"@antv/l7-layers": "^2.8.36",
|
||||||
"@antv/l7-maps": "^2.8.35",
|
"@antv/l7-maps": "^2.8.36",
|
||||||
"@antv/l7-renderer": "^2.8.35",
|
"@antv/l7-renderer": "^2.8.36",
|
||||||
"@antv/l7-utils": "^2.8.35",
|
"@antv/l7-utils": "^2.8.36",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"inversify": "^5.0.1",
|
"inversify": "^5.0.1",
|
||||||
"mapbox-gl": "^1.2.1",
|
"mapbox-gl": "^1.2.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-source",
|
"name": "@antv/l7-source",
|
||||||
"version": "2.8.35",
|
"version": "2.8.36",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -26,8 +26,8 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/async-hook": "^2.1.0",
|
"@antv/async-hook": "^2.1.0",
|
||||||
"@antv/l7-core": "^2.8.35",
|
"@antv/l7-core": "^2.8.36",
|
||||||
"@antv/l7-utils": "^2.8.35",
|
"@antv/l7-utils": "^2.8.36",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"@mapbox/geojson-rewind": "^0.4.0",
|
"@mapbox/geojson-rewind": "^0.4.0",
|
||||||
"@turf/helpers": "^6.1.4",
|
"@turf/helpers": "^6.1.4",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-three",
|
"name": "@antv/l7-three",
|
||||||
"version": "2.8.35",
|
"version": "2.8.36",
|
||||||
"description": "three for L7 ",
|
"description": "three for L7 ",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"3D",
|
"3D",
|
||||||
|
@ -44,9 +44,9 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/antvis/L7#readme",
|
"homepage": "https://github.com/antvis/L7#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7-core": "^2.8.35",
|
"@antv/l7-core": "^2.8.36",
|
||||||
"@antv/l7-layers": "^2.8.35",
|
"@antv/l7-layers": "^2.8.36",
|
||||||
"@antv/l7-scene": "^2.8.35",
|
"@antv/l7-scene": "^2.8.36",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"inversify": "^5.0.1",
|
"inversify": "^5.0.1",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-utils",
|
"name": "@antv/l7-utils",
|
||||||
"version": "2.8.35",
|
"version": "2.8.36",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -25,6 +25,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"@turf/helpers": "^6.1.4",
|
"@turf/helpers": "^6.1.4",
|
||||||
|
"@turf/bbox-polygon": "^6.5.0",
|
||||||
"d3-color": "^1.4.0"
|
"d3-color": "^1.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { Bounds, UpdateTileStrategy } from './types';
|
import { TileBounds, UpdateTileStrategy } from './types';
|
||||||
import {
|
import {
|
||||||
updateTileStateOverlap,
|
updateTileStateOverlap,
|
||||||
updateTileStateReplace,
|
updateTileStateReplace,
|
||||||
} from './utils/strategies';
|
} from './utils/strategies';
|
||||||
|
|
||||||
export const TILE_SIZE = 256;
|
export const TILE_SIZE = 256;
|
||||||
export const DEFAULT_EXTENT: Bounds = [
|
export const DEFAULT_EXTENT: TileBounds = [
|
||||||
-Infinity,
|
-Infinity,
|
||||||
-Infinity,
|
-Infinity,
|
||||||
Infinity,
|
Infinity,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
export * from './utils/tile-url';
|
export * from './utils/tile-url';
|
||||||
export { Tile, TileLoadParams } from './tile';
|
export * from './types';
|
||||||
export { TilesetManager, TilesetManagerOptions } from './tileset-manager';
|
export { Tile } from './tile';
|
||||||
|
export { TilesetManager } from './tileset-manager';
|
||||||
|
|
|
@ -1,27 +1,12 @@
|
||||||
import { bboxPolygon } from '@turf/turf';
|
import bboxPolygon from '@turf/bbox-polygon';
|
||||||
import { Bounds } from './types';
|
import {
|
||||||
|
LoadTileDataStatus,
|
||||||
|
TileBounds,
|
||||||
|
TileLoadDataOptions,
|
||||||
|
TileOptions,
|
||||||
|
} from './types';
|
||||||
import { getTileWarpXY, tileToBounds } from './utils/lonlat-tile';
|
import { getTileWarpXY, tileToBounds } from './utils/lonlat-tile';
|
||||||
|
|
||||||
type TileOptions = { x: number; y: number; z: number; tileSize: number };
|
|
||||||
|
|
||||||
export type TileLoadParams = TileOptions & {
|
|
||||||
bounds: Bounds;
|
|
||||||
signal: AbortSignal;
|
|
||||||
};
|
|
||||||
|
|
||||||
type TileLoadDataOptions = {
|
|
||||||
getData: (tile: TileLoadParams) => Promise<any>;
|
|
||||||
onLoad: (tile: Tile) => void;
|
|
||||||
onError: (error: Error, tile: Tile) => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum LoadTileDataStatus {
|
|
||||||
Loading = 'Loading',
|
|
||||||
Loaded = 'Loaded',
|
|
||||||
Failure = 'Failure',
|
|
||||||
Cancelled = 'Cancelled',
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单个瓦片
|
* 单个瓦片
|
||||||
* 负责瓦片数据加载、缓存数据、缓存图层
|
* 负责瓦片数据加载、缓存数据、缓存图层
|
||||||
|
@ -98,7 +83,7 @@ export class Tile {
|
||||||
const [minLng, minLat, maxLng, maxLat] = this.bounds;
|
const [minLng, minLat, maxLng, maxLat] = this.bounds;
|
||||||
const center = [(maxLng - minLng) / 2, (maxLat - minLat) / 2] as const;
|
const center = [(maxLng - minLng) / 2, (maxLat - minLat) / 2] as const;
|
||||||
|
|
||||||
const polygon = bboxPolygon(this.bounds as Bounds, {
|
const polygon = bboxPolygon(this.bounds as TileBounds, {
|
||||||
properties: {
|
properties: {
|
||||||
key: this.key,
|
key: this.key,
|
||||||
bbox: this.bounds,
|
bbox: this.bounds,
|
||||||
|
@ -158,7 +143,7 @@ export class Tile {
|
||||||
// 如果请求出错或数据为空
|
// 如果请求出错或数据为空
|
||||||
if (error || !tileData) {
|
if (error || !tileData) {
|
||||||
this.loadStatus = LoadTileDataStatus.Failure;
|
this.loadStatus = LoadTileDataStatus.Failure;
|
||||||
onError(error, this);
|
onError(error as Error, this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,20 +5,10 @@ import {
|
||||||
NOOP,
|
NOOP,
|
||||||
UPDATE_TILE_STRATEGIES,
|
UPDATE_TILE_STRATEGIES,
|
||||||
} from './const';
|
} from './const';
|
||||||
import { Tile, TileLoadParams } from './tile';
|
import { Tile } from './tile';
|
||||||
import { Bounds, UpdateTileStrategy } from './types';
|
import { TilesetManagerOptions, UpdateTileStrategy } from './types';
|
||||||
import { getTileIndices } from './utils/lonlat-tile';
|
import { getTileIndices } from './utils/lonlat-tile';
|
||||||
|
|
||||||
export type TilesetManagerOptions = {
|
|
||||||
tileSize: number;
|
|
||||||
zoomOffset: number;
|
|
||||||
minZoom: number;
|
|
||||||
maxZoom: number;
|
|
||||||
extent: Bounds;
|
|
||||||
getTileData: (tile: TileLoadParams) => any;
|
|
||||||
updateStrategy: UpdateTileStrategy | ((tiles: Tile[]) => void);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理瓦片数据
|
* 管理瓦片数据
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
import { Tile } from './tile';
|
||||||
|
|
||||||
// Bounds [minLng, minLat, maxLng, maxLat]
|
// Bounds [minLng, minLat, maxLng, maxLat]
|
||||||
export type Bounds = [number, number, number, number];
|
export type TileBounds = [number, number, number, number];
|
||||||
|
|
||||||
// 瓦片更新显示策略
|
// 瓦片更新显示策略
|
||||||
export enum UpdateTileStrategy {
|
export enum UpdateTileStrategy {
|
||||||
|
@ -8,3 +10,33 @@ export enum UpdateTileStrategy {
|
||||||
// 全部替换策略
|
// 全部替换策略
|
||||||
Replace = 'replace',
|
Replace = 'replace',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type TileOptions = { x: number; y: number; z: number; tileSize: number };
|
||||||
|
|
||||||
|
export type TileLoadParams = TileOptions & {
|
||||||
|
bounds: TileBounds;
|
||||||
|
signal: AbortSignal;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TileLoadDataOptions = {
|
||||||
|
getData: (tile: TileLoadParams) => Promise<any>;
|
||||||
|
onLoad: (tile: Tile) => void;
|
||||||
|
onError: (error: Error, tile: Tile) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export enum LoadTileDataStatus {
|
||||||
|
Loading = 'Loading',
|
||||||
|
Loaded = 'Loaded',
|
||||||
|
Failure = 'Failure',
|
||||||
|
Cancelled = 'Cancelled',
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TilesetManagerOptions = {
|
||||||
|
tileSize: number;
|
||||||
|
zoomOffset: number;
|
||||||
|
minZoom: number;
|
||||||
|
maxZoom: number;
|
||||||
|
extent: TileBounds;
|
||||||
|
getTileData: (tile: TileLoadParams) => any;
|
||||||
|
updateStrategy: UpdateTileStrategy | ((tiles: Tile[]) => void);
|
||||||
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { DEFAULT_EXTENT } from '../const';
|
import { DEFAULT_EXTENT } from '../const';
|
||||||
import { Bounds } from '../types';
|
import { TileBounds } from '../types';
|
||||||
|
|
||||||
// // https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#ECMAScript_.28JavaScript.2FActionScript.2C_etc..29
|
// // https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#ECMAScript_.28JavaScript.2FActionScript.2C_etc..29
|
||||||
export function osmLonLat2TileXY(lon: number, lat: number, zoom: number) {
|
export function osmLonLat2TileXY(lon: number, lat: number, zoom: number) {
|
||||||
|
@ -30,7 +30,7 @@ export function osmTileXY2LonLat(x: number, y: number, zoom: number) {
|
||||||
export const tileToBounds = (x: number, y: number, z: number) => {
|
export const tileToBounds = (x: number, y: number, z: number) => {
|
||||||
const [minLng, maxLat] = osmTileXY2LonLat(x, y, z);
|
const [minLng, maxLat] = osmTileXY2LonLat(x, y, z);
|
||||||
const [maxLng, minLat] = osmTileXY2LonLat(x + 1, y + 1, z);
|
const [maxLng, minLat] = osmTileXY2LonLat(x + 1, y + 1, z);
|
||||||
return [minLng, minLat, maxLng, maxLat] as Bounds;
|
return [minLng, minLat, maxLng, maxLat] as TileBounds;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,11 +49,11 @@ export function getTileIndices({
|
||||||
extent = DEFAULT_EXTENT,
|
extent = DEFAULT_EXTENT,
|
||||||
}: {
|
}: {
|
||||||
zoom: number;
|
zoom: number;
|
||||||
latLonBounds: Bounds;
|
latLonBounds: TileBounds;
|
||||||
maxZoom: number;
|
maxZoom: number;
|
||||||
minZoom: number;
|
minZoom: number;
|
||||||
zoomOffset: number;
|
zoomOffset: number;
|
||||||
extent: Bounds;
|
extent: TileBounds;
|
||||||
tileSize: number;
|
tileSize: number;
|
||||||
}) {
|
}) {
|
||||||
let z = Math.ceil(zoom) + zoomOffset;
|
let z = Math.ceil(zoom) + zoomOffset;
|
||||||
|
|
Loading…
Reference in New Issue