13class LocationWindowCommonExample {
19 LocationWindowCommonExample() {
20 _demonstrateLocationWindowCommonMethods();
26 void _demonstrateLocationWindowCommonMethods() {
27 print(
"=== LocationWindowCommon Methods ===");
29 _demonstrateSetSublocationId();
30 _demonstrateSublocationQueries();
31 _demonstrateSublocationChangeListener();
32 _demonstrateUserLocationView();
33 _demonstrateUserLocationLayer();
34 _demonstrateCoordinateConversion();
35 _demonstrateMapFeatureSelection();
36 _demonstrateZoomProperties();
42 void _demonstrateSetSublocationId() {
43 print(
"--- setSublocationId Method ---");
45 if (_locationWindow ==
null) {
46 print(
"LocationWindow not available yet");
52 _locationWindow!.setSublocationId(1);
53 print(
"Set sublocation ID to 1 (first floor)");
58 _locationWindow!.setSublocationId(2);
59 print(
"Set sublocation ID to 2 (second floor)");
64 _locationWindow!.setSublocationId(0);
65 print(
"Set sublocation ID to 0 (ground floor)");
69 List<int> sublocationIds = [1, 2, 3, 0, 5];
70 for (
int id in sublocationIds) {
71 _locationWindow!.setSublocationId(
id);
72 print(
"Switched to sublocation ID: $id");
79 void _demonstrateSublocationQueries() {
80 print(
"--- getSublocationId & getEnclosingCamera ---");
82 if (_locationWindow ==
null) {
83 print(
"LocationWindow not available yet");
88 int? currentId = _locationWindow!.getSublocationId();
89 if (currentId !=
null) {
90 print(
"Current sublocation id: $currentId");
92 print(
"Current sublocation id is not set");
98 Camera camera = _locationWindow!.getEnclosingCamera(boundingBox);
99 print(
"Camera that fits bounding box: $camera");
106 void _demonstrateSublocationChangeListener() {
107 print(
"--- Sublocation Change Listener ---");
109 if (_locationWindow ==
null) {
110 print(
"LocationWindow not available yet");
114 DemoSublocationChangeListener listener = DemoSublocationChangeListener();
117 _locationWindow!.addSublocationChangeListener(listener);
118 print(
"Added sublocation change listener");
121 _locationWindow!.setSublocationId(1);
122 _locationWindow!.setSublocationId(2);
125 _locationWindow!.removeSublocationChangeListener(listener);
126 print(
"Removed sublocation change listener");
133 void _demonstrateUserLocationView() {
134 print(
"--- UserLocationView ---");
136 if (_userLocationView ==
null) {
137 print(
"UserLocationView not available yet");
143 print(
"Arrow icon object: $arrow");
148 print(
"Accuracy circle object: $accuracyCircle");
155 void _demonstrateUserLocationLayer() {
156 print(
"--- UserLocationLayer ---");
158 if (_userLocationLayer ==
null) {
159 print(
"UserLocationLayer not available yet");
164 _userLocationLayer!.setVisible(
true);
165 print(
"User location layer set visible");
169 bool visible = _userLocationLayer!.isVisible();
170 print(
"User location layer is visible: $visible");
174 ScreenPoint anchor = ScreenPoint(100.0, 200.0);
175 _userLocationLayer!.setAnchor(anchor);
176 print(
"Set user location anchor to: (${anchor.x}, ${anchor.y})");
180 bool anchorEnabled = _userLocationLayer!.anchorEnabled();
181 print(
"Anchor enabled: $anchorEnabled");
185 _userLocationLayer!.resetAnchor();
186 print(
"Anchor reset to default");
193 void _demonstrateCoordinateConversion() {
194 print(
"--- Coordinate Conversion Methods ---");
196 if (_locationWindow ==
null) {
197 print(
"LocationWindow not available yet");
204 Point metersPoint = _locationWindow!.screenPositionToMeters(screenPoint);
205 print(
"Screen position (${screenPoint.x}, ${screenPoint.y}) converted to meters: (${metersPoint.x}, ${metersPoint.y})");
211 Point metersPoint2 = _locationWindow!.screenPositionToMeters(screenPoint2);
212 print(
"Screen position (${screenPoint2.x}, ${screenPoint2.y}) converted to meters: (${metersPoint2.x}, ${metersPoint2.y})");
218 Point screenPoint3 = _locationWindow!.metersToScreenPosition(metersPoint3,
true);
219 print(
"Meters position (${metersPoint3.x}, ${metersPoint3.y}) converted to screen with clipping: (${screenPoint3.x}, ${screenPoint3.y})");
225 Point screenPoint4 = _locationWindow!.metersToScreenPosition(metersPoint4,
false);
226 print(
"Meters position (${metersPoint4.x}, ${metersPoint4.y}) converted to screen without clipping: (${screenPoint4.x}, ${screenPoint4.y})");
230 List<Point> testScreenPoints = [
233 Point(1000.0, 600.0),
236 for (
int i = 0; i < testScreenPoints.length; i++) {
237 Point screenPoint = testScreenPoints[i];
238 Point metersPoint = _locationWindow!.screenPositionToMeters(screenPoint);
239 Point backToScreen = _locationWindow!.metersToScreenPosition(metersPoint,
false);
240 print(
"Test $i: Screen (${screenPoint.x}, ${screenPoint.y}) -> Meters (${metersPoint.x}, ${metersPoint.y}) -> Screen (${backToScreen.x}, ${backToScreen.y})");
247 void _demonstrateMapFeatureSelection() {
248 print(
"--- Map Feature Selection Methods ---");
250 if (_locationWindow ==
null) {
251 print(
"LocationWindow not available yet");
257 String featureId =
"room_101";
258 bool selected = _locationWindow!.selectMapFeature(featureId);
259 print(
"Selected map feature $featureId: $selected");
264 String featureId2 =
"office_205";
265 bool selected2 = _locationWindow!.selectMapFeature(featureId2);
266 print(
"Selected map feature $featureId2: $selected2");
271 List<String> selectedFeatures = _locationWindow!.selectedMapFeatures;
272 print(
"Currently selected map features: ${selectedFeatures.length} features");
273 for (String feature in selectedFeatures) {
274 print(
" - $feature");
280 bool deselected = _locationWindow!.deselectMapFeature(featureId);
281 print(
"Deselected map feature $featureId: $deselected");
286 bool deselected2 = _locationWindow!.deselectMapFeature(featureId2);
287 print(
"Deselected map feature $featureId2: $deselected2");
292 _locationWindow!.deselectAllMapFeatures();
293 print(
"Deselected all map features");
298 List<String> remainingFeatures = _locationWindow!.selectedMapFeatures;
299 print(
"Remaining selected features after deselect all: ${remainingFeatures.length} features");
303 List<String> testFeatureIds = [
"room_101",
"office_205",
"meeting_room_301",
"cafe_401"];
306 for (String featureId in testFeatureIds) {
307 bool success = _locationWindow!.selectMapFeature(featureId);
308 print(
"Selected feature $featureId: $success");
312 List<String> allSelected = _locationWindow!.selectedMapFeatures;
313 print(
"All selected features: ${allSelected.length} features");
316 _locationWindow!.deselectAllMapFeatures();
317 print(
"Deselected all features at once");
323 void _demonstrateZoomProperties() {
324 print(
"--- Zoom Properties ---");
326 if (_locationWindow ==
null) {
327 print(
"LocationWindow not available yet");
333 double currentZoom = _locationWindow!.zoomFactor;
334 print(
"Current zoom factor: $currentZoom");
339 _locationWindow!.zoomFactor = 150.0;
340 print(
"Set zoom factor to 150.0");
345 double minZoomFactor = _locationWindow!.minZoomFactor;
346 print(
"Minimum zoom factor: $minZoomFactor");
351 _locationWindow!.minZoomFactor = 50.0;
352 print(
"Set minimum zoom factor to 50.0");
357 double maxZoomFactor = _locationWindow!.maxZoomFactor;
358 print(
"Maximum zoom factor: $maxZoomFactor");
363 _locationWindow!.maxZoomFactor = 300.0;
364 print(
"Set maximum zoom factor to 300.0");
368 List<double> testZoomFactors = [100.0, 125.0, 150.0, 200.0, 250.0];
369 for (
double zoom in testZoomFactors) {
370 _locationWindow!.zoomFactor = zoom;
371 print(
"Changed zoom factor to: ${_locationWindow!.zoomFactor}");
375 print(
"Testing zoom limits...");
376 _locationWindow!.zoomFactor = _locationWindow!.minZoomFactor;
377 print(
"Set to minimum zoom: ${_locationWindow!.zoomFactor}");
379 _locationWindow!.zoomFactor = _locationWindow!.maxZoomFactor;
380 print(
"Set to maximum zoom: ${_locationWindow!.zoomFactor}");
383 _locationWindow!.zoomFactor = 100.0;
384 print(
"Reset zoom factor to default: ${_locationWindow!.zoomFactor}");
390 Future<void> runExample() async {
391 print(
"=== LocationWindowCommon Example ===");
394 await Future.delayed(Duration(milliseconds: 500));
400 _demonstrateLocationWindowCommonMethods();
402 print(
"=== Example completed ===");