13class LocationWindowCommonExample {
18 LocationWindowCommonExample() {
19 _demonstrateLocationWindowCommonMethods();
25 void _demonstrateLocationWindowCommonMethods() {
26 print(
"=== LocationWindowCommon Methods ===");
28 _demonstrateSetSublocationId();
29 _demonstrateOperatingMode();
30 _demonstrateSublocationQueries();
31 _demonstrateSublocationChangeListener();
32 _demonstrateUserLocationLayer();
33 _demonstrateCoordinateConversion();
34 _demonstrateMapFeatureSelection();
35 _demonstrateApplyLayerFilter();
36 _demonstrateDebugFlags();
37 _demonstrateZoomProperties();
43 void _demonstrateDebugFlags() {
44 print(
"--- Debug flags ---");
52 DebugFlag.DRAW_ALL_LABELS,
53 DebugFlag.SELECTION_BUFFER,
55 print(
"Debug flag enum values: ${allFlags.length}");
59 LocationWindow.setDebugFlag(DebugFlag.INFOS,
true);
60 LocationWindow.setDebugFlag(DebugFlag.STATS,
false);
61 print(
"Updated debug flags on LocationWindow");
65 bool infosOn = LocationWindow.getDebugFlag(DebugFlag.INFOS);
66 print(
"Debug flag INFOS enabled: $infosOn");
71 void _demonstrateOperatingMode() {
72 print(
"--- Operating Mode ---");
75 print(
"LocationWindow not available yet");
81 OperatingMode.INDOOR_ONLY,
82 OperatingMode.OUTDOOR,
83 OperatingMode.OUTDOOR_INDOOR,
85 print(
"Operating modes: ${modes.length}");
90 print(
"Set operating mode to OUTDOOR_INDOOR");
95 print(
"Current operating mode: $currentMode");
99 final alignment = AttributionAlignment(
100 AttributionHorizontalAlignment.RIGHT,
101 AttributionVerticalAlignment.BOTTOM,
111 print(
"Attribution: $attribution");
118 void _demonstrateSetSublocationId() {
119 print(
"--- setSublocationId Method ---");
122 print(
"LocationWindow not available yet");
129 print(
"Set sublocation ID to 1 (first floor)");
135 print(
"Set sublocation ID to 2 (second floor)");
141 print(
"Set sublocation ID to 0 (ground floor)");
145 List<int> sublocationIds = [1, 2, 3, 0, 5];
146 for (
int id in sublocationIds) {
148 print(
"Switched to sublocation ID: $id");
155 void _demonstrateSublocationQueries() {
156 print(
"--- getSublocationId & getEnclosingCamera ---");
159 print(
"LocationWindow not available yet");
165 if (currentId !=
null) {
166 print(
"Current sublocation id: $currentId");
168 print(
"Current sublocation id is not set");
173 BoundingBox boundingBox = BoundingBox(
174 GlobalPoint(55.75, 37.61), GlobalPoint(55.76, 37.63));
176 print(
"Camera that fits bounding box: $camera");
183 void _demonstrateSublocationChangeListener() {
184 print(
"--- Sublocation Change Listener ---");
187 print(
"LocationWindow not available yet");
191 DemoSublocationChangeListener listener = DemoSublocationChangeListener();
195 print(
"Added sublocation change listener");
203 print(
"Removed sublocation change listener");
210 void _demonstrateUserLocationLayer() {
211 print(
"--- UserLocationLayer ---");
214 print(
"UserLocationLayer not available yet");
220 print(
"User location layer set visible");
225 print(
"User location layer is visible: $visible");
229 ScreenPoint anchor = ScreenPoint(100.0, 200.0);
231 print(
"Set user location anchor to: (${anchor.x}, ${anchor.y})");
236 print(
"Anchor enabled: $anchorEnabled");
241 print(
"Anchor reset to default");
248 void _demonstrateCoordinateConversion() {
249 print(
"--- Coordinate Conversion Methods ---");
252 print(
"LocationWindow not available yet");
257 ScreenPoint screenPoint = ScreenPoint(100.0, 200.0);
258 GlobalPoint globalPoint =
_locationWindow!.screenPositionToGlobal(screenPoint);
259 print(
"Screen position (${screenPoint.x}, ${screenPoint.y}) converted to WGS84: (${globalPoint.latitude}, ${globalPoint.longitude})");
263 GlobalPoint globalPoint2 = GlobalPoint(55.7558, 37.6176);
264 ScreenPoint screenPoint2 =
_locationWindow!.globalToScreenPosition(globalPoint2,
true);
265 print(
"WGS84 (${globalPoint2.latitude}, ${globalPoint2.longitude}) converted to screen with clipping: (${screenPoint2.x}, ${screenPoint2.y})");
268 List<ScreenPoint> testScreenPoints = [
269 ScreenPoint(0.0, 0.0),
270 ScreenPoint(250.0, 250.0),
271 ScreenPoint(1000.0, 600.0),
274 for (
int i = 0; i < testScreenPoints.length; i++) {
275 ScreenPoint sp = testScreenPoints[i];
277 ScreenPoint backToScreen =
_locationWindow!.globalToScreenPosition(gp,
false);
278 print(
"Test $i: Screen (${sp.x}, ${sp.y}) -> WGS84 (${gp.latitude}, ${gp.longitude}) -> Screen (${backToScreen.x}, ${backToScreen.y})");
285 void _demonstrateMapFeatureSelection() {
286 print(
"--- Map Feature Selection Methods ---");
289 print(
"LocationWindow not available yet");
295 String featureId =
"room_101";
297 print(
"Selected map feature $featureId: $selected");
302 String featureId2 =
"office_205";
304 print(
"Selected map feature $featureId2: $selected2");
310 print(
"Currently selected map features: ${selectedFeatures.length} features");
311 for (String feature in selectedFeatures) {
312 print(
" - $feature");
319 print(
"Deselected map feature $featureId: $deselected");
325 print(
"Deselected map feature $featureId2: $deselected2");
331 print(
"Deselected all map features");
337 print(
"Remaining selected features after deselect all: ${remainingFeatures.length} features");
341 List<String> testFeatureIds = [
"room_101",
"office_205",
"meeting_room_301",
"cafe_401"];
344 for (String featureId in testFeatureIds) {
346 print(
"Selected feature $featureId: $success");
351 print(
"All selected features: ${allSelected.length} features");
355 print(
"Deselected all features at once");
361 void _demonstrateApplyLayerFilter() {
362 print(
"--- applyLayerFilter Method ---");
365 print(
"LocationWindow not available yet");
371 final condition = MapFilterCondition(property:
"category", values: [
"Toilet",
"Cafe"]);
376 final conditions = [MapFilterCondition(property:
"category", values: [
"Toilet",
"Cafe"])];
378 print(
"Applied layer filter: show venues with category Toilet or Cafe");
383 print(
"Reset layer filter: show all venues");
389 void _demonstrateZoomProperties() {
390 print(
"--- Zoom Properties ---");
393 print(
"LocationWindow not available yet");
400 print(
"Current zoom factor: $currentZoom");
406 print(
"Set zoom factor to 150.0");
412 print(
"Minimum zoom factor: $minZoomFactor");
418 print(
"Set minimum zoom factor to 50.0");
424 print(
"Maximum zoom factor: $maxZoomFactor");
430 print(
"Set maximum zoom factor to 300.0");
434 List<double> testZoomFactors = [100.0, 125.0, 150.0, 200.0, 250.0];
435 for (
double zoom in testZoomFactors) {
437 print(
"Changed zoom factor to: ${_locationWindow!.zoomFactor}");
441 print(
"Testing zoom limits...");
443 print(
"Set to minimum zoom: ${_locationWindow!.zoomFactor}");
446 print(
"Set to maximum zoom: ${_locationWindow!.zoomFactor}");
450 print(
"Reset zoom factor to default: ${_locationWindow!.zoomFactor}");
456 Future<void> runExample() async {
457 print(
"=== LocationWindowCommon Example ===");
460 await Future.delayed(Duration(milliseconds: 500));
466 _demonstrateLocationWindowCommonMethods();
468 print(
"=== Example completed ===");