Loading...
Searching...
No Matches
location_window_common_example.dart
Go to the documentation of this file.
1import 'dart:async';
2import 'dart:io';
3import 'dart:math';
4import 'package:flutter/material.dart';
5import 'package:navigine_sdk/navigine_sdk.dart';
6
7class DemoRouteLayerListener implements RouteLayerListener {
8 @override
9 void onRouteChanged(RouteLayerStatus status, RouteView? route) {
10 print("Route status: $status");
11 }
12
13 @override
14 void onRouteAdvanced(RouteProgress progress) {
15 print("Remaining distance: ${progress.remainingDistance}, time: ${progress.remainingTime}s");
16 }
17
18 @override
19 void onRouteTargetReached() {
20 print("Route target reached");
21 }
22}
23
24class DemoRouteViewListener implements RouteViewListener {
25 DemoRouteViewListener(this._routeLayer);
26
27 final RouteLayer _routeLayer;
28
29 @override
30 void onRouteViewsChanged() {
31 print("Route views changed");
32 }
33
34 @override
35 void onSelectedRouteChanged(RouteView? route) {
36 print("Selected route changed");
37 }
38
39 @override
40 void onRouteViewTap(RouteView route) {
41 _routeLayer.selectRoute(route);
42 }
43}
44
51class LocationWindowCommonExample {
58
59 LocationWindowCommonExample() {
60 _demonstrateLocationWindowCommonMethods();
61 }
62
66 void _demonstrateLocationWindowCommonMethods() {
67 print("=== LocationWindowCommon Methods ===");
68
69 _demonstrateSetSublocationId();
70 _demonstrateOperatingMode();
71 _demonstrateSublocationQueries();
72 _demonstrateSublocationChangeListener();
73 _demonstrateUserLocationLayer();
74 _demonstrateRouteLayer();
75 _demonstrateCoordinateConversion();
76 _demonstrateMapFeatureSelection();
77 _demonstrateApplyLayerFilter();
78 _demonstrateDebugFlags();
79 _demonstrateZoomProperties();
80 }
81
85 void _demonstrateDebugFlags() {
86 print("--- Debug flags ---");
87
88 // [dart_DebugFlag_enum]
89 final allFlags = [
90 DebugFlag.NONE,
91 DebugFlag.INFOS,
92 DebugFlag.STATS,
93 DebugFlag.LABELS,
94 DebugFlag.DRAW_ALL_LABELS,
95 DebugFlag.SELECTION_BUFFER,
96 ];
97 print("Debug flag enum values: ${allFlags.length}");
98 // [dart_DebugFlag_enum]
99
100 // [dart_LocationWindow_setDebugFlag]
101 LocationWindow.setDebugFlag(DebugFlag.INFOS, true);
102 LocationWindow.setDebugFlag(DebugFlag.STATS, false);
103 print("Updated debug flags on LocationWindow");
104 // [dart_LocationWindow_setDebugFlag]
105
106 // [dart_LocationWindow_getDebugFlag]
107 bool infosOn = LocationWindow.getDebugFlag(DebugFlag.INFOS);
108 print("Debug flag INFOS enabled: $infosOn");
109 // [dart_LocationWindow_getDebugFlag]
110 }
111
112
113 void _demonstrateOperatingMode() {
114 print("--- Operating Mode ---");
115
116 if (_locationWindow == null) {
117 print("LocationWindow not available yet");
118 return;
119 }
120
121 // [dart_OperatingMode_enum]
122 final modes = [
123 OperatingMode.INDOOR_ONLY,
124 OperatingMode.OUTDOOR,
125 OperatingMode.OUTDOOR_INDOOR,
126 ];
127 print("Operating modes: ${modes.length}");
128 // [dart_OperatingMode_enum]
129
130 // [dart_LocationWindow_setOperatingMode]
131 _locationWindow!.setOperatingMode(OperatingMode.OUTDOOR_INDOOR);
132 print("Set operating mode to OUTDOOR_INDOOR");
133 // [dart_LocationWindow_setOperatingMode]
134
135 // [dart_LocationWindow_getOperatingMode]
136 OperatingMode currentMode = _locationWindow!.getOperatingMode();
137 print("Current operating mode: $currentMode");
138 // [dart_LocationWindow_getOperatingMode]
139
140 // [dart_MapTheme_enum]
141 final themes = [MapTheme.LIGHT, MapTheme.DARK];
142 print("Map themes: ${themes.length}");
143 // [dart_MapTheme_enum]
144
145 // [dart_LocationWindow_setMapTheme]
146 _locationWindow!.setMapTheme(MapTheme.DARK);
147 print("Set map theme to DARK");
148 // [dart_LocationWindow_setMapTheme]
149
150 // [dart_LocationWindow_getMapTheme]
151 MapTheme currentTheme = _locationWindow!.getMapTheme();
152 print("Current map theme: $currentTheme");
153 // [dart_LocationWindow_getMapTheme]
154
155 // [dart_TileKind_enum]
156 final kinds = [TileKind.VECTOR, TileKind.RASTER];
157 print("Tile kinds: ${kinds.length}");
158 // [dart_TileKind_enum]
159
160 // [dart_TileSchema_enum]
161 final schemas = [TileSchema.SHORTBREAD, TileSchema.OPEN_MAP_TILES, TileSchema.MAPBOX_STREETS];
162 print("Tile schemas: ${schemas.length}");
163 // [dart_TileSchema_enum]
164
165 // [dart_HttpTileSource_record]
166 final http = HttpTileSource(
167 urlTemplate: "https://api.maptiler.com/tiles/v3-openmaptiles/{z}/{x}/{y}.pbf",
168 headers: null,
169 queryParameters: {"key": "YOUR_MAPTILER_KEY"},
170 );
171 // [dart_HttpTileSource_record]
172
173 // [dart_MbtilesTileSource_record]
174 final offline = MbtilesTileSource(path: "/path/to/map.mbtiles");
175 // [dart_MbtilesTileSource_record]
176
177 // [dart_TileProvider_record]
178 final osmHttp = TileProvider(
179 schema: TileSchema.OPEN_MAP_TILES,
180 http: http,
181 mbtiles: null,
182 minZoom: 0,
183 maxZoom: 14,
184 attribution: null,
185 kind: TileKind.VECTOR,
186 );
187 final mbtiles = TileProvider(
188 schema: TileSchema.SHORTBREAD,
189 http: null,
190 mbtiles: offline,
191 minZoom: 0,
192 maxZoom: 14,
193 attribution: null,
194 kind: TileKind.VECTOR,
195 );
196 // [dart_TileProvider_record]
197
198 // [dart_LocationWindow_setTileProvider]
199 _locationWindow!.setTileProvider(osmHttp);
200 _locationWindow!.setTileProvider(null);
201 final imagery = TileProvider(
202 schema: TileSchema.SHORTBREAD,
203 http: HttpTileSource(
204 urlTemplate: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
205 headers: null,
206 queryParameters: null,
207 ),
208 mbtiles: null,
209 minZoom: 0,
210 maxZoom: 19,
211 attribution: "© OpenStreetMap contributors",
212 kind: TileKind.RASTER,
213 );
214 _locationWindow!.setTileProvider(imagery);
215 // [dart_LocationWindow_setTileProvider]
216
217 // [dart_AttributionAlignment_record]
218 final alignment = AttributionAlignment(
219 AttributionHorizontalAlignment.RIGHT,
220 AttributionVerticalAlignment.BOTTOM,
221 );
222 // [dart_AttributionAlignment_record]
223
224 // [dart_LocationWindow_setAttributionAlignment]
225 _locationWindow!.setAttributionAlignment(alignment);
226 // [dart_LocationWindow_setAttributionAlignment]
227
228 // [dart_LocationWindow_getAttribution]
229 final attribution = _locationWindow!.getAttribution();
230 print("Attribution: $attribution");
231 // [dart_LocationWindow_getAttribution]
232 }
233
237 void _demonstrateSetSublocationId() {
238 print("--- setSublocationId Method ---");
239
240 if (_locationWindow == null) {
241 print("LocationWindow not available yet");
242 return;
243 }
244
245 // [dart_LocationWindow_setSublocationId]
246 // Set sublocation ID to switch between floors
247 _locationWindow!.setSublocationId(1);
248 print("Set sublocation ID to 1 (first floor)");
249 // [dart_LocationWindow_setSublocationId]
250
251 // [dart_LocationWindow_setSublocationId_2]
252 // Set sublocation ID to another floor
253 _locationWindow!.setSublocationId(2);
254 print("Set sublocation ID to 2 (second floor)");
255 // [dart_LocationWindow_setSublocationId_2]
256
257 // [dart_LocationWindow_setSublocationId_3]
258 // Set sublocation ID to ground floor
259 _locationWindow!.setSublocationId(0);
260 print("Set sublocation ID to 0 (ground floor)");
261 // [dart_LocationWindow_setSublocationId_3]
262
263 // Test with different sublocation IDs
264 List<int> sublocationIds = [1, 2, 3, 0, 5];
265 for (int id in sublocationIds) {
266 _locationWindow!.setSublocationId(id);
267 print("Switched to sublocation ID: $id");
268 }
269 }
270
274 void _demonstrateSublocationQueries() {
275 print("--- getSublocationId & getEnclosingCamera ---");
276
277 if (_locationWindow == null) {
278 print("LocationWindow not available yet");
279 return;
280 }
281
282 // [dart_LocationWindow_getSublocationId]
283 int? currentId = _locationWindow!.getSublocationId();
284 if (currentId != null) {
285 print("Current sublocation id: $currentId");
286 } else {
287 print("Current sublocation id is not set");
288 }
289 // [dart_LocationWindow_getSublocationId]
290
291 // [dart_LocationWindow_getEnclosingCamera]
292 BoundingBox boundingBox = BoundingBox(
293 GlobalPoint(55.75, 37.61), GlobalPoint(55.76, 37.63));
294 Camera camera = _locationWindow!.getEnclosingCamera(boundingBox);
295 print("Camera that fits bounding box: $camera");
296 // [dart_LocationWindow_getEnclosingCamera]
297
298 // [dart_LocationWindow_setFocusRect]
299 ScreenRect focus = ScreenRect(
300 ScreenPoint(0, 0),
301 ScreenPoint(1000, 1600),
302 );
303 _locationWindow!.setFocusRect(focus);
304 // [dart_LocationWindow_setFocusRect]
305
306 // [dart_LocationWindow_getEnclosingCameraWithFocus]
307 Camera padded = _locationWindow!.getEnclosingCameraWithFocus(
308 boundingBox,
309 focus,
310 null,
311 null,
312 );
313 print("Camera that fits bounding box in focus rect: $padded");
314 // [dart_LocationWindow_getEnclosingCameraWithFocus]
315 }
316
320 void _demonstrateSublocationChangeListener() {
321 print("--- Sublocation Change Listener ---");
322
323 if (_locationWindow == null) {
324 print("LocationWindow not available yet");
325 return;
326 }
327
328 DemoSublocationChangeListener listener = DemoSublocationChangeListener();
329
330 // [dart_LocationWindow_addSublocationChangeListener]
331 _locationWindow!.addSublocationChangeListener(listener);
332 print("Added sublocation change listener");
333 // [dart_LocationWindow_addSublocationChangeListener]
334
335 _locationWindow!.setSublocationId(1);
336 _locationWindow!.setSublocationId(2);
337
338 // [dart_LocationWindow_removeSublocationChangeListener]
339 _locationWindow!.removeSublocationChangeListener(listener);
340 print("Removed sublocation change listener");
341 // [dart_LocationWindow_removeSublocationChangeListener]
342 }
343
347 void _demonstrateUserLocationLayer() {
348 print("--- UserLocationLayer ---");
349
350 if (_userLocationLayer == null) {
351 print("UserLocationLayer not available yet");
352 return;
353 }
354
355 // [dart_UserLocationLayer_setVisible]
356 _userLocationLayer!.setVisible(true);
357 print("User location layer set visible");
358 // [dart_UserLocationLayer_setVisible]
359
360 // [dart_UserLocationLayer_isVisible]
361 bool visible = _userLocationLayer!.isVisible();
362 print("User location layer is visible: $visible");
363 // [dart_UserLocationLayer_isVisible]
364
365 // [dart_UserLocationLayer_setAnchor]
366 ScreenPoint anchor = ScreenPoint(100.0, 200.0);
367 _userLocationLayer!.setAnchor(anchor);
368 print("Set user location anchor to: (${anchor.x}, ${anchor.y})");
369 // [dart_UserLocationLayer_setAnchor]
370
371 // [dart_UserLocationLayer_anchorEnabled]
372 bool anchorEnabled = _userLocationLayer!.anchorEnabled();
373 print("Anchor enabled: $anchorEnabled");
374 // [dart_UserLocationLayer_anchorEnabled]
375
376 // [dart_UserLocationLayer_setHeadingModeActive]
377 _userLocationLayer!.setHeadingModeActive(true);
378 print("Heading-up mode enabled");
379 // [dart_UserLocationLayer_setHeadingModeActive]
380
381 // [dart_UserLocationLayer_headingModeActive]
382 bool headingModeActive = _userLocationLayer!.headingModeActive();
383 print("Heading-up mode active: $headingModeActive");
384 // [dart_UserLocationLayer_headingModeActive]
385
386 // [dart_UserLocationLayer_setFollowMode]
387 _userLocationLayer!.setFollowMode(UserLocationFollowMode.HEADING);
388 print("Follow mode set to heading");
389 // [dart_UserLocationLayer_setFollowMode]
390
391 // [dart_UserLocationLayer_followMode]
392 final followMode = _userLocationLayer!.followMode();
393 print("Follow mode: $followMode");
394 // [dart_UserLocationLayer_followMode]
395
396 // [dart_UserLocationLayer_setArrowBitmap]
397 _userLocationLayer!.setArrowBitmap(ImageProvider.fromImageProvider(
398 const AssetImage('assets/arrow.png'),
399 cacheable: true,
400 ));
401 _userLocationLayer!.setArrowBitmap(null);
402 print("Custom arrow bitmap cleared");
403 // [dart_UserLocationLayer_setArrowBitmap]
404
405 // [dart_UserLocationLayer_setAccuracyColor]
406 _userLocationLayer!.setAccuracyColor(const Color(0x4230AAD9));
407 print("Accuracy circle color updated");
408 // [dart_UserLocationLayer_setAccuracyColor]
409
410 // [dart_UserLocationLayer_resetAnchor]
411 _userLocationLayer!.resetAnchor();
412 print("Anchor reset to default");
413 // [dart_UserLocationLayer_resetAnchor]
414 }
415
419 void _demonstrateRouteLayer() {
420 print("--- RouteLayer ---");
421
422 if (_routeLayer == null) {
423 print("RouteLayer not available yet");
424 return;
425 }
426
427 // [dart_RouteLayer_setVisible]
428 _routeLayer!.setVisible(true);
429 print("Route layer set visible");
430 // [dart_RouteLayer_setVisible]
431
432 // [dart_RouteLayer_isVisible]
433 bool visible = _routeLayer!.isVisible();
434 print("Route layer is visible: $visible");
435 // [dart_RouteLayer_isVisible]
436
437 // [dart_RouteLayer_setTraveledColor]
438 _routeLayer!.setTraveledColor(const Color(0xB4787878));
439 print("Traveled color updated");
440 // [dart_RouteLayer_setTraveledColor]
441
442 // [dart_RouteLayer_setRemainingColor]
443 _routeLayer!.setRemainingColor(const Color(0xFF30AAD9));
444 print("Remaining color updated");
445 // [dart_RouteLayer_setRemainingColor]
446
447 // [dart_RouteLayer_setWidth]
448 _routeLayer!.setWidth(8.0);
449 print("Route width updated");
450 // [dart_RouteLayer_setWidth]
451
452 // [dart_RouteLayer_setRemainingStyle]
453 _routeLayer!.setRemainingStyle(RouteRemainingStyle.DOTTED);
454 print("Remaining style set to DOTTED");
455 // [dart_RouteLayer_setRemainingStyle]
456
457 // [dart_RouteLayer_remainingStyle]
458 RouteRemainingStyle remainingStyle = _routeLayer!.remainingStyle();
459 print("Remaining style: $remainingStyle");
460 // [dart_RouteLayer_remainingStyle]
461
462 // [dart_RouteLayer_setRemainingPointSize]
463 _routeLayer!.setRemainingPointSize(8.0, 8.0);
464 print("Remaining point size updated");
465 // [dart_RouteLayer_setRemainingPointSize]
466
467 // [dart_RouteLayer_setRemainingPlacement]
468 _routeLayer!.setRemainingPlacement(Placement.SPACED);
469 print("Remaining placement updated");
470 // [dart_RouteLayer_setRemainingPlacement]
471
472 // [dart_RouteLayer_setRemainingPlacementSpacing]
473 _routeLayer!.setRemainingPlacementSpacing(8.0);
474 print("Remaining placement spacing updated");
475 // [dart_RouteLayer_setRemainingPlacementSpacing]
476
477 // [dart_RouteLayer_setRemainingPlacementMinRatio]
478 _routeLayer!.setRemainingPlacementMinRatio(0.0);
479 print("Remaining placement min ratio updated");
480 // [dart_RouteLayer_setRemainingPlacementMinRatio]
481
482 // [dart_RouteLayer_setRemainingCollisionEnabled]
483 _routeLayer!.setRemainingCollisionEnabled(false);
484 print("Remaining collision disabled");
485 // [dart_RouteLayer_setRemainingCollisionEnabled]
486
487 // [dart_RouteLayer_setRemainingDashLength]
488 _routeLayer!.setRemainingDashLength(0.5);
489 print("Remaining dash length updated");
490 // [dart_RouteLayer_setRemainingDashLength]
491
492 // [dart_RouteLayer_setRemainingGapLength]
493 _routeLayer!.setRemainingGapLength(0.4);
494 print("Remaining gap length updated");
495 // [dart_RouteLayer_setRemainingGapLength]
496
497 final from = RouteEndpoint(
498 point: GlobalPoint(latitude: 55.751244, longitude: 37.618423),
499 sublocationId: 1, // null for outdoor point
500 );
501 final to = RouteEndpoint(
502 point: GlobalPoint(latitude: 55.751700, longitude: 37.619000),
503 sublocationId: 2, // null for outdoor point
504 );
505
506 // [dart_RouteLayer_setRoute]
507 _routeLayer!.setRoute(from, to);
508 print("Static route applied");
509 // [dart_RouteLayer_setRoute]
510
511 // [dart_RouteLayer_setTarget]
512 _routeLayer!.setTarget(to);
513 print("Guidance target applied");
514 // [dart_RouteLayer_setTarget]
515
516 // [dart_RouteLayer_routes]
517 final routes = _routeLayer!.routes();
518 print("Visible routes: ${routes.length}");
519 // [dart_RouteLayer_routes]
520
521 // [dart_RouteLayer_selectedRoute]
522 final selectedRoute = _routeLayer!.selectedRoute();
523 if (selectedRoute != null) {
524 print("Selected route length: ${selectedRoute.length()}");
525 }
526 // [dart_RouteLayer_selectedRoute]
527
528 // [dart_RouteLayer_selectRoute]
529 if (routes.isNotEmpty) {
530 _routeLayer!.selectRoute(routes.first);
531 }
532 // [dart_RouteLayer_selectRoute]
533
534 // [dart_RouteLayer_addRouteLayerListener]
535 _routeLayerListener = DemoRouteLayerListener();
536 _routeLayer!.addRouteLayerListener(_routeLayerListener!);
537 // [dart_RouteLayer_addRouteLayerListener]
538
539 // [dart_RouteLayer_addRouteViewListener]
540 _routeViewListener = DemoRouteViewListener(_routeLayer!);
541 _routeLayer!.addRouteViewListener(_routeViewListener!);
542 // [dart_RouteLayer_addRouteViewListener]
543
544 // [dart_RouteLayer_clear]
545 _routeLayer!.clear();
546 print("Route layer cleared");
547 // [dart_RouteLayer_clear]
548 }
549
553 void _demonstrateCoordinateConversion() {
554 print("--- Coordinate Conversion Methods ---");
555
556 if (_locationWindow == null) {
557 print("LocationWindow not available yet");
558 return;
559 }
560
561 // [dart_LocationWindow_screenPositionToGlobal]
562 ScreenPoint screenPoint = ScreenPoint(100.0, 200.0);
563 GlobalPoint globalPoint = _locationWindow!.screenPositionToGlobal(screenPoint);
564 print("Screen position (${screenPoint.x}, ${screenPoint.y}) converted to WGS84: (${globalPoint.latitude}, ${globalPoint.longitude})");
565 // [dart_LocationWindow_screenPositionToGlobal]
566
567 // [dart_LocationWindow_getVisibleRegion]
568 VisibleRegion visibleRegion = _locationWindow!.visibleRegion;
569 print("Viewport top-left: ${visibleRegion.topLeft}");
570 // [dart_LocationWindow_getVisibleRegion]
571
572 // [dart_LocationWindow_getFocusRegion]
573 VisibleRegion focusRegion = _locationWindow!.focusRegion;
574 print("Focus-rect top-left: ${focusRegion.topLeft}");
575 // [dart_LocationWindow_getFocusRegion]
576
577 // [dart_LocationWindow_globalToScreenPosition]
578 GlobalPoint globalPoint2 = GlobalPoint(55.7558, 37.6176);
579 ScreenPoint screenPoint2 = _locationWindow!.globalToScreenPosition(globalPoint2, true);
580 print("WGS84 (${globalPoint2.latitude}, ${globalPoint2.longitude}) converted to screen with clipping: (${screenPoint2.x}, ${screenPoint2.y})");
581 // [dart_LocationWindow_globalToScreenPosition]
582
583 List<ScreenPoint> testScreenPoints = [
584 ScreenPoint(0.0, 0.0),
585 ScreenPoint(250.0, 250.0),
586 ScreenPoint(1000.0, 600.0),
587 ];
588
589 for (int i = 0; i < testScreenPoints.length; i++) {
590 ScreenPoint sp = testScreenPoints[i];
591 GlobalPoint gp = _locationWindow!.screenPositionToGlobal(sp);
592 ScreenPoint backToScreen = _locationWindow!.globalToScreenPosition(gp, false);
593 print("Test $i: Screen (${sp.x}, ${sp.y}) -> WGS84 (${gp.latitude}, ${gp.longitude}) -> Screen (${backToScreen.x}, ${backToScreen.y})");
594 }
595 }
596
600 void _demonstrateMapFeatureSelection() {
601 print("--- Map Feature Selection Methods ---");
602
603 if (_locationWindow == null) {
604 print("LocationWindow not available yet");
605 return;
606 }
607
608 // [dart_LocationWindow_selectMapFeature]
609 // Select map feature by ID
610 String featureId = "room_101";
611 bool selected = _locationWindow!.selectMapFeature(featureId);
612 print("Selected map feature $featureId: $selected");
613 // [dart_LocationWindow_selectMapFeature]
614
615 // [dart_LocationWindow_selectMapFeature_2]
616 // Select another map feature
617 String featureId2 = "office_205";
618 bool selected2 = _locationWindow!.selectMapFeature(featureId2);
619 print("Selected map feature $featureId2: $selected2");
620 // [dart_LocationWindow_selectMapFeature_2]
621
622 // [dart_LocationWindow_getSelectedMapFeatures]
623 // Get list of selected map features
624 List<String> selectedFeatures = _locationWindow!.selectedMapFeatures;
625 print("Currently selected map features: ${selectedFeatures.length} features");
626 for (String feature in selectedFeatures) {
627 print(" - $feature");
628 }
629 // [dart_LocationWindow_getSelectedMapFeatures]
630
631 // [dart_LocationWindow_deselectMapFeature]
632 // Deselect specific map feature
633 bool deselected = _locationWindow!.deselectMapFeature(featureId);
634 print("Deselected map feature $featureId: $deselected");
635 // [dart_LocationWindow_deselectMapFeature]
636
637 // [dart_LocationWindow_deselectMapFeature_2]
638 // Deselect another map feature
639 bool deselected2 = _locationWindow!.deselectMapFeature(featureId2);
640 print("Deselected map feature $featureId2: $deselected2");
641 // [dart_LocationWindow_deselectMapFeature_2]
642
643 // [dart_LocationWindow_deselectAllMapFeatures]
644 // Deselect all map features
645 _locationWindow!.deselectAllMapFeatures();
646 print("Deselected all map features");
647 // [dart_LocationWindow_deselectAllMapFeatures]
648
649 // [dart_LocationWindow_getSelectedMapFeatures_2]
650 // Verify all features are deselected
651 List<String> remainingFeatures = _locationWindow!.selectedMapFeatures;
652 print("Remaining selected features after deselect all: ${remainingFeatures.length} features");
653 // [dart_LocationWindow_getSelectedMapFeatures_2]
654
655 // Test multiple feature selection and deselection
656 List<String> testFeatureIds = ["room_101", "office_205", "meeting_room_301", "cafe_401"];
657
658 // Select multiple features
659 for (String featureId in testFeatureIds) {
660 bool success = _locationWindow!.selectMapFeature(featureId);
661 print("Selected feature $featureId: $success");
662 }
663
664 // Check selected features
665 List<String> allSelected = _locationWindow!.selectedMapFeatures;
666 print("All selected features: ${allSelected.length} features");
667
668 // Deselect all at once
669 _locationWindow!.deselectAllMapFeatures();
670 print("Deselected all features at once");
671 }
672
676 void _demonstrateApplyLayerFilter() {
677 print("--- applyLayerFilter Method ---");
678
679 if (_locationWindow == null) {
680 print("LocationWindow not available yet");
681 return;
682 }
683
684 // [dart_MapFilterCondition_constructor]
685 // Create filter condition: show only venues with category "Toilet" or "Cafe"
686 final condition = MapFilterCondition(property: "category", values: ["Toilet", "Cafe"]);
687 // [dart_MapFilterCondition_constructor]
688
689 // [dart_LocationWindow_applyLayerFilter]
690 // Apply filter to venues layer
691 final conditions = [MapFilterCondition(property: "category", values: ["Toilet", "Cafe"])];
692 _locationWindow!.applyLayerFilter("venues", conditions);
693 print("Applied layer filter: show venues with category Toilet or Cafe");
694 // [dart_LocationWindow_applyLayerFilter]
695
696 // Reset filter (show all venues)
697 _locationWindow!.applyLayerFilter("venues", []);
698 print("Reset layer filter: show all venues");
699 }
700
704 void _demonstrateZoomProperties() {
705 print("--- Zoom Properties ---");
706
707 if (_locationWindow == null) {
708 print("LocationWindow not available yet");
709 return;
710 }
711
712 // [dart_LocationWindow_getZoomFactor]
713 // Get current zoom factor
714 double currentZoom = _locationWindow!.zoomFactor;
715 print("Current zoom factor: $currentZoom");
716 // [dart_LocationWindow_getZoomFactor]
717
718 // [dart_LocationWindow_setZoomFactor]
719 // Set zoom factor
720 _locationWindow!.zoomFactor = 150.0;
721 print("Set zoom factor to 150.0");
722 // [dart_LocationWindow_setZoomFactor]
723
724 // [dart_LocationWindow_getMinZoomFactor]
725 // Get minimum zoom factor
726 double minZoomFactor = _locationWindow!.minZoomFactor;
727 print("Minimum zoom factor: $minZoomFactor");
728 // [dart_LocationWindow_getMinZoomFactor]
729
730 // [dart_LocationWindow_setMinZoomFactor]
731 // Set minimum zoom factor
732 _locationWindow!.minZoomFactor = 50.0;
733 print("Set minimum zoom factor to 50.0");
734 // [dart_LocationWindow_setMinZoomFactor]
735
736 // [dart_LocationWindow_getMaxZoomFactor]
737 // Get maximum zoom factor
738 double maxZoomFactor = _locationWindow!.maxZoomFactor;
739 print("Maximum zoom factor: $maxZoomFactor");
740 // [dart_LocationWindow_getMaxZoomFactor]
741
742 // [dart_LocationWindow_setMaxZoomFactor]
743 // Set maximum zoom factor
744 _locationWindow!.maxZoomFactor = 300.0;
745 print("Set maximum zoom factor to 300.0");
746 // [dart_LocationWindow_setMaxZoomFactor]
747
748 // Test zoom factor changes
749 List<double> testZoomFactors = [100.0, 125.0, 150.0, 200.0, 250.0];
750 for (double zoom in testZoomFactors) {
751 _locationWindow!.zoomFactor = zoom;
752 print("Changed zoom factor to: ${_locationWindow!.zoomFactor}");
753 }
754
755 // Test zoom limits
756 print("Testing zoom limits...");
757 _locationWindow!.zoomFactor = _locationWindow!.minZoomFactor;
758 print("Set to minimum zoom: ${_locationWindow!.zoomFactor}");
759
760 _locationWindow!.zoomFactor = _locationWindow!.maxZoomFactor;
761 print("Set to maximum zoom: ${_locationWindow!.zoomFactor}");
762
763 // Reset to default
764 _locationWindow!.zoomFactor = 100.0;
765 print("Reset zoom factor to default: ${_locationWindow!.zoomFactor}");
766 }
767
771 Future<void> runExample() async {
772 print("=== LocationWindowCommon Example ===");
773
774 // Simulate LocationWindow initialization
775 await Future.delayed(Duration(milliseconds: 500));
776
777 // TODO: User will implement LocationWindow initialization here
778 // _locationWindow = await getLocationWindow();
779
780 // Run demonstrations
781 _demonstrateLocationWindowCommonMethods();
782
783 print("=== Example completed ===");
784 }
785}
786
790Future<void> main() async {
792 await example.runExample();
793}
794
795class DemoSublocationChangeListener implements SublocationChangeListener {
796 // [dart_SublocationChangeListener_onActiveSublocationChanged]
797 @override
798 void onActiveSublocationChanged(int sublocationId) {
799 print("Active sublocation changed to: $sublocationId");
800 }
801 // [dart_SublocationChangeListener_onActiveSublocationChanged]
802}