xy-map 1.1.59 → 1.1.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/xy-map.common.js +97 -19
- package/xy-map.umd.js +97 -19
- package/xy-map.umd.min.js +3 -3
package/package.json
CHANGED
package/xy-map.common.js
CHANGED
|
@@ -70779,20 +70779,29 @@ const gcj02ToWgs84 = coord => {
|
|
|
70779
70779
|
return [lng, lat];
|
|
70780
70780
|
}
|
|
70781
70781
|
|
|
70782
|
-
//
|
|
70783
|
-
let
|
|
70784
|
-
|
|
70785
|
-
let
|
|
70786
|
-
|
|
70787
|
-
|
|
70788
|
-
|
|
70789
|
-
|
|
70790
|
-
|
|
70791
|
-
|
|
70792
|
-
|
|
70793
|
-
|
|
70794
|
-
|
|
70795
|
-
|
|
70782
|
+
// 使用迭代法求解,提高迭代次数以增加精度
|
|
70783
|
+
let dLng = 0,
|
|
70784
|
+
dLat = 0;
|
|
70785
|
+
let mLng = lng,
|
|
70786
|
+
mLat = lat;
|
|
70787
|
+
|
|
70788
|
+
// 增加迭代次数到10次提高精度
|
|
70789
|
+
for (let i = 0; i < 10; i++) {
|
|
70790
|
+
// 使用wgs84ToGcj02获取当前估计值对应的gcj02坐标
|
|
70791
|
+
let [gcjLng, gcjLat] = wgs84ToGcj02([mLng, mLat]);
|
|
70792
|
+
// 计算差值
|
|
70793
|
+
dLng = gcjLng - lng;
|
|
70794
|
+
dLat = gcjLat - lat;
|
|
70795
|
+
// 更新估计值
|
|
70796
|
+
mLng = mLng - dLng;
|
|
70797
|
+
mLat = mLat - dLat;
|
|
70798
|
+
|
|
70799
|
+
// 如果精度已经足够高,提前退出循环
|
|
70800
|
+
if (Math.abs(dLng) < 0.000000001 && Math.abs(dLat) < 0.000000001) {
|
|
70801
|
+
break;
|
|
70802
|
+
}
|
|
70803
|
+
}
|
|
70804
|
+
return [mLng, mLat];
|
|
70796
70805
|
};
|
|
70797
70806
|
|
|
70798
70807
|
// 3857墨卡托坐标系转换为4326 (WGS84)经纬度坐标
|
|
@@ -72202,10 +72211,17 @@ const addLayerLine = (option, layerId) => {
|
|
|
72202
72211
|
if (opt.click) {
|
|
72203
72212
|
mapClick(opt.id, opt.click);
|
|
72204
72213
|
}
|
|
72214
|
+
|
|
72215
|
+
//添加动画
|
|
72205
72216
|
if (opt.animate) {
|
|
72206
72217
|
addLayerLineAnimation(opt, layerId);
|
|
72207
72218
|
}
|
|
72208
72219
|
|
|
72220
|
+
//添加虚线
|
|
72221
|
+
if (opt.dash) {
|
|
72222
|
+
addLayerLineDash(opt, layerId);
|
|
72223
|
+
}
|
|
72224
|
+
|
|
72209
72225
|
// 添加文本图层
|
|
72210
72226
|
if (opt.text && opt.text.show) {
|
|
72211
72227
|
addLayerText('line', opt, layerId);
|
|
@@ -72263,13 +72279,34 @@ const addLayerLineAnimation = (option, layerId) => {
|
|
|
72263
72279
|
opt.data.features.forEach(f => {
|
|
72264
72280
|
let coordinates = f.geometry.coordinates;
|
|
72265
72281
|
if (coordinates && coordinates.length > 0) {
|
|
72282
|
+
// 存储所有插值后的点坐标
|
|
72266
72283
|
let arc = [];
|
|
72267
|
-
//
|
|
72268
|
-
let
|
|
72269
|
-
|
|
72270
|
-
|
|
72271
|
-
|
|
72284
|
+
// 计算整条线的总长度(单位:公里)
|
|
72285
|
+
let length = es_length(f, 'kilometers');
|
|
72286
|
+
|
|
72287
|
+
// 遍历每个线段,进行插值计算
|
|
72288
|
+
for (let i = 0; i < coordinates.length - 1; i++) {
|
|
72289
|
+
const start = coordinates[i];
|
|
72290
|
+
const end = coordinates[i + 1];
|
|
72291
|
+
const lineSegment = lineString([start, end]);
|
|
72292
|
+
const segLength = es_length(lineSegment, 'kilometers');
|
|
72293
|
+
// 根据线段长度和总长度的比例,计算需要插入的点数
|
|
72294
|
+
const pointsToAdd = Math.floor(segLength / (length / step));
|
|
72295
|
+
|
|
72296
|
+
// 添加起始点
|
|
72297
|
+
arc.push(start);
|
|
72298
|
+
|
|
72299
|
+
// 在线段上进行插值,添加过渡点
|
|
72300
|
+
if (pointsToAdd > 1) {
|
|
72301
|
+
for (let j = 1; j < pointsToAdd; j++) {
|
|
72302
|
+
const fraction = j / pointsToAdd;
|
|
72303
|
+
const point = along(lineSegment, segLength * fraction, 'kilometers');
|
|
72304
|
+
arc.push(point.geometry.coordinates);
|
|
72305
|
+
}
|
|
72306
|
+
}
|
|
72272
72307
|
}
|
|
72308
|
+
// 添加线段的终点
|
|
72309
|
+
arc.push(coordinates[coordinates.length - 1]);
|
|
72273
72310
|
|
|
72274
72311
|
// 更新数据
|
|
72275
72312
|
let i = 0;
|
|
@@ -72292,6 +72329,47 @@ const addLayerLineAnimation = (option, layerId) => {
|
|
|
72292
72329
|
}
|
|
72293
72330
|
});
|
|
72294
72331
|
};
|
|
72332
|
+
|
|
72333
|
+
/**
|
|
72334
|
+
* 添加虚线图层
|
|
72335
|
+
*/
|
|
72336
|
+
const addLayerLineDash = (option, layerId) => {
|
|
72337
|
+
let {
|
|
72338
|
+
map
|
|
72339
|
+
} = package_map;
|
|
72340
|
+
let opt = option;
|
|
72341
|
+
let parentId = opt.id;
|
|
72342
|
+
let id = parentId + '-dash';
|
|
72343
|
+
if (hasLayer(id)) {
|
|
72344
|
+
setSource(id, opt.data);
|
|
72345
|
+
return;
|
|
72346
|
+
}
|
|
72347
|
+
let layout = opt.dash ? opt.dash.layout : {};
|
|
72348
|
+
let layoutOpt = Object.assign({
|
|
72349
|
+
'visibility': 'visible'
|
|
72350
|
+
}, layout);
|
|
72351
|
+
let paint = opt.dash ? opt.dash.paint : {};
|
|
72352
|
+
let paintOpt = Object.assign({
|
|
72353
|
+
'line-color': '#28b2ff',
|
|
72354
|
+
'line-dasharray': [4, 4],
|
|
72355
|
+
'line-width': 3,
|
|
72356
|
+
'line-opacity': 1
|
|
72357
|
+
}, paint);
|
|
72358
|
+
if (!hasSource(id)) {
|
|
72359
|
+
map.addSource(id, {
|
|
72360
|
+
type: 'geojson',
|
|
72361
|
+
data: opt.data
|
|
72362
|
+
});
|
|
72363
|
+
}
|
|
72364
|
+
map.addLayer({
|
|
72365
|
+
id: id,
|
|
72366
|
+
type: 'line',
|
|
72367
|
+
source: id,
|
|
72368
|
+
layout: layoutOpt,
|
|
72369
|
+
paint: paintOpt,
|
|
72370
|
+
...opt.other
|
|
72371
|
+
}, layerId);
|
|
72372
|
+
};
|
|
72295
72373
|
;// CONCATENATED MODULE: ./src/package/layers/Point.js
|
|
72296
72374
|
|
|
72297
72375
|
|
package/xy-map.umd.js
CHANGED
|
@@ -70797,20 +70797,29 @@ const gcj02ToWgs84 = coord => {
|
|
|
70797
70797
|
return [lng, lat];
|
|
70798
70798
|
}
|
|
70799
70799
|
|
|
70800
|
-
//
|
|
70801
|
-
let
|
|
70802
|
-
|
|
70803
|
-
let
|
|
70804
|
-
|
|
70805
|
-
|
|
70806
|
-
|
|
70807
|
-
|
|
70808
|
-
|
|
70809
|
-
|
|
70810
|
-
|
|
70811
|
-
|
|
70812
|
-
|
|
70813
|
-
|
|
70800
|
+
// 使用迭代法求解,提高迭代次数以增加精度
|
|
70801
|
+
let dLng = 0,
|
|
70802
|
+
dLat = 0;
|
|
70803
|
+
let mLng = lng,
|
|
70804
|
+
mLat = lat;
|
|
70805
|
+
|
|
70806
|
+
// 增加迭代次数到10次提高精度
|
|
70807
|
+
for (let i = 0; i < 10; i++) {
|
|
70808
|
+
// 使用wgs84ToGcj02获取当前估计值对应的gcj02坐标
|
|
70809
|
+
let [gcjLng, gcjLat] = wgs84ToGcj02([mLng, mLat]);
|
|
70810
|
+
// 计算差值
|
|
70811
|
+
dLng = gcjLng - lng;
|
|
70812
|
+
dLat = gcjLat - lat;
|
|
70813
|
+
// 更新估计值
|
|
70814
|
+
mLng = mLng - dLng;
|
|
70815
|
+
mLat = mLat - dLat;
|
|
70816
|
+
|
|
70817
|
+
// 如果精度已经足够高,提前退出循环
|
|
70818
|
+
if (Math.abs(dLng) < 0.000000001 && Math.abs(dLat) < 0.000000001) {
|
|
70819
|
+
break;
|
|
70820
|
+
}
|
|
70821
|
+
}
|
|
70822
|
+
return [mLng, mLat];
|
|
70814
70823
|
};
|
|
70815
70824
|
|
|
70816
70825
|
// 3857墨卡托坐标系转换为4326 (WGS84)经纬度坐标
|
|
@@ -72220,10 +72229,17 @@ const addLayerLine = (option, layerId) => {
|
|
|
72220
72229
|
if (opt.click) {
|
|
72221
72230
|
mapClick(opt.id, opt.click);
|
|
72222
72231
|
}
|
|
72232
|
+
|
|
72233
|
+
//添加动画
|
|
72223
72234
|
if (opt.animate) {
|
|
72224
72235
|
addLayerLineAnimation(opt, layerId);
|
|
72225
72236
|
}
|
|
72226
72237
|
|
|
72238
|
+
//添加虚线
|
|
72239
|
+
if (opt.dash) {
|
|
72240
|
+
addLayerLineDash(opt, layerId);
|
|
72241
|
+
}
|
|
72242
|
+
|
|
72227
72243
|
// 添加文本图层
|
|
72228
72244
|
if (opt.text && opt.text.show) {
|
|
72229
72245
|
addLayerText('line', opt, layerId);
|
|
@@ -72281,13 +72297,34 @@ const addLayerLineAnimation = (option, layerId) => {
|
|
|
72281
72297
|
opt.data.features.forEach(f => {
|
|
72282
72298
|
let coordinates = f.geometry.coordinates;
|
|
72283
72299
|
if (coordinates && coordinates.length > 0) {
|
|
72300
|
+
// 存储所有插值后的点坐标
|
|
72284
72301
|
let arc = [];
|
|
72285
|
-
//
|
|
72286
|
-
let
|
|
72287
|
-
|
|
72288
|
-
|
|
72289
|
-
|
|
72302
|
+
// 计算整条线的总长度(单位:公里)
|
|
72303
|
+
let length = es_length(f, 'kilometers');
|
|
72304
|
+
|
|
72305
|
+
// 遍历每个线段,进行插值计算
|
|
72306
|
+
for (let i = 0; i < coordinates.length - 1; i++) {
|
|
72307
|
+
const start = coordinates[i];
|
|
72308
|
+
const end = coordinates[i + 1];
|
|
72309
|
+
const lineSegment = lineString([start, end]);
|
|
72310
|
+
const segLength = es_length(lineSegment, 'kilometers');
|
|
72311
|
+
// 根据线段长度和总长度的比例,计算需要插入的点数
|
|
72312
|
+
const pointsToAdd = Math.floor(segLength / (length / step));
|
|
72313
|
+
|
|
72314
|
+
// 添加起始点
|
|
72315
|
+
arc.push(start);
|
|
72316
|
+
|
|
72317
|
+
// 在线段上进行插值,添加过渡点
|
|
72318
|
+
if (pointsToAdd > 1) {
|
|
72319
|
+
for (let j = 1; j < pointsToAdd; j++) {
|
|
72320
|
+
const fraction = j / pointsToAdd;
|
|
72321
|
+
const point = along(lineSegment, segLength * fraction, 'kilometers');
|
|
72322
|
+
arc.push(point.geometry.coordinates);
|
|
72323
|
+
}
|
|
72324
|
+
}
|
|
72290
72325
|
}
|
|
72326
|
+
// 添加线段的终点
|
|
72327
|
+
arc.push(coordinates[coordinates.length - 1]);
|
|
72291
72328
|
|
|
72292
72329
|
// 更新数据
|
|
72293
72330
|
let i = 0;
|
|
@@ -72310,6 +72347,47 @@ const addLayerLineAnimation = (option, layerId) => {
|
|
|
72310
72347
|
}
|
|
72311
72348
|
});
|
|
72312
72349
|
};
|
|
72350
|
+
|
|
72351
|
+
/**
|
|
72352
|
+
* 添加虚线图层
|
|
72353
|
+
*/
|
|
72354
|
+
const addLayerLineDash = (option, layerId) => {
|
|
72355
|
+
let {
|
|
72356
|
+
map
|
|
72357
|
+
} = package_map;
|
|
72358
|
+
let opt = option;
|
|
72359
|
+
let parentId = opt.id;
|
|
72360
|
+
let id = parentId + '-dash';
|
|
72361
|
+
if (hasLayer(id)) {
|
|
72362
|
+
setSource(id, opt.data);
|
|
72363
|
+
return;
|
|
72364
|
+
}
|
|
72365
|
+
let layout = opt.dash ? opt.dash.layout : {};
|
|
72366
|
+
let layoutOpt = Object.assign({
|
|
72367
|
+
'visibility': 'visible'
|
|
72368
|
+
}, layout);
|
|
72369
|
+
let paint = opt.dash ? opt.dash.paint : {};
|
|
72370
|
+
let paintOpt = Object.assign({
|
|
72371
|
+
'line-color': '#28b2ff',
|
|
72372
|
+
'line-dasharray': [4, 4],
|
|
72373
|
+
'line-width': 3,
|
|
72374
|
+
'line-opacity': 1
|
|
72375
|
+
}, paint);
|
|
72376
|
+
if (!hasSource(id)) {
|
|
72377
|
+
map.addSource(id, {
|
|
72378
|
+
type: 'geojson',
|
|
72379
|
+
data: opt.data
|
|
72380
|
+
});
|
|
72381
|
+
}
|
|
72382
|
+
map.addLayer({
|
|
72383
|
+
id: id,
|
|
72384
|
+
type: 'line',
|
|
72385
|
+
source: id,
|
|
72386
|
+
layout: layoutOpt,
|
|
72387
|
+
paint: paintOpt,
|
|
72388
|
+
...opt.other
|
|
72389
|
+
}, layerId);
|
|
72390
|
+
};
|
|
72313
72391
|
;// CONCATENATED MODULE: ./src/package/layers/Point.js
|
|
72314
72392
|
|
|
72315
72393
|
|