@octostar/map-component 0.8.0 → 0.8.1
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/dist/index.mjs +32 -28
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/dist/types/lib/custom-layer-stack.d.ts +8 -2
- package/dist/types/lib/custom-layer-stack.d.ts.map +1 -1
- package/dist/types/lib/feature-stack.d.ts.map +1 -1
- package/dist/types/lib/shard-pipeline.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1687,13 +1687,14 @@ function geometryClassesOf(features) {
|
|
|
1687
1687
|
const ROLES_BY_CLASS = {
|
|
1688
1688
|
polygon: ["polygon-fill", "polygon-stroke"],
|
|
1689
1689
|
line: ["line"],
|
|
1690
|
-
point: ["point-shadow", "point"
|
|
1690
|
+
point: ["point-shadow", "point"]
|
|
1691
1691
|
};
|
|
1692
|
-
function rolesForGeometry(classes) {
|
|
1692
|
+
function rolesForGeometry(classes, { icons = true } = {}) {
|
|
1693
1693
|
const needed = /* @__PURE__ */ new Set(["labels", "labels-pinned"]);
|
|
1694
1694
|
Object.keys(ROLES_BY_CLASS).forEach((cls) => {
|
|
1695
1695
|
if (classes.has(cls)) ROLES_BY_CLASS[cls].forEach((role) => needed.add(role));
|
|
1696
1696
|
});
|
|
1697
|
+
if (icons && classes.has("point")) needed.add("point-icon");
|
|
1697
1698
|
return CUSTOM_LAYER_ROLES.filter((role) => needed.has(role));
|
|
1698
1699
|
}
|
|
1699
1700
|
function shardInsertAnchor(role) {
|
|
@@ -2049,7 +2050,7 @@ function shardFingerprintsEqual(a, b) {
|
|
|
2049
2050
|
if (!a || !b) return false;
|
|
2050
2051
|
return Object.is(a.features, b.features) && Object.is(a.visualConfig, b.visualConfig) && Object.is(a.heatmapConfig, b.heatmapConfig) && Object.is(a.clusterConfig, b.clusterConfig) && Object.is(a.altitudeDisplayMode, b.altitudeDisplayMode) && Object.is(a.hasAltitudeData, b.hasAltitudeData) && Object.is(a.shardSize, b.shardSize);
|
|
2051
2052
|
}
|
|
2052
|
-
const INTERACTIVE_ROLES = ["point", "line", "polygon-fill"];
|
|
2053
|
+
const INTERACTIVE_ROLES = ["point", "point-icon", "line", "polygon-fill"];
|
|
2053
2054
|
const HOST_INTERACTIVE_ROLES = [...INTERACTIVE_ROLES, "host-icon"];
|
|
2054
2055
|
function createShardRegistry(host, hooks) {
|
|
2055
2056
|
const states = /* @__PURE__ */ new Map();
|
|
@@ -3096,17 +3097,19 @@ async function runShardPass(input) {
|
|
|
3096
3097
|
for (let index = 0; index < ranges.length; index++) {
|
|
3097
3098
|
const { start, end } = ranges[index];
|
|
3098
3099
|
const slice = features.slice(start, end);
|
|
3099
|
-
const roles = rolesForGeometry(geometryClassesOf(slice));
|
|
3100
3100
|
const ctx = input.contextForShard();
|
|
3101
3101
|
const shardArrows = [];
|
|
3102
|
+
let icons = false;
|
|
3102
3103
|
const painted = slice.map((f) => {
|
|
3103
|
-
var _a2;
|
|
3104
|
+
var _a2, _b2;
|
|
3104
3105
|
const styled = styleFeatureForPaint(f, layer, ctx, true);
|
|
3105
3106
|
if (((_a2 = styled.feature.properties) == null ? void 0 : _a2.kind) === "arrow" && styled.feature.geometry.type === "LineString") {
|
|
3106
3107
|
shardArrows.push(styled.feature);
|
|
3107
3108
|
}
|
|
3109
|
+
if (!icons && ((_b2 = styled.feature.properties) == null ? void 0 : _b2.icon)) icons = true;
|
|
3108
3110
|
return styled.feature;
|
|
3109
3111
|
});
|
|
3112
|
+
const roles = rolesForGeometry(geometryClassesOf(slice), { icons });
|
|
3110
3113
|
host.paintShard(index, roles, { type: "FeatureCollection", features: painted });
|
|
3111
3114
|
if (shardArrows.length > 0) pushAll$1(arrowLines, shardArrows);
|
|
3112
3115
|
(_a = input.onShardPainted) == null ? void 0 : _a.call(input, index, start, end);
|
|
@@ -10112,7 +10115,7 @@ function resolveTooltipFeature(rendered, lookup) {
|
|
|
10112
10115
|
}
|
|
10113
10116
|
const DEFAULT_POINT_RADIUS = 5;
|
|
10114
10117
|
const DEFAULT_ICON_SIZE = 24;
|
|
10115
|
-
const MAX_POINT_RADIUS =
|
|
10118
|
+
const MAX_POINT_RADIUS = 24;
|
|
10116
10119
|
const SAME_SPOT_PX = 1;
|
|
10117
10120
|
const CROWD = 16;
|
|
10118
10121
|
const SCAN_LIMIT = 256;
|
|
@@ -10124,7 +10127,6 @@ function paintedRadius(f) {
|
|
|
10124
10127
|
const hidden = ((_a = f.state) == null ? void 0 : _a[TIMELINE_HIDDEN_KEY]) === true || p.isHiddenByCluster === 1 || p.isHiddenByHeatmap === 1;
|
|
10125
10128
|
if (hidden) return 0;
|
|
10126
10129
|
if (typeof p.icon === "string" && p.icon !== "") {
|
|
10127
|
-
if (p[HOST_OWNED_PROP] !== 1) return 0;
|
|
10128
10130
|
return typeof p.iconSize === "number" && Number.isFinite(p.iconSize) ? p.iconSize / 2 : DEFAULT_ICON_SIZE / 2;
|
|
10129
10131
|
}
|
|
10130
10132
|
const r = ((_b = f.state) == null ? void 0 : _b[TRACE_ENDPOINT_KEY]) === true ? p._endpointRadius : p.pointRadius;
|
|
@@ -12823,13 +12825,33 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12823
12825
|
}
|
|
12824
12826
|
};
|
|
12825
12827
|
let pendingHover = null;
|
|
12828
|
+
const endHover = () => {
|
|
12829
|
+
mapInstance.getCanvas().style.cursor = "";
|
|
12830
|
+
const wasPolygon = lastHoveredGeomType === "Polygon" || lastHoveredGeomType === "MultiPolygon";
|
|
12831
|
+
lastHoveredFeatureKey = null;
|
|
12832
|
+
lastHoveredGeomType = null;
|
|
12833
|
+
if (tooltipShowTimeout) {
|
|
12834
|
+
clearTimeout(tooltipShowTimeout);
|
|
12835
|
+
tooltipShowTimeout = null;
|
|
12836
|
+
}
|
|
12837
|
+
if (wasPolygon) {
|
|
12838
|
+
hideTooltip2();
|
|
12839
|
+
} else {
|
|
12840
|
+
scheduleTooltipHide();
|
|
12841
|
+
}
|
|
12842
|
+
};
|
|
12826
12843
|
const flushHover = ({ e, hits, entered }) => {
|
|
12827
12844
|
if (hits.length === 0) return;
|
|
12828
12845
|
const order = mapInstance.getLayersOrder();
|
|
12829
12846
|
const z = (list) => order.indexOf(list[0].layer.id);
|
|
12830
12847
|
const all = hits.length === 1 ? hits[0] : [].concat(...[...hits].sort((a, b) => z(b) - z(a)));
|
|
12831
12848
|
const hover = stackFromHits(e.point, all);
|
|
12832
|
-
if (
|
|
12849
|
+
if (hover.features.length === 0) {
|
|
12850
|
+
if (lastHoveredFeatureKey !== null) endHover();
|
|
12851
|
+
return;
|
|
12852
|
+
}
|
|
12853
|
+
mapInstance.getCanvas().style.cursor = "pointer";
|
|
12854
|
+
if (entered && stackKey(hover) !== lastHoveredFeatureKey) showTooltipForFeatures(e, hover);
|
|
12833
12855
|
else moveTooltip(e, hover);
|
|
12834
12856
|
};
|
|
12835
12857
|
const collectHover = (e, entered) => {
|
|
@@ -12844,27 +12866,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12844
12866
|
};
|
|
12845
12867
|
const bindHoverHandlers = (layerId) => {
|
|
12846
12868
|
if (hoverHandlersByLayer.has(layerId)) return;
|
|
12847
|
-
const onMouseEnter = (e) =>
|
|
12848
|
-
mapInstance.getCanvas().style.cursor = "pointer";
|
|
12849
|
-
collectHover(e, true);
|
|
12850
|
-
};
|
|
12869
|
+
const onMouseEnter = (e) => collectHover(e, true);
|
|
12851
12870
|
const onMouseMove = (e) => collectHover(e, false);
|
|
12852
|
-
const
|
|
12853
|
-
mapInstance.getCanvas().style.cursor = "";
|
|
12854
|
-
const wasPolygon = lastHoveredGeomType === "Polygon" || lastHoveredGeomType === "MultiPolygon";
|
|
12855
|
-
lastHoveredFeatureKey = null;
|
|
12856
|
-
lastHoveredGeomType = null;
|
|
12857
|
-
if (tooltipShowTimeout) {
|
|
12858
|
-
clearTimeout(tooltipShowTimeout);
|
|
12859
|
-
tooltipShowTimeout = null;
|
|
12860
|
-
}
|
|
12861
|
-
if (wasPolygon) {
|
|
12862
|
-
hideTooltip2();
|
|
12863
|
-
} else {
|
|
12864
|
-
scheduleTooltipHide();
|
|
12865
|
-
}
|
|
12866
|
-
};
|
|
12867
|
-
const handlers = { mouseenter: onMouseEnter, mousemove: onMouseMove, mouseleave: onMouseLeave };
|
|
12871
|
+
const handlers = { mouseenter: onMouseEnter, mousemove: onMouseMove, mouseleave: endHover };
|
|
12868
12872
|
hoverHandlersByLayer.set(layerId, handlers);
|
|
12869
12873
|
mapInstance.on("mouseenter", layerId, handlers.mouseenter);
|
|
12870
12874
|
mapInstance.on("mousemove", layerId, handlers.mousemove);
|