@classic-homes/maps-core 0.2.4 → 0.2.6
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.cjs +456 -48
- package/dist/index.d.cts +307 -46
- package/dist/index.d.ts +307 -46
- package/dist/index.js +447 -44
- package/package.json +1 -1
- package/src/styles/utilities.css +22 -0
package/dist/index.cjs
CHANGED
|
@@ -1469,49 +1469,6 @@ function filterByGeometryType(geojson, types) {
|
|
|
1469
1469
|
};
|
|
1470
1470
|
}
|
|
1471
1471
|
|
|
1472
|
-
// src/utils/positioning.ts
|
|
1473
|
-
var BASE_OFFSET = 8;
|
|
1474
|
-
var POSITION_CLASSES = {
|
|
1475
|
-
"top-left": "top-2 left-2",
|
|
1476
|
-
"top-right": "top-2 right-2",
|
|
1477
|
-
"bottom-left": "bottom-2 left-2",
|
|
1478
|
-
"bottom-right": "bottom-2 right-2"
|
|
1479
|
-
};
|
|
1480
|
-
var OFFSET_CLASSES = {
|
|
1481
|
-
"top-left": "left-14",
|
|
1482
|
-
// Offset right (toward center)
|
|
1483
|
-
"top-right": "right-14",
|
|
1484
|
-
// Offset left (toward center)
|
|
1485
|
-
"bottom-left": "left-14",
|
|
1486
|
-
// Offset right (toward center)
|
|
1487
|
-
"bottom-right": "right-14"
|
|
1488
|
-
// Offset left (toward center)
|
|
1489
|
-
};
|
|
1490
|
-
function computePositionClasses(position, hasControlsAtPosition) {
|
|
1491
|
-
const base = POSITION_CLASSES[position];
|
|
1492
|
-
if (!hasControlsAtPosition) {
|
|
1493
|
-
return base;
|
|
1494
|
-
}
|
|
1495
|
-
const offset = OFFSET_CLASSES[position];
|
|
1496
|
-
if (position.includes("left")) {
|
|
1497
|
-
return base.replace("left-2", offset);
|
|
1498
|
-
}
|
|
1499
|
-
if (position.includes("right")) {
|
|
1500
|
-
return base.replace("right-2", offset);
|
|
1501
|
-
}
|
|
1502
|
-
return base;
|
|
1503
|
-
}
|
|
1504
|
-
function computeVerticalOffsetStyle(position, customControlOffset, baseOffset = BASE_OFFSET) {
|
|
1505
|
-
if (customControlOffset <= 0) {
|
|
1506
|
-
return {};
|
|
1507
|
-
}
|
|
1508
|
-
const totalOffset = `${baseOffset + customControlOffset}px`;
|
|
1509
|
-
if (position.includes("top")) {
|
|
1510
|
-
return { top: totalOffset };
|
|
1511
|
-
}
|
|
1512
|
-
return { bottom: totalOffset };
|
|
1513
|
-
}
|
|
1514
|
-
|
|
1515
1472
|
// src/utils/cluster.ts
|
|
1516
1473
|
function isClusterFeature(feature) {
|
|
1517
1474
|
return feature.properties !== null && feature.properties !== void 0 && typeof feature.properties === "object" && "cluster_id" in feature.properties && "point_count" in feature.properties;
|
|
@@ -3191,6 +3148,34 @@ function applyMarkerChildProtection(element) {
|
|
|
3191
3148
|
}
|
|
3192
3149
|
|
|
3193
3150
|
// src/basemaps/registry.ts
|
|
3151
|
+
var DEFAULT_BASEMAP = {
|
|
3152
|
+
id: "default",
|
|
3153
|
+
name: "Default",
|
|
3154
|
+
provider: "maptiler",
|
|
3155
|
+
category: "minimal",
|
|
3156
|
+
style: "https://api.maptiler.com/maps/019c0bd2-b70f-78c1-a129-6b471a6c2d93/style.json?key=DfdiXzki9UFQMr3alBEe",
|
|
3157
|
+
thumbnail: "https://api.maptiler.com/maps/positron/256/0/0/0.png?key=DfdiXzki9UFQMr3alBEe",
|
|
3158
|
+
requiresApiKey: false
|
|
3159
|
+
// Key is embedded in the style URL
|
|
3160
|
+
};
|
|
3161
|
+
var SATELLITE_BASEMAP = {
|
|
3162
|
+
id: "satellite",
|
|
3163
|
+
name: "Satellite",
|
|
3164
|
+
provider: "maptiler",
|
|
3165
|
+
category: "satellite",
|
|
3166
|
+
style: "https://api.maptiler.com/maps/hybrid-v4/style.json?key=DfdiXzki9UFQMr3alBEe",
|
|
3167
|
+
thumbnail: "https://api.maptiler.com/maps/hybrid/256/0/0/0.jpg?key=DfdiXzki9UFQMr3alBEe",
|
|
3168
|
+
requiresApiKey: false
|
|
3169
|
+
};
|
|
3170
|
+
var TOPO_BASEMAP = {
|
|
3171
|
+
id: "topo",
|
|
3172
|
+
name: "Topo",
|
|
3173
|
+
provider: "maptiler",
|
|
3174
|
+
category: "outdoor",
|
|
3175
|
+
style: "https://api.maptiler.com/maps/topo-v4/style.json?key=DfdiXzki9UFQMr3alBEe",
|
|
3176
|
+
thumbnail: "https://api.maptiler.com/maps/topo-v2/256/0/0/0.png?key=DfdiXzki9UFQMr3alBEe",
|
|
3177
|
+
requiresApiKey: false
|
|
3178
|
+
};
|
|
3194
3179
|
var OSM_STANDARD = {
|
|
3195
3180
|
id: "osm-standard",
|
|
3196
3181
|
name: "OpenStreetMap",
|
|
@@ -3300,7 +3285,15 @@ var STADIA_STAMEN_TERRAIN = {
|
|
|
3300
3285
|
style: (apiKey) => `https://tiles.stadiamaps.com/styles/stamen_terrain.json?api_key=${apiKey}`,
|
|
3301
3286
|
requiresApiKey: true
|
|
3302
3287
|
};
|
|
3288
|
+
var PRIMARY_BASEMAPS = [
|
|
3289
|
+
DEFAULT_BASEMAP,
|
|
3290
|
+
SATELLITE_BASEMAP,
|
|
3291
|
+
TOPO_BASEMAP
|
|
3292
|
+
];
|
|
3303
3293
|
var BUILTIN_BASEMAPS = [
|
|
3294
|
+
DEFAULT_BASEMAP,
|
|
3295
|
+
SATELLITE_BASEMAP,
|
|
3296
|
+
TOPO_BASEMAP,
|
|
3304
3297
|
OSM_STANDARD,
|
|
3305
3298
|
CLASSIC_LIGHT,
|
|
3306
3299
|
CLASSIC_DARK,
|
|
@@ -3855,6 +3848,416 @@ function getLayersWithErrors(states) {
|
|
|
3855
3848
|
return Array.from(states.values()).filter((state) => state.error !== null);
|
|
3856
3849
|
}
|
|
3857
3850
|
|
|
3851
|
+
// src/positioning/types.ts
|
|
3852
|
+
var Z_INDEX_LAYERS = {
|
|
3853
|
+
base: 10,
|
|
3854
|
+
interactive: 20,
|
|
3855
|
+
expanded: 30,
|
|
3856
|
+
modal: 40,
|
|
3857
|
+
tooltip: 50
|
|
3858
|
+
};
|
|
3859
|
+
var PRIORITY_ORDER = ["low", "normal", "high", "critical"];
|
|
3860
|
+
var STACK_GAP = 8;
|
|
3861
|
+
var EDGE_MARGIN = 8;
|
|
3862
|
+
var ATTRIBUTION_HEIGHT = 32;
|
|
3863
|
+
|
|
3864
|
+
// src/positioning/PositioningCoordinator.ts
|
|
3865
|
+
var PositioningCoordinator = class {
|
|
3866
|
+
constructor() {
|
|
3867
|
+
/** Registered controls */
|
|
3868
|
+
this.controls = /* @__PURE__ */ new Map();
|
|
3869
|
+
/** Computed offsets for each control */
|
|
3870
|
+
this.offsets = /* @__PURE__ */ new Map();
|
|
3871
|
+
/** Current map dimensions */
|
|
3872
|
+
this.mapDimensions = { width: 0, height: 0 };
|
|
3873
|
+
/** Event listeners */
|
|
3874
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
3875
|
+
/** Batch update flag to defer layout recalculation */
|
|
3876
|
+
this.batchingUpdates = false;
|
|
3877
|
+
/** Pending recalculation flag during batching */
|
|
3878
|
+
this.pendingRecalculation = false;
|
|
3879
|
+
}
|
|
3880
|
+
/**
|
|
3881
|
+
* Register a control with the coordinator
|
|
3882
|
+
*
|
|
3883
|
+
* @param registration - Control registration data
|
|
3884
|
+
* @returns Computed offset for the control, or null if registration failed
|
|
3885
|
+
*/
|
|
3886
|
+
register(registration) {
|
|
3887
|
+
if (this.controls.has(registration.id)) {
|
|
3888
|
+
console.warn(
|
|
3889
|
+
`PositioningCoordinator: Control "${registration.id}" is already registered. Use update() to modify.`
|
|
3890
|
+
);
|
|
3891
|
+
return this.offsets.get(registration.id) || null;
|
|
3892
|
+
}
|
|
3893
|
+
this.controls.set(registration.id, { ...registration });
|
|
3894
|
+
this.recalculateLayout();
|
|
3895
|
+
this.emit("control-registered", registration.id);
|
|
3896
|
+
return this.offsets.get(registration.id) || null;
|
|
3897
|
+
}
|
|
3898
|
+
/**
|
|
3899
|
+
* Unregister a control from the coordinator
|
|
3900
|
+
*
|
|
3901
|
+
* @param controlId - ID of the control to unregister
|
|
3902
|
+
*/
|
|
3903
|
+
unregister(controlId) {
|
|
3904
|
+
if (!this.controls.has(controlId)) {
|
|
3905
|
+
return;
|
|
3906
|
+
}
|
|
3907
|
+
this.controls.delete(controlId);
|
|
3908
|
+
this.offsets.delete(controlId);
|
|
3909
|
+
this.recalculateLayout();
|
|
3910
|
+
this.emit("control-unregistered", controlId);
|
|
3911
|
+
}
|
|
3912
|
+
/**
|
|
3913
|
+
* Update a control's registration
|
|
3914
|
+
*
|
|
3915
|
+
* @param controlId - ID of the control to update
|
|
3916
|
+
* @param updates - Partial registration updates
|
|
3917
|
+
* @returns Updated offset, or null if control not found
|
|
3918
|
+
*/
|
|
3919
|
+
update(controlId, updates) {
|
|
3920
|
+
const existing = this.controls.get(controlId);
|
|
3921
|
+
if (!existing) {
|
|
3922
|
+
console.warn(`PositioningCoordinator: Cannot update unregistered control "${controlId}"`);
|
|
3923
|
+
return null;
|
|
3924
|
+
}
|
|
3925
|
+
this.controls.set(controlId, { ...existing, ...updates });
|
|
3926
|
+
this.recalculateLayout();
|
|
3927
|
+
this.emit("control-updated", controlId);
|
|
3928
|
+
return this.offsets.get(controlId) || null;
|
|
3929
|
+
}
|
|
3930
|
+
/**
|
|
3931
|
+
* Set the expanded state of a control
|
|
3932
|
+
*
|
|
3933
|
+
* @param controlId - ID of the control
|
|
3934
|
+
* @param isExpanded - Whether the control is expanded
|
|
3935
|
+
* @returns Updated offset, or null if control not found
|
|
3936
|
+
*/
|
|
3937
|
+
setExpanded(controlId, isExpanded) {
|
|
3938
|
+
return this.update(controlId, { isExpanded });
|
|
3939
|
+
}
|
|
3940
|
+
/**
|
|
3941
|
+
* Set the map dimensions for layout calculations
|
|
3942
|
+
*
|
|
3943
|
+
* @param dimensions - New map dimensions
|
|
3944
|
+
*/
|
|
3945
|
+
setMapDimensions(dimensions) {
|
|
3946
|
+
if (dimensions.width === this.mapDimensions.width && dimensions.height === this.mapDimensions.height) {
|
|
3947
|
+
return;
|
|
3948
|
+
}
|
|
3949
|
+
this.mapDimensions = { ...dimensions };
|
|
3950
|
+
this.recalculateLayout();
|
|
3951
|
+
this.emit("map-resized");
|
|
3952
|
+
}
|
|
3953
|
+
/**
|
|
3954
|
+
* Get the current offset for a control
|
|
3955
|
+
*
|
|
3956
|
+
* @param controlId - ID of the control
|
|
3957
|
+
* @returns Current offset, or null if not found
|
|
3958
|
+
*/
|
|
3959
|
+
getOffset(controlId) {
|
|
3960
|
+
return this.offsets.get(controlId) || null;
|
|
3961
|
+
}
|
|
3962
|
+
/**
|
|
3963
|
+
* Get all current offsets
|
|
3964
|
+
*
|
|
3965
|
+
* @returns Map of control IDs to offsets
|
|
3966
|
+
*/
|
|
3967
|
+
getAllOffsets() {
|
|
3968
|
+
return new Map(this.offsets);
|
|
3969
|
+
}
|
|
3970
|
+
/**
|
|
3971
|
+
* Subscribe to coordinator events
|
|
3972
|
+
*
|
|
3973
|
+
* @param listener - Event listener function
|
|
3974
|
+
* @returns Unsubscribe function
|
|
3975
|
+
*/
|
|
3976
|
+
subscribe(listener) {
|
|
3977
|
+
this.listeners.add(listener);
|
|
3978
|
+
return () => {
|
|
3979
|
+
this.listeners.delete(listener);
|
|
3980
|
+
};
|
|
3981
|
+
}
|
|
3982
|
+
/**
|
|
3983
|
+
* Start batching updates to defer layout recalculation
|
|
3984
|
+
* Call endBatch() when done to trigger a single recalculation
|
|
3985
|
+
*/
|
|
3986
|
+
startBatch() {
|
|
3987
|
+
this.batchingUpdates = true;
|
|
3988
|
+
this.pendingRecalculation = false;
|
|
3989
|
+
}
|
|
3990
|
+
/**
|
|
3991
|
+
* End batching and trigger layout recalculation if needed
|
|
3992
|
+
*/
|
|
3993
|
+
endBatch() {
|
|
3994
|
+
this.batchingUpdates = false;
|
|
3995
|
+
if (this.pendingRecalculation) {
|
|
3996
|
+
this.pendingRecalculation = false;
|
|
3997
|
+
this.recalculateLayout();
|
|
3998
|
+
this.emit("layout-changed");
|
|
3999
|
+
}
|
|
4000
|
+
}
|
|
4001
|
+
/**
|
|
4002
|
+
* Recalculate layout for all registered controls
|
|
4003
|
+
*/
|
|
4004
|
+
recalculateLayout() {
|
|
4005
|
+
if (this.batchingUpdates) {
|
|
4006
|
+
this.pendingRecalculation = true;
|
|
4007
|
+
return;
|
|
4008
|
+
}
|
|
4009
|
+
this.offsets.clear();
|
|
4010
|
+
if (this.mapDimensions.width === 0 || this.mapDimensions.height === 0) {
|
|
4011
|
+
return;
|
|
4012
|
+
}
|
|
4013
|
+
const controlsByPosition = this.groupControlsByPosition();
|
|
4014
|
+
const positionedBoxes = /* @__PURE__ */ new Map();
|
|
4015
|
+
for (const [position, controls] of controlsByPosition) {
|
|
4016
|
+
this.calculatePositionStack(position, controls, positionedBoxes);
|
|
4017
|
+
}
|
|
4018
|
+
this.resolveCollisions(positionedBoxes);
|
|
4019
|
+
}
|
|
4020
|
+
/**
|
|
4021
|
+
* Group controls by their primary position
|
|
4022
|
+
*/
|
|
4023
|
+
groupControlsByPosition() {
|
|
4024
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
4025
|
+
for (const control of this.controls.values()) {
|
|
4026
|
+
const position = control.position.primary;
|
|
4027
|
+
const existing = grouped.get(position) || [];
|
|
4028
|
+
existing.push(control);
|
|
4029
|
+
grouped.set(position, existing);
|
|
4030
|
+
}
|
|
4031
|
+
for (const [position, controls] of grouped) {
|
|
4032
|
+
controls.sort((a, b) => {
|
|
4033
|
+
const aPriority = PRIORITY_ORDER.indexOf(a.priority);
|
|
4034
|
+
const bPriority = PRIORITY_ORDER.indexOf(b.priority);
|
|
4035
|
+
return bPriority - aPriority;
|
|
4036
|
+
});
|
|
4037
|
+
grouped.set(position, controls);
|
|
4038
|
+
}
|
|
4039
|
+
return grouped;
|
|
4040
|
+
}
|
|
4041
|
+
/**
|
|
4042
|
+
* Calculate stacked offsets for controls at a single position
|
|
4043
|
+
*/
|
|
4044
|
+
calculatePositionStack(position, controls, positionedBoxes) {
|
|
4045
|
+
let stackOffset = 0;
|
|
4046
|
+
const isBottomPosition = position.startsWith("bottom");
|
|
4047
|
+
const isTopPosition = position.startsWith("top");
|
|
4048
|
+
const isCenterHorizontal = position.includes("center");
|
|
4049
|
+
const isRightPosition = position.includes("right");
|
|
4050
|
+
for (const control of controls) {
|
|
4051
|
+
const dimensions = control.isExpanded && control.expandedDimensions ? control.expandedDimensions : control.dimensions;
|
|
4052
|
+
let x = EDGE_MARGIN;
|
|
4053
|
+
let y = EDGE_MARGIN + stackOffset;
|
|
4054
|
+
if (isCenterHorizontal) {
|
|
4055
|
+
x = (this.mapDimensions.width - dimensions.width) / 2;
|
|
4056
|
+
} else if (isRightPosition) {
|
|
4057
|
+
x = EDGE_MARGIN;
|
|
4058
|
+
}
|
|
4059
|
+
if (isBottomPosition) {
|
|
4060
|
+
const attributionOffset = position === "bottom-right" ? ATTRIBUTION_HEIGHT : 0;
|
|
4061
|
+
y = EDGE_MARGIN + attributionOffset + stackOffset;
|
|
4062
|
+
} else if (position.startsWith("middle")) {
|
|
4063
|
+
y = (this.mapDimensions.height - dimensions.height) / 2;
|
|
4064
|
+
}
|
|
4065
|
+
let absoluteX = x;
|
|
4066
|
+
let absoluteY = y;
|
|
4067
|
+
if (isRightPosition && !isCenterHorizontal) {
|
|
4068
|
+
absoluteX = this.mapDimensions.width - dimensions.width - x;
|
|
4069
|
+
}
|
|
4070
|
+
if (isBottomPosition) {
|
|
4071
|
+
absoluteY = this.mapDimensions.height - dimensions.height - y;
|
|
4072
|
+
}
|
|
4073
|
+
const boundingBox = {
|
|
4074
|
+
left: absoluteX,
|
|
4075
|
+
top: absoluteY,
|
|
4076
|
+
right: absoluteX + dimensions.width,
|
|
4077
|
+
bottom: absoluteY + dimensions.height
|
|
4078
|
+
};
|
|
4079
|
+
const visible = this.isBoxInViewport(boundingBox);
|
|
4080
|
+
const zIndex = this.calculateZIndex(control);
|
|
4081
|
+
this.offsets.set(control.id, {
|
|
4082
|
+
x,
|
|
4083
|
+
y,
|
|
4084
|
+
zIndex,
|
|
4085
|
+
position,
|
|
4086
|
+
visible,
|
|
4087
|
+
usedFallback: false,
|
|
4088
|
+
warning: visible ? void 0 : "Control may be outside visible area"
|
|
4089
|
+
});
|
|
4090
|
+
positionedBoxes.set(control.id, boundingBox);
|
|
4091
|
+
if (isBottomPosition || isTopPosition) {
|
|
4092
|
+
stackOffset += dimensions.height + STACK_GAP;
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
}
|
|
4096
|
+
/**
|
|
4097
|
+
* Calculate z-index for a control based on its layer and state
|
|
4098
|
+
*/
|
|
4099
|
+
calculateZIndex(control) {
|
|
4100
|
+
let baseZ = Z_INDEX_LAYERS[control.zLayer];
|
|
4101
|
+
if (control.isExpanded) {
|
|
4102
|
+
baseZ += 5;
|
|
4103
|
+
}
|
|
4104
|
+
const priorityBonus = PRIORITY_ORDER.indexOf(control.priority);
|
|
4105
|
+
baseZ += priorityBonus;
|
|
4106
|
+
return baseZ;
|
|
4107
|
+
}
|
|
4108
|
+
/**
|
|
4109
|
+
* Check if a bounding box is within the viewport
|
|
4110
|
+
*/
|
|
4111
|
+
isBoxInViewport(box) {
|
|
4112
|
+
return box.left >= 0 && box.top >= 0 && box.right <= this.mapDimensions.width && box.bottom <= this.mapDimensions.height;
|
|
4113
|
+
}
|
|
4114
|
+
/**
|
|
4115
|
+
* Detect collisions between bounding boxes
|
|
4116
|
+
*/
|
|
4117
|
+
boxesCollide(box1, box2) {
|
|
4118
|
+
return !(box1.right < box2.left || box1.left > box2.right || box1.bottom < box2.top || box1.top > box2.bottom);
|
|
4119
|
+
}
|
|
4120
|
+
/**
|
|
4121
|
+
* Resolve collisions by moving lower-priority controls to fallback positions
|
|
4122
|
+
*/
|
|
4123
|
+
resolveCollisions(positionedBoxes) {
|
|
4124
|
+
const sortedControls = Array.from(this.controls.values()).sort((a, b) => {
|
|
4125
|
+
const aPriority = PRIORITY_ORDER.indexOf(a.priority);
|
|
4126
|
+
const bPriority = PRIORITY_ORDER.indexOf(b.priority);
|
|
4127
|
+
return aPriority - bPriority;
|
|
4128
|
+
});
|
|
4129
|
+
for (const control of sortedControls) {
|
|
4130
|
+
const currentBox = positionedBoxes.get(control.id);
|
|
4131
|
+
if (!currentBox) continue;
|
|
4132
|
+
let hasCollision = false;
|
|
4133
|
+
for (const [otherId, otherBox] of positionedBoxes) {
|
|
4134
|
+
if (otherId === control.id) continue;
|
|
4135
|
+
const otherControl = this.controls.get(otherId);
|
|
4136
|
+
if (!otherControl) continue;
|
|
4137
|
+
const otherPriority = PRIORITY_ORDER.indexOf(otherControl.priority);
|
|
4138
|
+
const thisPriority = PRIORITY_ORDER.indexOf(control.priority);
|
|
4139
|
+
if (otherPriority > thisPriority && this.boxesCollide(currentBox, otherBox)) {
|
|
4140
|
+
hasCollision = true;
|
|
4141
|
+
break;
|
|
4142
|
+
}
|
|
4143
|
+
}
|
|
4144
|
+
if (hasCollision && control.position.fallbacks?.length) {
|
|
4145
|
+
const newPosition = this.tryFallbackPositions(control, positionedBoxes);
|
|
4146
|
+
if (newPosition) {
|
|
4147
|
+
const offset = this.offsets.get(control.id);
|
|
4148
|
+
if (offset) {
|
|
4149
|
+
offset.usedFallback = true;
|
|
4150
|
+
offset.position = newPosition;
|
|
4151
|
+
}
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4154
|
+
}
|
|
4155
|
+
}
|
|
4156
|
+
/**
|
|
4157
|
+
* Try fallback positions for a control
|
|
4158
|
+
*
|
|
4159
|
+
* @returns The fallback position that worked, or null if none worked
|
|
4160
|
+
*/
|
|
4161
|
+
tryFallbackPositions(control, positionedBoxes) {
|
|
4162
|
+
const fallbacks = control.position.fallbacks || [];
|
|
4163
|
+
for (const fallbackPosition of fallbacks) {
|
|
4164
|
+
const dimensions = control.isExpanded && control.expandedDimensions ? control.expandedDimensions : control.dimensions;
|
|
4165
|
+
const newBox = this.calculateBoxAtPosition(fallbackPosition, dimensions);
|
|
4166
|
+
let isValid = true;
|
|
4167
|
+
for (const [otherId, otherBox] of positionedBoxes) {
|
|
4168
|
+
if (otherId === control.id) continue;
|
|
4169
|
+
const otherControl = this.controls.get(otherId);
|
|
4170
|
+
if (!otherControl) continue;
|
|
4171
|
+
if (this.boxesCollide(newBox, otherBox)) {
|
|
4172
|
+
isValid = false;
|
|
4173
|
+
break;
|
|
4174
|
+
}
|
|
4175
|
+
}
|
|
4176
|
+
if (isValid && this.isBoxInViewport(newBox)) {
|
|
4177
|
+
positionedBoxes.set(control.id, newBox);
|
|
4178
|
+
let cssX = EDGE_MARGIN;
|
|
4179
|
+
let cssY = EDGE_MARGIN;
|
|
4180
|
+
if (fallbackPosition.includes("center")) {
|
|
4181
|
+
cssX = (this.mapDimensions.width - dimensions.width) / 2;
|
|
4182
|
+
}
|
|
4183
|
+
if (fallbackPosition.startsWith("middle")) {
|
|
4184
|
+
cssY = (this.mapDimensions.height - dimensions.height) / 2;
|
|
4185
|
+
} else if (fallbackPosition === "bottom-right") {
|
|
4186
|
+
cssY = EDGE_MARGIN + ATTRIBUTION_HEIGHT;
|
|
4187
|
+
}
|
|
4188
|
+
const offset = this.offsets.get(control.id);
|
|
4189
|
+
if (offset) {
|
|
4190
|
+
offset.x = cssX;
|
|
4191
|
+
offset.y = cssY;
|
|
4192
|
+
offset.position = fallbackPosition;
|
|
4193
|
+
offset.visible = true;
|
|
4194
|
+
}
|
|
4195
|
+
return fallbackPosition;
|
|
4196
|
+
}
|
|
4197
|
+
}
|
|
4198
|
+
return null;
|
|
4199
|
+
}
|
|
4200
|
+
/**
|
|
4201
|
+
* Calculate absolute bounding box for a control at a specific position
|
|
4202
|
+
* Returns absolute coordinates for collision detection
|
|
4203
|
+
*/
|
|
4204
|
+
calculateBoxAtPosition(position, dimensions) {
|
|
4205
|
+
const isCenterHorizontal = position.includes("center");
|
|
4206
|
+
const isRightPosition = position.includes("right");
|
|
4207
|
+
const isBottomPosition = position.startsWith("bottom");
|
|
4208
|
+
const isMiddleVertical = position.startsWith("middle");
|
|
4209
|
+
let x = EDGE_MARGIN;
|
|
4210
|
+
if (isCenterHorizontal) {
|
|
4211
|
+
x = (this.mapDimensions.width - dimensions.width) / 2;
|
|
4212
|
+
} else if (isRightPosition) {
|
|
4213
|
+
x = this.mapDimensions.width - dimensions.width - EDGE_MARGIN;
|
|
4214
|
+
}
|
|
4215
|
+
const attributionOffset = position === "bottom-right" ? ATTRIBUTION_HEIGHT : 0;
|
|
4216
|
+
let y = EDGE_MARGIN;
|
|
4217
|
+
if (isBottomPosition) {
|
|
4218
|
+
y = this.mapDimensions.height - dimensions.height - EDGE_MARGIN - attributionOffset;
|
|
4219
|
+
} else if (isMiddleVertical) {
|
|
4220
|
+
y = (this.mapDimensions.height - dimensions.height) / 2;
|
|
4221
|
+
}
|
|
4222
|
+
return {
|
|
4223
|
+
left: x,
|
|
4224
|
+
top: y,
|
|
4225
|
+
right: x + dimensions.width,
|
|
4226
|
+
bottom: y + dimensions.height
|
|
4227
|
+
};
|
|
4228
|
+
}
|
|
4229
|
+
/**
|
|
4230
|
+
* Emit an event to all listeners
|
|
4231
|
+
*/
|
|
4232
|
+
emit(type, controlId) {
|
|
4233
|
+
const event = {
|
|
4234
|
+
type,
|
|
4235
|
+
controlId,
|
|
4236
|
+
offsets: this.getAllOffsets(),
|
|
4237
|
+
timestamp: Date.now()
|
|
4238
|
+
};
|
|
4239
|
+
for (const listener of this.listeners) {
|
|
4240
|
+
try {
|
|
4241
|
+
listener(event);
|
|
4242
|
+
} catch (error) {
|
|
4243
|
+
console.error("PositioningCoordinator: Error in event listener", error);
|
|
4244
|
+
}
|
|
4245
|
+
}
|
|
4246
|
+
}
|
|
4247
|
+
/**
|
|
4248
|
+
* Clear all registrations and reset state
|
|
4249
|
+
*/
|
|
4250
|
+
destroy() {
|
|
4251
|
+
this.controls.clear();
|
|
4252
|
+
this.offsets.clear();
|
|
4253
|
+
this.listeners.clear();
|
|
4254
|
+
this.mapDimensions = { width: 0, height: 0 };
|
|
4255
|
+
}
|
|
4256
|
+
};
|
|
4257
|
+
function createPositioningCoordinator() {
|
|
4258
|
+
return new PositioningCoordinator();
|
|
4259
|
+
}
|
|
4260
|
+
|
|
3858
4261
|
// src/colors/realEstate.ts
|
|
3859
4262
|
var lotAvailabilityColors = {
|
|
3860
4263
|
Available: "#4caf50",
|
|
@@ -3969,7 +4372,6 @@ function createMatchedColorExpression(baseColorExpression, matchedProperty = "ma
|
|
|
3969
4372
|
];
|
|
3970
4373
|
}
|
|
3971
4374
|
|
|
3972
|
-
exports.BASE_OFFSET = BASE_OFFSET;
|
|
3973
4375
|
exports.BIKE_LANES = BIKE_LANES;
|
|
3974
4376
|
exports.BUILTIN_BASEMAPS = BUILTIN_BASEMAPS;
|
|
3975
4377
|
exports.BUILTIN_OVERLAY_LAYERS = BUILTIN_OVERLAY_LAYERS;
|
|
@@ -3977,7 +4379,9 @@ exports.CATEGORY_META = CATEGORY_META;
|
|
|
3977
4379
|
exports.CITY_LIMITS = CITY_LIMITS;
|
|
3978
4380
|
exports.CLASSIC_DARK = CLASSIC_DARK;
|
|
3979
4381
|
exports.CLASSIC_LIGHT = CLASSIC_LIGHT;
|
|
4382
|
+
exports.DEFAULT_BASEMAP = DEFAULT_BASEMAP;
|
|
3980
4383
|
exports.DEFAULT_SIMPLIFICATION_THRESHOLDS = DEFAULT_SIMPLIFICATION_THRESHOLDS;
|
|
4384
|
+
exports.EDGE_MARGIN = EDGE_MARGIN;
|
|
3981
4385
|
exports.FLOOD_ZONES = FLOOD_ZONES;
|
|
3982
4386
|
exports.FREE_BASEMAPS = FREE_BASEMAPS;
|
|
3983
4387
|
exports.KEYBOARD_CONTROLS = KEYBOARD_CONTROLS;
|
|
@@ -3986,12 +4390,15 @@ exports.MAPTILER_OUTDOOR = MAPTILER_OUTDOOR;
|
|
|
3986
4390
|
exports.MAPTILER_SATELLITE = MAPTILER_SATELLITE;
|
|
3987
4391
|
exports.MAPTILER_STREETS = MAPTILER_STREETS;
|
|
3988
4392
|
exports.MARKER_PROTECTION_CLASS = MARKER_PROTECTION_CLASS;
|
|
3989
|
-
exports.OFFSET_CLASSES = OFFSET_CLASSES;
|
|
3990
4393
|
exports.OSM_STANDARD = OSM_STANDARD;
|
|
3991
4394
|
exports.PARKS = PARKS;
|
|
3992
|
-
exports.
|
|
4395
|
+
exports.PRIMARY_BASEMAPS = PRIMARY_BASEMAPS;
|
|
4396
|
+
exports.PRIORITY_ORDER = PRIORITY_ORDER;
|
|
4397
|
+
exports.PositioningCoordinator = PositioningCoordinator;
|
|
4398
|
+
exports.SATELLITE_BASEMAP = SATELLITE_BASEMAP;
|
|
3993
4399
|
exports.SCHOOL_DISTRICTS = SCHOOL_DISTRICTS;
|
|
3994
4400
|
exports.SPORTS_FACILITIES = SPORTS_FACILITIES;
|
|
4401
|
+
exports.STACK_GAP = STACK_GAP;
|
|
3995
4402
|
exports.STADIA_ALIDADE_DARK = STADIA_ALIDADE_DARK;
|
|
3996
4403
|
exports.STADIA_ALIDADE_SMOOTH = STADIA_ALIDADE_SMOOTH;
|
|
3997
4404
|
exports.STADIA_STAMEN_TERRAIN = STADIA_STAMEN_TERRAIN;
|
|
@@ -3999,10 +4406,12 @@ exports.STADIA_STAMEN_TONER = STADIA_STAMEN_TONER;
|
|
|
3999
4406
|
exports.STADIA_STAMEN_WATERCOLOR = STADIA_STAMEN_WATERCOLOR;
|
|
4000
4407
|
exports.THEME_DARK = THEME_DARK;
|
|
4001
4408
|
exports.THEME_LIGHT = THEME_LIGHT;
|
|
4409
|
+
exports.TOPO_BASEMAP = TOPO_BASEMAP;
|
|
4002
4410
|
exports.TRAILS = TRAILS;
|
|
4003
4411
|
exports.TRANSIT_ROUTES = TRANSIT_ROUTES;
|
|
4004
4412
|
exports.WATERSHEDS = WATERSHEDS;
|
|
4005
4413
|
exports.ZONING_DISTRICTS = ZONING_DISTRICTS;
|
|
4414
|
+
exports.Z_INDEX_LAYERS = Z_INDEX_LAYERS;
|
|
4006
4415
|
exports.applyMarkerChildProtection = applyMarkerChildProtection;
|
|
4007
4416
|
exports.applyMarkerProtection = applyMarkerProtection;
|
|
4008
4417
|
exports.boundaryColors = boundaryColors;
|
|
@@ -4015,8 +4424,6 @@ exports.calculateZoomThresholds = calculateZoomThresholds;
|
|
|
4015
4424
|
exports.clusterColorExpression = clusterColorExpression;
|
|
4016
4425
|
exports.clusterColors = clusterColors;
|
|
4017
4426
|
exports.combineBounds = combineBounds;
|
|
4018
|
-
exports.computePositionClasses = computePositionClasses;
|
|
4019
|
-
exports.computeVerticalOffsetStyle = computeVerticalOffsetStyle;
|
|
4020
4427
|
exports.countFeaturesByType = countFeaturesByType;
|
|
4021
4428
|
exports.createCategoricalColorExpression = createCategoricalColorExpression;
|
|
4022
4429
|
exports.createCircleStyle = createCircleStyle;
|
|
@@ -4036,6 +4443,7 @@ exports.createLineStyle = createLineStyle;
|
|
|
4036
4443
|
exports.createLotFillStyle = createLotFillStyle;
|
|
4037
4444
|
exports.createLotOutlineStyle = createLotOutlineStyle;
|
|
4038
4445
|
exports.createMatchedColorExpression = createMatchedColorExpression;
|
|
4446
|
+
exports.createPositioningCoordinator = createPositioningCoordinator;
|
|
4039
4447
|
exports.createPredictiveViewportManager = createPredictiveViewportManager;
|
|
4040
4448
|
exports.createRTreeViewportManager = createRTreeViewportManager;
|
|
4041
4449
|
exports.createSelectionExpression = createSelectionExpression;
|