@smartnet360/svelte-components 0.0.81 → 0.0.82

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.
@@ -51,6 +51,8 @@ export function cellsToGeoJSON(cells, currentZoom, baseRadius = 500, groupColorM
51
51
  cellID: cell.cellID,
52
52
  cellName: cell.cellName,
53
53
  siteId: cell.siteId,
54
+ latitude: cell.latitude,
55
+ longitude: cell.longitude,
54
56
  // Cell attributes
55
57
  tech: cell.tech,
56
58
  band: cell.frq,
@@ -14,6 +14,7 @@
14
14
 
15
15
  import { onMount, onDestroy, getContext } from 'svelte';
16
16
  import { get } from 'svelte/store';
17
+ import mapboxgl from 'mapbox-gl';
17
18
  import MapControl from './MapControl.svelte';
18
19
  import { createFeatureSelectionStore, type SelectedFeature } from './featureSelectionStore.svelte';
19
20
  import { MAP_CONTEXT_KEY, type MapStore } from '../../core/types';
@@ -47,7 +48,7 @@
47
48
  onAction,
48
49
  actionButtonLabel = 'Process Cluster',
49
50
  featureIcon = 'geo-alt-fill',
50
- idPropertyOptions = ['siteId', 'cellName','id'],
51
+ idPropertyOptions = ['siteId','sectorId', 'cellName','id'],
51
52
  defaultIdProperty = 'siteId'
52
53
  }: Props = $props();
53
54
 
@@ -69,6 +70,9 @@
69
70
  // Track collapsed state
70
71
  let isCollapsed = $state(false);
71
72
 
73
+ // Track markers for selected features
74
+ let markers = new Map<string, mapboxgl.Marker>();
75
+
72
76
  // Subscribe to map store and initialize when map becomes available
73
77
  let unsubscribe: (() => void) | null = null;
74
78
 
@@ -92,10 +96,63 @@
92
96
  if (unsubscribe) {
93
97
  unsubscribe();
94
98
  }
99
+ // Remove all markers
100
+ clearAllMarkers();
95
101
  // Cleanup event handlers
96
102
  store.destroy();
97
103
  });
98
104
 
105
+ // Update markers when selected features change
106
+ $effect(() => {
107
+ updateMarkers(selectedFeatures);
108
+ });
109
+
110
+ function updateMarkers(features: SelectedFeature[]) {
111
+ console.log('[FeatureSelectionControl] Updating markers for', features.length, 'features');
112
+
113
+ // Get current map
114
+ const map = get(mapStore);
115
+ if (!map) return;
116
+
117
+ // Remove markers that are no longer in the selection
118
+ const currentIds = new Set(features.map(f => f.id));
119
+ for (const [id, marker] of markers.entries()) {
120
+ if (!currentIds.has(id)) {
121
+ marker.remove();
122
+ markers.delete(id);
123
+ console.log('[FeatureSelectionControl] Removed marker for', id);
124
+ }
125
+ }
126
+
127
+ // Add markers for new selections
128
+ for (const feature of features) {
129
+ if (!markers.has(feature.id)) {
130
+ // Try to extract coordinates from properties
131
+ const lat = feature.properties?.latitude || feature.properties?.lat;
132
+ const lon = feature.properties?.longitude || feature.properties?.lon || feature.properties?.lng;
133
+
134
+ if (lat && lon) {
135
+ const marker = new mapboxgl.Marker({ color: '#FF6B35' })
136
+ .setLngLat([lon, lat])
137
+ .addTo(map);
138
+
139
+ markers.set(feature.id, marker);
140
+ console.log('[FeatureSelectionControl] Added marker for', feature.id, 'at', [lon, lat]);
141
+ } else {
142
+ console.warn('[FeatureSelectionControl] No coordinates found for feature', feature.id);
143
+ }
144
+ }
145
+ }
146
+ }
147
+
148
+ function clearAllMarkers() {
149
+ for (const marker of markers.values()) {
150
+ marker.remove();
151
+ }
152
+ markers.clear();
153
+ console.log('[FeatureSelectionControl] All markers cleared');
154
+ }
155
+
99
156
  function handleCollapseToggle(collapsed: boolean) {
100
157
  isCollapsed = collapsed;
101
158
  // When control is expanded, enable selection mode
@@ -119,6 +176,7 @@
119
176
 
120
177
  function handleClearAll() {
121
178
  store.clearSelection();
179
+ clearAllMarkers();
122
180
  }
123
181
 
124
182
  async function handleCopy() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartnet360/svelte-components",
3
- "version": "0.0.81",
3
+ "version": "0.0.82",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",