51class LocationWindowCommonExample {
59 LocationWindowCommonExample() {
60 _demonstrateLocationWindowCommonMethods();
66 void _demonstrateLocationWindowCommonMethods() {
67 print(
"=== LocationWindowCommon Methods ===");
69 _demonstrateSetSublocationId();
70 _demonstrateOperatingMode();
71 _demonstrateSublocationQueries();
72 _demonstrateSublocationChangeListener();
73 _demonstrateUserLocationLayer();
74 _demonstrateRouteLayer();
75 _demonstrateCoordinateConversion();
76 _demonstrateMapFeatureSelection();
77 _demonstrateApplyLayerFilter();
78 _demonstrateDebugFlags();
79 _demonstrateZoomProperties();
85 void _demonstrateDebugFlags() {
86 print(
"--- Debug flags ---");
94 DebugFlag.DRAW_ALL_LABELS,
95 DebugFlag.SELECTION_BUFFER,
97 print(
"Debug flag enum values: ${allFlags.length}");
101 LocationWindow.setDebugFlag(DebugFlag.INFOS,
true);
102 LocationWindow.setDebugFlag(DebugFlag.STATS,
false);
103 print(
"Updated debug flags on LocationWindow");
107 bool infosOn = LocationWindow.getDebugFlag(DebugFlag.INFOS);
108 print(
"Debug flag INFOS enabled: $infosOn");
113 void _demonstrateOperatingMode() {
114 print(
"--- Operating Mode ---");
117 print(
"LocationWindow not available yet");
123 OperatingMode.INDOOR_ONLY,
124 OperatingMode.OUTDOOR,
125 OperatingMode.OUTDOOR_INDOOR,
127 print(
"Operating modes: ${modes.length}");
132 print(
"Set operating mode to OUTDOOR_INDOOR");
137 print(
"Current operating mode: $currentMode");
141 final themes = [MapTheme.LIGHT, MapTheme.DARK];
142 print(
"Map themes: ${themes.length}");
147 print(
"Set map theme to DARK");
152 print(
"Current map theme: $currentTheme");
156 final kinds = [TileKind.VECTOR, TileKind.RASTER];
157 print(
"Tile kinds: ${kinds.length}");
161 final schemas = [TileSchema.SHORTBREAD, TileSchema.OPEN_MAP_TILES, TileSchema.MAPBOX_STREETS];
162 print(
"Tile schemas: ${schemas.length}");
166 final http = HttpTileSource(
167 urlTemplate:
"https://api.maptiler.com/tiles/v3-openmaptiles/{z}/{x}/{y}.pbf",
169 queryParameters: {
"key":
"YOUR_MAPTILER_KEY"},
174 final offline = MbtilesTileSource(path:
"/path/to/map.mbtiles");
178 final osmHttp = TileProvider(
179 schema: TileSchema.OPEN_MAP_TILES,
185 kind: TileKind.VECTOR,
187 final mbtiles = TileProvider(
188 schema: TileSchema.SHORTBREAD,
194 kind: TileKind.VECTOR,
201 final imagery = TileProvider(
202 schema: TileSchema.SHORTBREAD,
203 http: HttpTileSource(
204 urlTemplate:
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
206 queryParameters:
null,
211 attribution:
"© OpenStreetMap contributors",
212 kind: TileKind.RASTER,
218 final alignment = AttributionAlignment(
219 AttributionHorizontalAlignment.RIGHT,
220 AttributionVerticalAlignment.BOTTOM,
230 print(
"Attribution: $attribution");
237 void _demonstrateSetSublocationId() {
238 print(
"--- setSublocationId Method ---");
241 print(
"LocationWindow not available yet");
248 print(
"Set sublocation ID to 1 (first floor)");
254 print(
"Set sublocation ID to 2 (second floor)");
260 print(
"Set sublocation ID to 0 (ground floor)");
264 List<int> sublocationIds = [1, 2, 3, 0, 5];
265 for (
int id in sublocationIds) {
267 print(
"Switched to sublocation ID: $id");
274 void _demonstrateSublocationQueries() {
275 print(
"--- getSublocationId & getEnclosingCamera ---");
278 print(
"LocationWindow not available yet");
284 if (currentId !=
null) {
285 print(
"Current sublocation id: $currentId");
287 print(
"Current sublocation id is not set");
292 BoundingBox boundingBox = BoundingBox(
293 GlobalPoint(55.75, 37.61), GlobalPoint(55.76, 37.63));
295 print(
"Camera that fits bounding box: $camera");
299 ScreenRect focus = ScreenRect(
301 ScreenPoint(1000, 1600),
313 print(
"Camera that fits bounding box in focus rect: $padded");
320 void _demonstrateSublocationChangeListener() {
321 print(
"--- Sublocation Change Listener ---");
324 print(
"LocationWindow not available yet");
328 DemoSublocationChangeListener listener = DemoSublocationChangeListener();
332 print(
"Added sublocation change listener");
340 print(
"Removed sublocation change listener");
347 void _demonstrateUserLocationLayer() {
348 print(
"--- UserLocationLayer ---");
351 print(
"UserLocationLayer not available yet");
357 print(
"User location layer set visible");
362 print(
"User location layer is visible: $visible");
366 ScreenPoint anchor = ScreenPoint(100.0, 200.0);
368 print(
"Set user location anchor to: (${anchor.x}, ${anchor.y})");
373 print(
"Anchor enabled: $anchorEnabled");
378 print(
"Heading-up mode enabled");
383 print(
"Heading-up mode active: $headingModeActive");
388 print(
"Follow mode set to heading");
393 print(
"Follow mode: $followMode");
398 const AssetImage(
'assets/arrow.png'),
402 print(
"Custom arrow bitmap cleared");
407 print(
"Accuracy circle color updated");
412 print(
"Anchor reset to default");
419 void _demonstrateRouteLayer() {
420 print(
"--- RouteLayer ---");
423 print(
"RouteLayer not available yet");
429 print(
"Route layer set visible");
434 print(
"Route layer is visible: $visible");
438 _routeLayer!.setTraveledColor(
const Color(0xB4787878));
439 print(
"Traveled color updated");
443 _routeLayer!.setRemainingColor(
const Color(0xFF30AAD9));
444 print(
"Remaining color updated");
449 print(
"Route width updated");
453 _routeLayer!.setRemainingStyle(RouteRemainingStyle.DOTTED);
454 print(
"Remaining style set to DOTTED");
458 RouteRemainingStyle remainingStyle =
_routeLayer!.remainingStyle();
459 print(
"Remaining style: $remainingStyle");
464 print(
"Remaining point size updated");
468 _routeLayer!.setRemainingPlacement(Placement.SPACED);
469 print(
"Remaining placement updated");
474 print(
"Remaining placement spacing updated");
479 print(
"Remaining placement min ratio updated");
484 print(
"Remaining collision disabled");
489 print(
"Remaining dash length updated");
494 print(
"Remaining gap length updated");
497 final from = RouteEndpoint(
498 point: GlobalPoint(latitude: 55.751244, longitude: 37.618423),
501 final to = RouteEndpoint(
502 point: GlobalPoint(latitude: 55.751700, longitude: 37.619000),
508 print(
"Static route applied");
513 print(
"Guidance target applied");
518 print(
"Visible routes: ${routes.length}");
522 final selectedRoute =
_routeLayer!.selectedRoute();
523 if (selectedRoute !=
null) {
524 print(
"Selected route length: ${selectedRoute.length()}");
529 if (routes.isNotEmpty) {
546 print(
"Route layer cleared");
553 void _demonstrateCoordinateConversion() {
554 print(
"--- Coordinate Conversion Methods ---");
557 print(
"LocationWindow not available yet");
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})");
569 print(
"Viewport top-left: ${visibleRegion.topLeft}");
574 print(
"Focus-rect top-left: ${focusRegion.topLeft}");
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})");
583 List<ScreenPoint> testScreenPoints = [
584 ScreenPoint(0.0, 0.0),
585 ScreenPoint(250.0, 250.0),
586 ScreenPoint(1000.0, 600.0),
589 for (
int i = 0; i < testScreenPoints.length; i++) {
590 ScreenPoint sp = testScreenPoints[i];
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})");
600 void _demonstrateMapFeatureSelection() {
601 print(
"--- Map Feature Selection Methods ---");
604 print(
"LocationWindow not available yet");
610 String featureId =
"room_101";
612 print(
"Selected map feature $featureId: $selected");
617 String featureId2 =
"office_205";
619 print(
"Selected map feature $featureId2: $selected2");
625 print(
"Currently selected map features: ${selectedFeatures.length} features");
626 for (String feature in selectedFeatures) {
627 print(
" - $feature");
634 print(
"Deselected map feature $featureId: $deselected");
640 print(
"Deselected map feature $featureId2: $deselected2");
646 print(
"Deselected all map features");
652 print(
"Remaining selected features after deselect all: ${remainingFeatures.length} features");
656 List<String> testFeatureIds = [
"room_101",
"office_205",
"meeting_room_301",
"cafe_401"];
659 for (String featureId in testFeatureIds) {
661 print(
"Selected feature $featureId: $success");
666 print(
"All selected features: ${allSelected.length} features");
670 print(
"Deselected all features at once");
676 void _demonstrateApplyLayerFilter() {
677 print(
"--- applyLayerFilter Method ---");
680 print(
"LocationWindow not available yet");
686 final condition = MapFilterCondition(property:
"category", values: [
"Toilet",
"Cafe"]);
691 final conditions = [MapFilterCondition(property:
"category", values: [
"Toilet",
"Cafe"])];
693 print(
"Applied layer filter: show venues with category Toilet or Cafe");
698 print(
"Reset layer filter: show all venues");
704 void _demonstrateZoomProperties() {
705 print(
"--- Zoom Properties ---");
708 print(
"LocationWindow not available yet");
715 print(
"Current zoom factor: $currentZoom");
721 print(
"Set zoom factor to 150.0");
727 print(
"Minimum zoom factor: $minZoomFactor");
733 print(
"Set minimum zoom factor to 50.0");
739 print(
"Maximum zoom factor: $maxZoomFactor");
745 print(
"Set maximum zoom factor to 300.0");
749 List<double> testZoomFactors = [100.0, 125.0, 150.0, 200.0, 250.0];
750 for (
double zoom in testZoomFactors) {
752 print(
"Changed zoom factor to: ${_locationWindow!.zoomFactor}");
756 print(
"Testing zoom limits...");
758 print(
"Set to minimum zoom: ${_locationWindow!.zoomFactor}");
761 print(
"Set to maximum zoom: ${_locationWindow!.zoomFactor}");
765 print(
"Reset zoom factor to default: ${_locationWindow!.zoomFactor}");
771 Future<void> runExample() async {
772 print(
"=== LocationWindowCommon Example ===");
775 await Future.delayed(Duration(milliseconds: 500));
781 _demonstrateLocationWindowCommonMethods();
783 print(
"=== Example completed ===");