sctj-components 1.1.8 → 1.1.9
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/lib/sctj-components.es.js +77 -66
- package/lib/sctj-components.umd.js +1 -1
- package/lib/style.css +1 -1
- package/package.json +1 -1
|
@@ -5399,7 +5399,7 @@ const _sfc_main$8 = {
|
|
|
5399
5399
|
};
|
|
5400
5400
|
}
|
|
5401
5401
|
};
|
|
5402
|
-
const
|
|
5402
|
+
const index_vue_vue_type_style_index_0_scoped_c98dea1e_lang = "";
|
|
5403
5403
|
const _hoisted_1$6 = {
|
|
5404
5404
|
key: 0,
|
|
5405
5405
|
class: "action-container"
|
|
@@ -5491,8 +5491,8 @@ const _sfc_main$7 = {
|
|
|
5491
5491
|
setup(__props, { expose, emit }) {
|
|
5492
5492
|
const props = __props;
|
|
5493
5493
|
useCssVars((_ctx) => ({
|
|
5494
|
-
"
|
|
5495
|
-
"
|
|
5494
|
+
"0bc30804": __props.width,
|
|
5495
|
+
"2fe209ef": __props.height
|
|
5496
5496
|
}));
|
|
5497
5497
|
const controlsPositionVars = computed$1(() => {
|
|
5498
5498
|
const position = props.controlsPosition || {};
|
|
@@ -5519,6 +5519,7 @@ const _sfc_main$7 = {
|
|
|
5519
5519
|
const circleInstances = shallowRef([]);
|
|
5520
5520
|
const circleTextInstances = shallowRef([]);
|
|
5521
5521
|
const polygonTextInstances = shallowRef([]);
|
|
5522
|
+
const polylineTextInstances = shallowRef([]);
|
|
5522
5523
|
const typeVisibility = shallowRef(/* @__PURE__ */ new Map());
|
|
5523
5524
|
const overlayGroups = shallowRef(/* @__PURE__ */ new Map());
|
|
5524
5525
|
const isMoreLegend = ref$1(false);
|
|
@@ -5682,10 +5683,8 @@ const _sfc_main$7 = {
|
|
|
5682
5683
|
if (!map.value)
|
|
5683
5684
|
return;
|
|
5684
5685
|
map.value.on("zoomend", () => {
|
|
5685
|
-
updateTextVisibility();
|
|
5686
5686
|
});
|
|
5687
5687
|
map.value.on("moveend", () => {
|
|
5688
|
-
updateTextVisibility();
|
|
5689
5688
|
});
|
|
5690
5689
|
};
|
|
5691
5690
|
const clearMapEvents = () => {
|
|
@@ -5753,6 +5752,7 @@ const _sfc_main$7 = {
|
|
|
5753
5752
|
circleInstances.value = [];
|
|
5754
5753
|
circleTextInstances.value = [];
|
|
5755
5754
|
polygonTextInstances.value = [];
|
|
5755
|
+
polylineTextInstances.value = [];
|
|
5756
5756
|
typeVisibility.value.clear();
|
|
5757
5757
|
});
|
|
5758
5758
|
const initMap = async () => {
|
|
@@ -5909,6 +5909,41 @@ const _sfc_main$7 = {
|
|
|
5909
5909
|
}
|
|
5910
5910
|
return [sumX / path.length, sumY / path.length];
|
|
5911
5911
|
};
|
|
5912
|
+
const haversineDistance = (p1, p2) => {
|
|
5913
|
+
const R = 6371e3;
|
|
5914
|
+
const lat1 = p1[1] * Math.PI / 180;
|
|
5915
|
+
const lat2 = p2[1] * Math.PI / 180;
|
|
5916
|
+
const deltaLat = (p2[1] - p1[1]) * Math.PI / 180;
|
|
5917
|
+
const deltaLng = (p2[0] - p1[0]) * Math.PI / 180;
|
|
5918
|
+
const a = Math.sin(deltaLat / 2) * Math.sin(deltaLat / 2) + Math.cos(lat1) * Math.cos(lat2) * Math.sin(deltaLng / 2) * Math.sin(deltaLng / 2);
|
|
5919
|
+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
5920
|
+
return R * c;
|
|
5921
|
+
};
|
|
5922
|
+
const getPointOnPolylineByPercent = (path, percent = 0.5) => {
|
|
5923
|
+
if (!path || path.length === 0)
|
|
5924
|
+
return null;
|
|
5925
|
+
if (path.length === 1)
|
|
5926
|
+
return [path[0][0], path[0][1]];
|
|
5927
|
+
let totalLength = 0;
|
|
5928
|
+
const lengths = [];
|
|
5929
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
5930
|
+
const length = haversineDistance(path[i], path[i + 1]);
|
|
5931
|
+
lengths.push(length);
|
|
5932
|
+
totalLength += length;
|
|
5933
|
+
}
|
|
5934
|
+
const targetDistance = totalLength * percent;
|
|
5935
|
+
let accumulatedDistance = 0;
|
|
5936
|
+
for (let i = 0; i < lengths.length; i++) {
|
|
5937
|
+
if (targetDistance <= accumulatedDistance + lengths[i]) {
|
|
5938
|
+
const t = (targetDistance - accumulatedDistance) / lengths[i];
|
|
5939
|
+
const lng = path[i][0] + (path[i + 1][0] - path[i][0]) * t;
|
|
5940
|
+
const lat = path[i][1] + (path[i + 1][1] - path[i][1]) * t;
|
|
5941
|
+
return [lng, lat];
|
|
5942
|
+
}
|
|
5943
|
+
accumulatedDistance += lengths[i];
|
|
5944
|
+
}
|
|
5945
|
+
return [path[path.length - 1][0], path[path.length - 1][1]];
|
|
5946
|
+
};
|
|
5912
5947
|
const setLegend = () => {
|
|
5913
5948
|
legend.value = props.legendConfig.filter((item) => item.defaultVisible === void 0 || item.defaultVisible === true).map((item) => item.value);
|
|
5914
5949
|
handleLegendChange(legend.value);
|
|
@@ -5938,13 +5973,15 @@ const _sfc_main$7 = {
|
|
|
5938
5973
|
size: size ? new AMap.Size(size.width, size.height) : new AMap.Size(state.markerDefaultConfig.size.width, state.markerDefaultConfig.size.height),
|
|
5939
5974
|
offset: size ? new AMap.Pixel(-(size.width / 2), -size.height) : new AMap.Pixel(-(state.markerDefaultConfig.size.width / 2), -state.markerDefaultConfig.size.height),
|
|
5940
5975
|
map: map.value,
|
|
5941
|
-
title
|
|
5976
|
+
title,
|
|
5977
|
+
zooms: [16, 25]
|
|
5942
5978
|
});
|
|
5943
5979
|
blink && markerInstance.dom && markerInstance.dom.querySelector(".amap-icon").classList.add("blinking-marker");
|
|
5944
5980
|
label && markerInstance.setLabel({
|
|
5945
5981
|
direction: "top",
|
|
5946
5982
|
offset: new AMap.Pixel(0, -5),
|
|
5947
|
-
content: `<div title="${label}" style="${objectToStyleString({ ...state.textLabelDefaultStyle, ...textLabelDefaultStyle })}" class='info'>${label}</div
|
|
5983
|
+
content: `<div title="${label}" style="${objectToStyleString({ ...state.textLabelDefaultStyle, ...textLabelDefaultStyle })}" class='info'>${label}</div>`,
|
|
5984
|
+
zooms: [16, 25]
|
|
5948
5985
|
});
|
|
5949
5986
|
markerInstance.on("click", () => {
|
|
5950
5987
|
emit("overlay-click", { type: "staticMarker", data: marker });
|
|
@@ -5970,8 +6007,10 @@ const _sfc_main$7 = {
|
|
|
5970
6007
|
offset: size ? new AMap.Pixel(-(size.width / 2), -size.height) : new AMap.Pixel(-(state.markerDefaultConfig.size.width / 2), -state.markerDefaultConfig.size.height),
|
|
5971
6008
|
size: size ? new AMap.Size(size.width, size.height) : new AMap.Size(state.markerDefaultConfig.size.width, state.markerDefaultConfig.size.height),
|
|
5972
6009
|
map: map.value,
|
|
5973
|
-
title
|
|
6010
|
+
title,
|
|
6011
|
+
zooms: [16, 25]
|
|
5974
6012
|
});
|
|
6013
|
+
console.log("markerInstance", markerInstance);
|
|
5975
6014
|
blink && markerInstance.dom && markerInstance.dom.querySelector(".amap-icon").classList.add("blinking-marker");
|
|
5976
6015
|
label && markerInstance.setLabel({
|
|
5977
6016
|
direction: "top",
|
|
@@ -6011,7 +6050,7 @@ const _sfc_main$7 = {
|
|
|
6011
6050
|
},
|
|
6012
6051
|
offset: new AMap.Pixel(0, 0),
|
|
6013
6052
|
anchor: "center",
|
|
6014
|
-
zooms: [
|
|
6053
|
+
zooms: [16, 25]
|
|
6015
6054
|
});
|
|
6016
6055
|
map.value.add(textInstance);
|
|
6017
6056
|
circleTextInstances.value.push({
|
|
@@ -6056,6 +6095,29 @@ const _sfc_main$7 = {
|
|
|
6056
6095
|
path: parsePath(polyline.path),
|
|
6057
6096
|
map: map.value
|
|
6058
6097
|
});
|
|
6098
|
+
let textInstance = null;
|
|
6099
|
+
if (polyline.label) {
|
|
6100
|
+
const center = getPointOnPolylineByPercent(parsePath(polyline.path));
|
|
6101
|
+
textInstance = new AMap.Text({
|
|
6102
|
+
text: polyline.label,
|
|
6103
|
+
position: center,
|
|
6104
|
+
zIndex: 1,
|
|
6105
|
+
style: {
|
|
6106
|
+
...state.textLabelDefaultStyle,
|
|
6107
|
+
...polyline.labelStyle || {}
|
|
6108
|
+
},
|
|
6109
|
+
offset: new AMap.Pixel(0, 0),
|
|
6110
|
+
anchor: "center",
|
|
6111
|
+
zooms: [16, 25]
|
|
6112
|
+
});
|
|
6113
|
+
map.value.add(textInstance);
|
|
6114
|
+
polylineTextInstances.value.push({
|
|
6115
|
+
instance: textInstance,
|
|
6116
|
+
polygonId: parsePath(polyline.path).join("|"),
|
|
6117
|
+
polygonInstance: polylineInstance,
|
|
6118
|
+
path: parsePath(polyline.path)
|
|
6119
|
+
});
|
|
6120
|
+
}
|
|
6059
6121
|
polylineInstance.on("click", () => {
|
|
6060
6122
|
emit("overlay-click", { type: "polyline", data: polyline });
|
|
6061
6123
|
});
|
|
@@ -6105,7 +6167,7 @@ const _sfc_main$7 = {
|
|
|
6105
6167
|
},
|
|
6106
6168
|
offset: new AMap.Pixel(0, 0),
|
|
6107
6169
|
anchor: "center",
|
|
6108
|
-
zooms: [
|
|
6170
|
+
zooms: [16, 25]
|
|
6109
6171
|
});
|
|
6110
6172
|
map.value.add(textInstance);
|
|
6111
6173
|
polygonTextInstances.value.push({
|
|
@@ -6252,6 +6314,10 @@ const _sfc_main$7 = {
|
|
|
6252
6314
|
polyline.setMap(null);
|
|
6253
6315
|
});
|
|
6254
6316
|
polylineInstances.value = [];
|
|
6317
|
+
polylineTextInstances.value.forEach((textObj) => {
|
|
6318
|
+
textObj.instance.setMap(null);
|
|
6319
|
+
});
|
|
6320
|
+
polylineTextInstances.value = [];
|
|
6255
6321
|
};
|
|
6256
6322
|
const clearPolygons = () => {
|
|
6257
6323
|
polygonInstances.value.forEach((polygon) => {
|
|
@@ -6285,61 +6351,6 @@ const _sfc_main$7 = {
|
|
|
6285
6351
|
});
|
|
6286
6352
|
bezierCurveInstances.value = [];
|
|
6287
6353
|
};
|
|
6288
|
-
const updateTextVisibility = () => {
|
|
6289
|
-
if (!map.value)
|
|
6290
|
-
return;
|
|
6291
|
-
circleTextInstances.value.forEach((textObj) => {
|
|
6292
|
-
if (!textObj.circleInstance || !textObj.instance || !textObj.instance.dom)
|
|
6293
|
-
return;
|
|
6294
|
-
const center = textObj.circleInstance.getCenter();
|
|
6295
|
-
const radius = textObj.radius;
|
|
6296
|
-
const pixelRadius = getPixelDistance(center, radius);
|
|
6297
|
-
console.log("pixelRadius", pixelRadius);
|
|
6298
|
-
const labelWidth = textObj.instance.dom.getBoundingClientRect().width;
|
|
6299
|
-
if (labelWidth > pixelRadius * 1.5) {
|
|
6300
|
-
textObj.instance.dom.style.opacity = "0";
|
|
6301
|
-
} else {
|
|
6302
|
-
textObj.instance.dom.style.opacity = "1";
|
|
6303
|
-
}
|
|
6304
|
-
});
|
|
6305
|
-
polygonTextInstances.value.forEach((textObj) => {
|
|
6306
|
-
if (!textObj.polygonInstance || !textObj.instance || !textObj.instance.dom)
|
|
6307
|
-
return;
|
|
6308
|
-
const polygonPixelArea = getPolygonPixelArea(textObj.path);
|
|
6309
|
-
const labelWidth = textObj.instance.dom.offsetWidth;
|
|
6310
|
-
const labelHeight = textObj.instance.dom.offsetHeight;
|
|
6311
|
-
const labelArea = labelWidth * labelHeight;
|
|
6312
|
-
if (labelArea > polygonPixelArea * 0.3) {
|
|
6313
|
-
textObj.instance.dom.style.opacity = "0";
|
|
6314
|
-
} else {
|
|
6315
|
-
textObj.instance.dom.style.opacity = "1";
|
|
6316
|
-
}
|
|
6317
|
-
});
|
|
6318
|
-
};
|
|
6319
|
-
const getPixelDistance = (center, radiusInMeters) => {
|
|
6320
|
-
if (!map.value)
|
|
6321
|
-
return 0;
|
|
6322
|
-
const east = new AMap.LngLat(center.lng, center.lat).offset(radiusInMeters, 90);
|
|
6323
|
-
const centerPx = map.value.lngLatToContainer(center);
|
|
6324
|
-
const eastPx = map.value.lngLatToContainer(east);
|
|
6325
|
-
const dx = eastPx.x - centerPx.x;
|
|
6326
|
-
const dy = eastPx.y - centerPx.y;
|
|
6327
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
6328
|
-
};
|
|
6329
|
-
const getPolygonPixelArea = (path) => {
|
|
6330
|
-
if (!map.value || !path || path.length < 3)
|
|
6331
|
-
return 0;
|
|
6332
|
-
const pixelPath = path.map((point) => {
|
|
6333
|
-
const lngLat = new AMap.LngLat(point[0], point[1]);
|
|
6334
|
-
const pixel = map.value.lngLatToContainer(lngLat);
|
|
6335
|
-
return [pixel.x, pixel.y];
|
|
6336
|
-
});
|
|
6337
|
-
let area = 0;
|
|
6338
|
-
for (let i = 0, j = pixelPath.length - 1; i < pixelPath.length; j = i++) {
|
|
6339
|
-
area += (pixelPath[j][0] + pixelPath[i][0]) * (pixelPath[j][1] - pixelPath[i][1]);
|
|
6340
|
-
}
|
|
6341
|
-
return Math.abs(area / 2);
|
|
6342
|
-
};
|
|
6343
6354
|
expose({
|
|
6344
6355
|
fitView,
|
|
6345
6356
|
updateCenter,
|
|
@@ -6397,7 +6408,7 @@ const _sfc_main$7 = {
|
|
|
6397
6408
|
};
|
|
6398
6409
|
}
|
|
6399
6410
|
};
|
|
6400
|
-
const SCTJMapViewer = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-
|
|
6411
|
+
const SCTJMapViewer = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-c98dea1e"]]);
|
|
6401
6412
|
const index_vue_vue_type_style_index_0_scoped_761d2ab4_lang = "";
|
|
6402
6413
|
const _withScopeId$4 = (n) => (pushScopeId("data-v-761d2ab4"), n = n(), popScopeId(), n);
|
|
6403
6414
|
const _hoisted_1$5 = {
|