xy-map 1.1.14 → 1.1.15
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 +2 -2
- package/xy-map.common.js +116 -4
- package/xy-map.umd.js +116 -4
- package/xy-map.umd.min.js +1 -1
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xy-map",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.15",
|
|
4
4
|
"description": "雄越地图",
|
|
5
5
|
"main": "xy-map.umd.min.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"pub": "npm publish"
|
|
8
8
|
},
|
|
9
9
|
"keywords": [],
|
|
10
|
-
"author": "",
|
|
10
|
+
"author": "hanjing",
|
|
11
11
|
"license": "ISC"
|
|
12
12
|
}
|
package/xy-map.common.js
CHANGED
|
@@ -48283,6 +48283,24 @@ const toGeoJson = (list, type, props = 'position') => {
|
|
|
48283
48283
|
return data;
|
|
48284
48284
|
};
|
|
48285
48285
|
|
|
48286
|
+
// 点坐标转geoJson
|
|
48287
|
+
const pointToGeoJson = (position = [0, 0]) => {
|
|
48288
|
+
let pointsData = {
|
|
48289
|
+
id: Date.now().toString(),
|
|
48290
|
+
type: 'Feature',
|
|
48291
|
+
geometry: {
|
|
48292
|
+
type: 'Point',
|
|
48293
|
+
coordinates: position
|
|
48294
|
+
},
|
|
48295
|
+
properties: {}
|
|
48296
|
+
};
|
|
48297
|
+
let data = {
|
|
48298
|
+
type: 'FeatureCollection',
|
|
48299
|
+
features: [pointsData]
|
|
48300
|
+
};
|
|
48301
|
+
return data;
|
|
48302
|
+
};
|
|
48303
|
+
|
|
48286
48304
|
/**
|
|
48287
48305
|
* 加载图片
|
|
48288
48306
|
*/
|
|
@@ -48453,6 +48471,7 @@ const Point_defaultOptions = {
|
|
|
48453
48471
|
},
|
|
48454
48472
|
click: null
|
|
48455
48473
|
};
|
|
48474
|
+
let clock = null;
|
|
48456
48475
|
|
|
48457
48476
|
/**
|
|
48458
48477
|
* 添加点图层
|
|
@@ -48522,6 +48541,97 @@ const addLayerPoint = (option, layerId) => {
|
|
|
48522
48541
|
}
|
|
48523
48542
|
};
|
|
48524
48543
|
|
|
48544
|
+
/**
|
|
48545
|
+
* 添加闪烁点图层
|
|
48546
|
+
*/
|
|
48547
|
+
const addFlashPoint = (option = {
|
|
48548
|
+
id: 'flash',
|
|
48549
|
+
position: [],
|
|
48550
|
+
timer: 3000,
|
|
48551
|
+
// 闪烁时间
|
|
48552
|
+
size: 140,
|
|
48553
|
+
// 大小
|
|
48554
|
+
layerId // 层级
|
|
48555
|
+
}) => {
|
|
48556
|
+
// 点
|
|
48557
|
+
let {
|
|
48558
|
+
map
|
|
48559
|
+
} = package_map;
|
|
48560
|
+
const size = option.size;
|
|
48561
|
+
const pulsingDot = {
|
|
48562
|
+
width: size,
|
|
48563
|
+
height: size,
|
|
48564
|
+
data: new Uint8Array(size * size * 4),
|
|
48565
|
+
onAdd: function () {
|
|
48566
|
+
const canvas = document.createElement('canvas');
|
|
48567
|
+
canvas.width = this.width;
|
|
48568
|
+
canvas.height = this.height;
|
|
48569
|
+
this.context = canvas.getContext('2d');
|
|
48570
|
+
},
|
|
48571
|
+
render: function () {
|
|
48572
|
+
const duration = 1000;
|
|
48573
|
+
const t = performance.now() % duration / duration;
|
|
48574
|
+
const radius = size / 2 * 0.3;
|
|
48575
|
+
const outerRadius = size / 2 * 0.5 * t + radius;
|
|
48576
|
+
const context = this.context;
|
|
48577
|
+
|
|
48578
|
+
// Draw the outer circle.
|
|
48579
|
+
context.clearRect(0, 0, this.width, this.height);
|
|
48580
|
+
context.beginPath();
|
|
48581
|
+
context.arc(this.width / 2, this.height / 2, outerRadius, 0, Math.PI * 2);
|
|
48582
|
+
context.fillStyle = `rgba(255, 255, 255, ${1 - t})`;
|
|
48583
|
+
context.fill();
|
|
48584
|
+
|
|
48585
|
+
// Draw the inner circle.
|
|
48586
|
+
context.beginPath();
|
|
48587
|
+
context.arc(this.width / 2, this.height / 2, radius, 0, Math.PI * 2);
|
|
48588
|
+
context.fillStyle = 'rgba(255, 100, 100, 1)';
|
|
48589
|
+
context.strokeStyle = 'white';
|
|
48590
|
+
context.lineWidth = 2 + 4 * (1 - t);
|
|
48591
|
+
context.fill();
|
|
48592
|
+
context.stroke();
|
|
48593
|
+
|
|
48594
|
+
// Update this image's data with data from the canvas.
|
|
48595
|
+
this.data = context.getImageData(0, 0, this.width, this.height).data;
|
|
48596
|
+
map.triggerRepaint();
|
|
48597
|
+
return true;
|
|
48598
|
+
}
|
|
48599
|
+
};
|
|
48600
|
+
|
|
48601
|
+
// 添加自定义图标
|
|
48602
|
+
const imgId = 'pulsing-dot-' + option.id;
|
|
48603
|
+
if (!map.hasImage(imgId)) {
|
|
48604
|
+
map.addImage(imgId, pulsingDot, {
|
|
48605
|
+
pixelRatio: 2
|
|
48606
|
+
}); // 2倍屏分辨率
|
|
48607
|
+
}
|
|
48608
|
+
|
|
48609
|
+
const opt = {
|
|
48610
|
+
id: option.id,
|
|
48611
|
+
data: option.data,
|
|
48612
|
+
style: {
|
|
48613
|
+
layout: {
|
|
48614
|
+
'icon-image': imgId
|
|
48615
|
+
},
|
|
48616
|
+
paint: {
|
|
48617
|
+
'text-opacity': 0
|
|
48618
|
+
}
|
|
48619
|
+
}
|
|
48620
|
+
};
|
|
48621
|
+
if (hasLayer(opt.id)) {
|
|
48622
|
+
setSource(opt.id, opt.data);
|
|
48623
|
+
} else {
|
|
48624
|
+
addDiyPoint(opt, option.layerId);
|
|
48625
|
+
}
|
|
48626
|
+
if (option.timer > 0) {
|
|
48627
|
+
window.clearInterval(clock);
|
|
48628
|
+
clock = window.setInterval(() => {
|
|
48629
|
+
map.removeImage(imgId);
|
|
48630
|
+
window.clearInterval(clock);
|
|
48631
|
+
}, option.timer);
|
|
48632
|
+
}
|
|
48633
|
+
};
|
|
48634
|
+
|
|
48525
48635
|
/**
|
|
48526
48636
|
* 添加自定义点图层
|
|
48527
48637
|
*/
|
|
@@ -48547,13 +48657,13 @@ const addDiyPoint = (option, layerId) => {
|
|
|
48547
48657
|
// 该属性表示文本偏移锚点的距离,正值表示向右和向下,负值表示向左和向上
|
|
48548
48658
|
'text-anchor': 'top',
|
|
48549
48659
|
// 图标与锚点的位置关系
|
|
48550
|
-
'icon-allow-overlap':
|
|
48660
|
+
'icon-allow-overlap': true,
|
|
48551
48661
|
// 是否允许图标重叠
|
|
48552
|
-
'icon-ignore-placement':
|
|
48662
|
+
'icon-ignore-placement': true,
|
|
48553
48663
|
// 是否忽略图标位置(可选,默认值为 false。当值为 true 时,其他符号即使与此图标触碰也会显示)
|
|
48554
|
-
'text-allow-overlap':
|
|
48664
|
+
'text-allow-overlap': true,
|
|
48555
48665
|
// 是否允许文本重叠(可选,默认值为 false。当值为 true 时,文本即使和其他符号触碰也会显示)
|
|
48556
|
-
'text-ignore-placement':
|
|
48666
|
+
'text-ignore-placement': true,
|
|
48557
48667
|
// 是否忽略文本位置(可选,默认值为 false。当值为 true 时,其他符号即使与此文本触碰也会显示)
|
|
48558
48668
|
// 'text-max-width': 12, // 文本宽度
|
|
48559
48669
|
'visibility': 'visible'
|
|
@@ -59402,6 +59512,7 @@ const mapDraw = {
|
|
|
59402
59512
|
addLayerLineAnimation: addLayerLineAnimation,
|
|
59403
59513
|
addLayerPoint: addLayerPoint,
|
|
59404
59514
|
addDiyPoint: addDiyPoint,
|
|
59515
|
+
addFlashPoint: addFlashPoint,
|
|
59405
59516
|
addLayerImagePoint: addLayerImagePoint,
|
|
59406
59517
|
addLayerPolygon: addLayerPolygon,
|
|
59407
59518
|
addLayerCircle: addLayerCircle,
|
|
@@ -59412,6 +59523,7 @@ const mapDraw = {
|
|
|
59412
59523
|
// 地图工具
|
|
59413
59524
|
const mapTools = {
|
|
59414
59525
|
toGeoJson: toGeoJson,
|
|
59526
|
+
pointToGeoJson: pointToGeoJson,
|
|
59415
59527
|
loadImage: loadImage,
|
|
59416
59528
|
ranging: ranging,
|
|
59417
59529
|
drawArea: drawArea,
|
package/xy-map.umd.js
CHANGED
|
@@ -48301,6 +48301,24 @@ const toGeoJson = (list, type, props = 'position') => {
|
|
|
48301
48301
|
return data;
|
|
48302
48302
|
};
|
|
48303
48303
|
|
|
48304
|
+
// 点坐标转geoJson
|
|
48305
|
+
const pointToGeoJson = (position = [0, 0]) => {
|
|
48306
|
+
let pointsData = {
|
|
48307
|
+
id: Date.now().toString(),
|
|
48308
|
+
type: 'Feature',
|
|
48309
|
+
geometry: {
|
|
48310
|
+
type: 'Point',
|
|
48311
|
+
coordinates: position
|
|
48312
|
+
},
|
|
48313
|
+
properties: {}
|
|
48314
|
+
};
|
|
48315
|
+
let data = {
|
|
48316
|
+
type: 'FeatureCollection',
|
|
48317
|
+
features: [pointsData]
|
|
48318
|
+
};
|
|
48319
|
+
return data;
|
|
48320
|
+
};
|
|
48321
|
+
|
|
48304
48322
|
/**
|
|
48305
48323
|
* 加载图片
|
|
48306
48324
|
*/
|
|
@@ -48471,6 +48489,7 @@ const Point_defaultOptions = {
|
|
|
48471
48489
|
},
|
|
48472
48490
|
click: null
|
|
48473
48491
|
};
|
|
48492
|
+
let clock = null;
|
|
48474
48493
|
|
|
48475
48494
|
/**
|
|
48476
48495
|
* 添加点图层
|
|
@@ -48540,6 +48559,97 @@ const addLayerPoint = (option, layerId) => {
|
|
|
48540
48559
|
}
|
|
48541
48560
|
};
|
|
48542
48561
|
|
|
48562
|
+
/**
|
|
48563
|
+
* 添加闪烁点图层
|
|
48564
|
+
*/
|
|
48565
|
+
const addFlashPoint = (option = {
|
|
48566
|
+
id: 'flash',
|
|
48567
|
+
position: [],
|
|
48568
|
+
timer: 3000,
|
|
48569
|
+
// 闪烁时间
|
|
48570
|
+
size: 140,
|
|
48571
|
+
// 大小
|
|
48572
|
+
layerId // 层级
|
|
48573
|
+
}) => {
|
|
48574
|
+
// 点
|
|
48575
|
+
let {
|
|
48576
|
+
map
|
|
48577
|
+
} = package_map;
|
|
48578
|
+
const size = option.size;
|
|
48579
|
+
const pulsingDot = {
|
|
48580
|
+
width: size,
|
|
48581
|
+
height: size,
|
|
48582
|
+
data: new Uint8Array(size * size * 4),
|
|
48583
|
+
onAdd: function () {
|
|
48584
|
+
const canvas = document.createElement('canvas');
|
|
48585
|
+
canvas.width = this.width;
|
|
48586
|
+
canvas.height = this.height;
|
|
48587
|
+
this.context = canvas.getContext('2d');
|
|
48588
|
+
},
|
|
48589
|
+
render: function () {
|
|
48590
|
+
const duration = 1000;
|
|
48591
|
+
const t = performance.now() % duration / duration;
|
|
48592
|
+
const radius = size / 2 * 0.3;
|
|
48593
|
+
const outerRadius = size / 2 * 0.5 * t + radius;
|
|
48594
|
+
const context = this.context;
|
|
48595
|
+
|
|
48596
|
+
// Draw the outer circle.
|
|
48597
|
+
context.clearRect(0, 0, this.width, this.height);
|
|
48598
|
+
context.beginPath();
|
|
48599
|
+
context.arc(this.width / 2, this.height / 2, outerRadius, 0, Math.PI * 2);
|
|
48600
|
+
context.fillStyle = `rgba(255, 255, 255, ${1 - t})`;
|
|
48601
|
+
context.fill();
|
|
48602
|
+
|
|
48603
|
+
// Draw the inner circle.
|
|
48604
|
+
context.beginPath();
|
|
48605
|
+
context.arc(this.width / 2, this.height / 2, radius, 0, Math.PI * 2);
|
|
48606
|
+
context.fillStyle = 'rgba(255, 100, 100, 1)';
|
|
48607
|
+
context.strokeStyle = 'white';
|
|
48608
|
+
context.lineWidth = 2 + 4 * (1 - t);
|
|
48609
|
+
context.fill();
|
|
48610
|
+
context.stroke();
|
|
48611
|
+
|
|
48612
|
+
// Update this image's data with data from the canvas.
|
|
48613
|
+
this.data = context.getImageData(0, 0, this.width, this.height).data;
|
|
48614
|
+
map.triggerRepaint();
|
|
48615
|
+
return true;
|
|
48616
|
+
}
|
|
48617
|
+
};
|
|
48618
|
+
|
|
48619
|
+
// 添加自定义图标
|
|
48620
|
+
const imgId = 'pulsing-dot-' + option.id;
|
|
48621
|
+
if (!map.hasImage(imgId)) {
|
|
48622
|
+
map.addImage(imgId, pulsingDot, {
|
|
48623
|
+
pixelRatio: 2
|
|
48624
|
+
}); // 2倍屏分辨率
|
|
48625
|
+
}
|
|
48626
|
+
|
|
48627
|
+
const opt = {
|
|
48628
|
+
id: option.id,
|
|
48629
|
+
data: option.data,
|
|
48630
|
+
style: {
|
|
48631
|
+
layout: {
|
|
48632
|
+
'icon-image': imgId
|
|
48633
|
+
},
|
|
48634
|
+
paint: {
|
|
48635
|
+
'text-opacity': 0
|
|
48636
|
+
}
|
|
48637
|
+
}
|
|
48638
|
+
};
|
|
48639
|
+
if (hasLayer(opt.id)) {
|
|
48640
|
+
setSource(opt.id, opt.data);
|
|
48641
|
+
} else {
|
|
48642
|
+
addDiyPoint(opt, option.layerId);
|
|
48643
|
+
}
|
|
48644
|
+
if (option.timer > 0) {
|
|
48645
|
+
window.clearInterval(clock);
|
|
48646
|
+
clock = window.setInterval(() => {
|
|
48647
|
+
map.removeImage(imgId);
|
|
48648
|
+
window.clearInterval(clock);
|
|
48649
|
+
}, option.timer);
|
|
48650
|
+
}
|
|
48651
|
+
};
|
|
48652
|
+
|
|
48543
48653
|
/**
|
|
48544
48654
|
* 添加自定义点图层
|
|
48545
48655
|
*/
|
|
@@ -48565,13 +48675,13 @@ const addDiyPoint = (option, layerId) => {
|
|
|
48565
48675
|
// 该属性表示文本偏移锚点的距离,正值表示向右和向下,负值表示向左和向上
|
|
48566
48676
|
'text-anchor': 'top',
|
|
48567
48677
|
// 图标与锚点的位置关系
|
|
48568
|
-
'icon-allow-overlap':
|
|
48678
|
+
'icon-allow-overlap': true,
|
|
48569
48679
|
// 是否允许图标重叠
|
|
48570
|
-
'icon-ignore-placement':
|
|
48680
|
+
'icon-ignore-placement': true,
|
|
48571
48681
|
// 是否忽略图标位置(可选,默认值为 false。当值为 true 时,其他符号即使与此图标触碰也会显示)
|
|
48572
|
-
'text-allow-overlap':
|
|
48682
|
+
'text-allow-overlap': true,
|
|
48573
48683
|
// 是否允许文本重叠(可选,默认值为 false。当值为 true 时,文本即使和其他符号触碰也会显示)
|
|
48574
|
-
'text-ignore-placement':
|
|
48684
|
+
'text-ignore-placement': true,
|
|
48575
48685
|
// 是否忽略文本位置(可选,默认值为 false。当值为 true 时,其他符号即使与此文本触碰也会显示)
|
|
48576
48686
|
// 'text-max-width': 12, // 文本宽度
|
|
48577
48687
|
'visibility': 'visible'
|
|
@@ -59420,6 +59530,7 @@ const mapDraw = {
|
|
|
59420
59530
|
addLayerLineAnimation: addLayerLineAnimation,
|
|
59421
59531
|
addLayerPoint: addLayerPoint,
|
|
59422
59532
|
addDiyPoint: addDiyPoint,
|
|
59533
|
+
addFlashPoint: addFlashPoint,
|
|
59423
59534
|
addLayerImagePoint: addLayerImagePoint,
|
|
59424
59535
|
addLayerPolygon: addLayerPolygon,
|
|
59425
59536
|
addLayerCircle: addLayerCircle,
|
|
@@ -59430,6 +59541,7 @@ const mapDraw = {
|
|
|
59430
59541
|
// 地图工具
|
|
59431
59542
|
const mapTools = {
|
|
59432
59543
|
toGeoJson: toGeoJson,
|
|
59544
|
+
pointToGeoJson: pointToGeoJson,
|
|
59433
59545
|
loadImage: loadImage,
|
|
59434
59546
|
ranging: ranging,
|
|
59435
59547
|
drawArea: drawArea,
|