@@ -216,7 +216,10 @@ function onClick(e: MapMouseEvent): void {
216
216
}
217
217
}
218
218
219
+ const selectedFeatureDepsIDs = ref <number []>([])
219
220
async function updateSelectedFeature(feature ? : ApiPoi ): Promise <void > {
221
+ selectedFeatureDepsIDs .value = []
222
+
220
223
if (! feature ) {
221
224
await menuStore .fetchFeatures ({
222
225
vidoConfig: config ! ,
@@ -253,39 +256,47 @@ async function updateSelectedFeature(feature?: ApiPoi): Promise<void> {
253
256
let waypointIndex = 1
254
257
255
258
data .value .features .forEach ((f ) => {
259
+ const depID = ' metadata' in f .properties ? f .properties .metadata .id : f .properties .id
260
+ selectedFeatureDepsIDs .value .push (depID )
261
+
256
262
f = {
257
263
... f ,
258
264
properties: {
259
265
... f .properties ,
260
266
vido_visible: true ,
261
267
},
262
268
}
263
- if (' metadata' in f .properties && f .properties .metadata .id === id ) {
269
+
270
+ if (id === depID ) {
264
271
poi = f as ApiPoi
265
272
}
266
- else {
267
- if (f .properties [' route:point:type' ]) {
268
- f = apiRouteWaypointToApiPoi (
269
- f as ApiRouteWaypoint ,
270
- poi ?.properties .display ?.color_fill || ' #76009E' ,
271
- poi ?.properties .display ?.color_line || ' #76009E' ,
272
- f .properties [' route:point:type' ] === ApiRouteWaypointType .way_point
273
- ? (waypointIndex ++ ).toString ()
274
- : undefined ,
275
- )
276
- }
273
+
274
+ if (f .properties [' route:point:type' ]) {
275
+ f = apiRouteWaypointToApiPoi (
276
+ f as ApiRouteWaypoint ,
277
+ poi ?.properties .display ?.color_fill || ' #76009E' ,
278
+ poi ?.properties .display ?.color_line || ' #76009E' ,
279
+ f .properties [' route:point:type' ] === ApiRouteWaypointType .way_point
280
+ ? (waypointIndex ++ ).toString ()
281
+ : undefined ,
282
+ )
283
+ }
284
+
285
+ if (f .geometry .type === ' Point' ) {
277
286
deps .push (f as ApiPoi )
278
287
}
279
288
})
280
289
290
+ if (! poi )
291
+ throw new Error (` Feature with ID: ${id } not found. ` )
292
+
281
293
mapStore .setSelectedFeature (poi )
282
- if (poi ) {
283
- // In case user click on vecto element, attach Pin Marker to POI Marker
284
- teritorioCluster .value ?.setSelectedFeature (poi as unknown as MapGeoJSONFeature )
285
294
286
- if (poi .properties .metadata .category_ids ?.length )
287
- menuStore .filterByDeps (poi .properties .metadata .category_ids , deps , selectedFeature .value )
288
- }
295
+ // In case user click on vecto element, attach Pin Marker to POI Marker
296
+ teritorioCluster .value ?.setSelectedFeature (poi as unknown as MapGeoJSONFeature )
297
+
298
+ if (poi .properties .metadata .category_ids ?.length )
299
+ menuStore .filterByDeps (poi .properties .metadata .category_ids , deps )
289
300
}
290
301
}
291
302
catch (e ) {
@@ -382,11 +393,8 @@ function showVectorSelectedFeature(): void {
382
393
return
383
394
}
384
395
385
- if (
386
- selectedFeature .value
387
- && (selectedFeature .value .properties ?.metadata ?.id || selectedFeature .value .id || selectedFeature .value .properties ?.id )
388
- ) {
389
- filterRouteByPoiIds (map .value , [selectedFeature .value .properties ?.metadata ?.id || selectedFeature .value .id || selectedFeature .value .properties ?.id ])
396
+ if (selectedFeature .value ) {
397
+ filterRouteByPoiIds (map .value , selectedFeatureDepsIDs .value )
390
398
}
391
399
else {
392
400
if (props .enableFilterRouteByFeatures ) {
0 commit comments