xy-cesium3 0.0.64 → 0.0.65

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xy-cesium3",
3
- "version": "0.0.64",
3
+ "version": "0.0.65",
4
4
  "description": "雄越cesium3",
5
5
  "main": "xy-cesium3.umd.js",
6
6
  "scripts": {
package/xy-cesium3.es.js CHANGED
@@ -1789,6 +1789,8 @@ const computePolyLineCenter = (lglt = []) => {
1789
1789
  var coordinates = lglt.map((item2) => {
1790
1790
  return [item2[0], item2[1]];
1791
1791
  });
1792
+ if (!coordinates || coordinates.length < 2)
1793
+ return;
1792
1794
  var lineString$1 = lineString(coordinates);
1793
1795
  var totalLength = length(lineString$1, { units: "kilometers" });
1794
1796
  var midPoint = along(lineString$1, totalLength / 2, { units: "kilometers" });
@@ -1804,6 +1806,8 @@ const computePolygonCenter = (lglt = []) => {
1804
1806
  var coordinates = lglt.map((item2) => {
1805
1807
  return [item2[0], item2[1]];
1806
1808
  });
1809
+ if (!coordinates || coordinates.length < 3)
1810
+ return;
1807
1811
  let polygon$1 = polygon([coordinates]);
1808
1812
  let center2 = centerOfMass(polygon$1);
1809
1813
  var midPointCoords = center2.geometry.coordinates;
@@ -8922,11 +8926,14 @@ const addEntityPolygon = (viewer2, option) => {
8922
8926
  });
8923
8927
  dataSource.entities.add(entity);
8924
8928
  if (labelStyle.show) {
8925
- let position2 = computePolygonCenter(item2[props2.lglt]);
8929
+ const center2 = Cesium.BoundingSphere.fromPoints(polygonPositions).center;
8930
+ const centerCartographic = Cesium.Cartographic.fromCartesian(center2);
8931
+ const centerLon = Cesium.Math.toDegrees(centerCartographic.longitude);
8932
+ const centerLat = Cesium.Math.toDegrees(centerCartographic.latitude);
8926
8933
  let label = {
8927
8934
  name: "polygon_text_" + item2.id,
8928
8935
  show: show2,
8929
- position: position2,
8936
+ position: Cesium.Cartesian3.fromDegrees(centerLon, centerLat, 0),
8930
8937
  label: Object.assign({
8931
8938
  text: item2[props2.name],
8932
8939
  font: "12px Helvetica",