Loading...
Searching...
No Matches
location_window_map_objects_example.dart
Go to the documentation of this file.
1import 'dart:ffi';
2import 'dart:math' as math;
3import 'dart:typed_data';
4import 'package:meta/meta.dart';
5import 'package:navigine_sdk/com/_library_context.dart' as __lib;
6import 'package:navigine_sdk/com/_native_base.dart' as __lib;
7import 'package:navigine_sdk/com/_weak_map.dart';
8import 'package:navigine_sdk/com/builtin_types__conversion.dart';
9import 'package:navigine_sdk/com/navigine/idl/animation_type.dart';
10import 'package:navigine_sdk/com/navigine/idl/cap_type.dart';
11import 'package:navigine_sdk/com/navigine/idl/circle_map_object.dart';
12import 'package:navigine_sdk/com/navigine/idl/dotted_polyline_map_object.dart';
13import 'package:navigine_sdk/com/navigine/idl/icon_map_object.dart';
14import 'package:navigine_sdk/com/navigine/idl/join_type.dart';
15import 'package:navigine_sdk/com/navigine/idl/location_point.dart';
16import 'package:navigine_sdk/com/navigine/sdk/location_polygon.dart';
17import 'package:navigine_sdk/com/navigine/sdk/location_polyline.dart';
18import 'package:navigine_sdk/com/navigine/idl/map_object.dart';
19import 'package:navigine_sdk/com/navigine/idl/map_object_type.dart';
20import 'package:navigine_sdk/com/navigine/idl/placement.dart';
21import 'package:navigine_sdk/com/navigine/idl/point.dart';
22import 'package:navigine_sdk/com/navigine/idl/polygon.dart';
23import 'package:navigine_sdk/com/navigine/idl/polygon_map_object.dart';
24import 'package:navigine_sdk/com/navigine/idl/polyline.dart';
25import 'package:navigine_sdk/com/navigine/idl/polyline_map_object.dart';
26import 'package:navigine_sdk/image_wrapper.dart';
27
34class LocationWindowMapObjectsExample {
35 LocationWindow? _locationWindow;
36 CircleMapObject? _circleMapObject;
37 IconMapObject? _iconMapObject;
38 PolygonMapObject? _polygonMapObject;
39 PolylineMapObject? _polylineMapObject;
40 DottedPolylineMapObject? _dottedPolylineMapObject;
41
42 LocationWindowMapObjectsExample() {
43 _demonstrateLocationWindowMapObjectsMethods();
44 }
45
49 void _demonstrateLocationWindowMapObjectsMethods() {
50 print("=== LocationWindowMapObjects Example ===");
51
52 _demonstrateCircleMapObjects();
53 _demonstrateIconMapObjects();
54 _demonstratePolygonMapObjects();
55 _demonstratePolylineMapObjects();
56 _demonstrateDottedPolylineMapObjects();
57 _demonstrateRemoveAllMapObjects();
58 _cleanup();
59 }
60
64 void _demonstrateCircleMapObjects() {
65 print("--- Circle Map Objects ---");
66
67 if (_locationWindow == null) {
68 print("LocationWindow not available yet");
69 return;
70 }
71
72 // [dart_CircleMapObject_constructor]
73 // Create circle map object
74 LocationPoint center = LocationPoint(10.0, 20.0);
75 _circleMapObject = _locationWindow!.addCircleMapObject();
76 print(
77 "Created circle map object with center (${center.x}, ${center.y}) and radius 5.0",
78 );
79 // [dart_CircleMapObject_constructor]
80
81 // [dart_CircleMapObject_getCenter]
82 // Access circle center
83 LocationPoint circleCenter = _circleMapObject!.getPosition();
84 print("Circle center: (${circleCenter.x}, ${circleCenter.y})");
85 // [dart_CircleMapObject_getCenter]
86
87 // [dart_CircleMapObject_getRadius]
88 // Access circle radius
89 double radius = _circleMapObject!.getRadius();
90 print("Circle radius: $radius");
91 // [dart_CircleMapObject_getRadius]
92
93 // [dart_LocationWindow_addCircleMapObject]
94 // Add circle map object
95 _circleMapObject = _locationWindow!.addCircleMapObject();
96 print("Added circle map object");
97 // [dart_LocationWindow_addCircleMapObject]
98
99 if (_circleMapObject != null) {
100 // [dart_CircleMapObject_setPosition]
101 // Set circle position
102 LocationPoint centerPoint = LocationPoint(100.0, 200.0);
103 bool success = _circleMapObject!.setPosition(centerPoint);
104 print(
105 "Set circle position to (${centerPoint.x}, ${centerPoint.y}): $success",
106 );
107 // [dart_CircleMapObject_setPosition]
108
109 // [dart_CircleMapObject_setPositionAnimated]
110 // Set circle position with animation
111 LocationPoint animatedPoint = LocationPoint(150.0, 250.0);
112 bool animatedSuccess = _circleMapObject!.setPositionAnimated(
113 animatedPoint,
114 2.0,
115 AnimationType.LINEAR,
116 );
117 print(
118 "Set circle position with animation to (${animatedPoint.x}, ${animatedPoint.y}): $animatedSuccess",
119 );
120 // [dart_CircleMapObject_setPositionAnimated]
121
122 // [dart_CircleMapObject_setOffset]
123 // Set position offset
124 bool offsetSuccess = _circleMapObject!.setOffset(2.0, 3.0);
125 print("Set position offset to (2.0, 3.0) pixels: $offsetSuccess");
126 // [dart_CircleMapObject_setOffset]
127
128 // [dart_CircleMapObject_setOutlineColor]
129 // Set outline color
130 bool outlineColorSuccess = _circleMapObject!.setOutlineColor(
131 0.0,
132 0.0,
133 1.0,
134 1.0,
135 );
136 print("Set circle outline color to blue: $outlineColorSuccess");
137 // [dart_CircleMapObject_setOutlineColor]
138
139 // [dart_CircleMapObject_setOutlineAlpha]
140 // Set outline alpha
141 bool outlineAlphaSuccess = _circleMapObject!.setOutlineAlpha(0.5);
142 print("Set circle outline alpha to 0.5: $outlineAlphaSuccess");
143 // [dart_CircleMapObject_setOutlineAlpha]
144
145 // [dart_CircleMapObject_setOutlineRadius]
146 // Set outline radius
147 bool outlineRadiusSuccess = _circleMapObject!.setOutlineRadius(2.0);
148 print("Set circle outline radius to 2.0: $outlineRadiusSuccess");
149 // [dart_CircleMapObject_setOutlineRadius]
150
151 // [dart_CircleMapObject_setColor]
152 // Set circle color
153 bool colorSuccess = _circleMapObject!.setColor(1.0, 0.0, 0.0, 0.8);
154 print("Set circle color to red with 80% opacity: $colorSuccess");
155 // [dart_CircleMapObject_setColor]
156
157 // [dart_CircleMapObject_setRadius]
158 // Set circle radius
159 bool radiusSuccess = _circleMapObject!.setRadius(10.0);
160 print("Set circle radius to 10.0 meters: $radiusSuccess");
161 // [dart_CircleMapObject_setRadius]
162
163 // [dart_CircleMapObject_setCollisionEnabled]
164 // Enable collision detection
165 bool collisionSuccess = _circleMapObject!.setCollisionEnabled(true);
166 print("Enabled collision detection for circle: $collisionSuccess");
167 // [dart_CircleMapObject_setCollisionEnabled]
168
169 // [dart_CircleMapObject_setBuffer]
170 // Set collision buffer
171 bool bufferSuccess = _circleMapObject!.setBuffer(5.0, 5.0);
172 print("Set collision buffer to 5x5 pixels: $bufferSuccess");
173 // [dart_CircleMapObject_setBuffer]
174
175 // [dart_CircleMapObject_setPriority]
176 // Set rendering priority
177 bool prioritySuccess = _circleMapObject!.setPriority(1);
178 print("Set rendering priority to 1: $prioritySuccess");
179 // [dart_CircleMapObject_setPriority]
180
181 // [dart_MapObject_setVisible]
182 // Set visibility
183 bool visibleSuccess = _circleMapObject!.setVisible(true);
184 print("Set circle visibility to true: $visibleSuccess");
185 // [dart_MapObject_setVisible]
186
187 // [dart_CircleMapObject_getMapObjectType]
188 // Get map object type
189 MapObjectType objectType = _circleMapObject!.mapObjectType;
190 print("Circle map object type: $objectType");
191 // [dart_CircleMapObject_getMapObjectType]
192
193 // [dart_MapObject_setAlpha]
194 // Set alpha transparency
195 bool alphaSuccess = _circleMapObject!.setAlpha(0.7);
196 print("Set circle alpha to 0.7: $alphaSuccess");
197 // [dart_MapObject_setAlpha]
198
199 // [dart_MapObject_setInteractive]
200 // Set interactive mode
201 bool interactiveSuccess = _circleMapObject!.setInteractive(true);
202 print("Set circle interactive to true: $interactiveSuccess");
203 // [dart_MapObject_setInteractive]
204
205 // [dart_MapObject_setTitle]
206 // Set title
207 bool titleSuccess = _circleMapObject!.setTitle("Circle Object");
208 print("Set circle title to 'Circle Object': $titleSuccess");
209 // [dart_MapObject_setTitle]
210
211 // [dart_MapObject_setData]
212 // Set custom data
213 Map<String, dynamic> customData = {"key": "value", "number": 42};
214 bool dataSuccess = _circleMapObject!.setData(customData);
215 print("Set circle custom data: $dataSuccess");
216 // [dart_MapObject_setData]
217
218 // [dart_MapObject_getId]
219 // Get object ID
220 int objectId = _circleMapObject!.id;
221 print("Circle object ID: $objectId");
222 // [dart_MapObject_getId]
223
224 // [dart_MapObject_getType]
225 // Get object type
226 String objectTypeString = _circleMapObject!.type;
227 print("Circle object type: $objectTypeString");
228 // [dart_MapObject_getType]
229
230 // [dart_MapObject_getData]
231 // Get custom data
232 Map<String, dynamic> retrievedData = _circleMapObject!.data;
233 print("Circle custom data: $retrievedData");
234 // [dart_MapObject_getData]
235 }
236
237 // [dart_LocationWindow_removeCircleMapObject]
238 // Remove circle map object
239 if (_circleMapObject != null) {
240 bool removed = _locationWindow!.removeCircleMapObject(_circleMapObject!);
241 print("Removed circle map object: $removed");
242 _circleMapObject = null;
243 }
244 // [dart_LocationWindow_removeCircleMapObject]
245
246 // Test multiple circle objects
247 List<CircleMapObject> circles = [];
248 for (int i = 0; i < 3; i++) {
249 CircleMapObject circle = _locationWindow!.addCircleMapObject();
250 if (circle != null) {
251 circle.setPosition(LocationPoint(50.0 * i, 100.0 * i));
252 circle.setColor(0.0, 1.0, 0.0, 0.6);
253 circle.setRadius(5.0 + i * 2.0);
254 circles.add(circle);
255 print(
256 "Created circle $i at (${50.0 * i}, ${100.0 * i}) with radius ${5.0 + i * 2.0}",
257 );
258 }
259 }
260
261 for (int i = 0; i < circles.length; i++) {
262 _locationWindow!.removeCircleMapObject(circles[i]);
263 print("Removed circle $i");
264 }
265 }
266
270 void _demonstrateIconMapObjects() {
271 print("--- Icon Map Objects ---");
272
273 if (_locationWindow == null) {
274 print("LocationWindow not available yet");
275 return;
276 }
277
278 // [dart_IconMapObject_constructor]
279 // Create icon map object
280 LocationPoint position = LocationPoint(30.0, 40.0);
281 _iconMapObject = _locationWindow!.addIconMapObject();
282 print("Created icon map object at (${position.x}, ${position.y})");
283 // [dart_IconMapObject_constructor]
284
285 // [dart_IconMapObject_getPosition]
286 // Access icon position
287 LocationPoint iconPosition = _iconMapObject!.getPosition();
288 print("Icon position: (${iconPosition.x}, ${iconPosition.y})");
289 // [dart_IconMapObject_getPosition]
290
291 // [dart_LocationWindow_addIconMapObject]
292 // Add icon map object
293 _iconMapObject = _locationWindow!.addIconMapObject();
294 print("Added icon map object");
295 // [dart_LocationWindow_addIconMapObject]
296
297 if (_iconMapObject != null) {
298 // [dart_IconMapObject_setPosition]
299 // Set icon position
300 LocationPoint iconPoint = LocationPoint(200.0, 300.0);
301 bool success = _iconMapObject!.setPosition(iconPoint);
302 print("Set icon position to (${iconPoint.x}, ${iconPoint.y}): $success");
303 // [dart_IconMapObject_setPosition]
304
305 // [dart_IconMapObject_setPositionAnimated]
306 // Set icon position with animation
307 LocationPoint animatedIconPoint = LocationPoint(250.0, 350.0);
308 bool animatedSuccess = _iconMapObject!.setPositionAnimated(
309 animatedIconPoint,
310 1.5,
311 AnimationType.CUBIC,
312 );
313 print(
314 "Set icon position with animation to (${animatedIconPoint.x}, ${animatedIconPoint.y}): $animatedSuccess",
315 );
316 // [dart_IconMapObject_setPositionAnimated]
317
318 // [dart_IconMapObject_setSize]
319 // Set icon size
320 bool sizeSuccess = _iconMapObject!.setSize(32.0, 32.0);
321 print("Set icon size to 32x32 pixels: $sizeSuccess");
322 // [dart_IconMapObject_setSize]
323
324 // [dart_IconMapObject_setAngle]
325 // Set icon rotation angle
326 bool angleSuccess = _iconMapObject!.setAngle(45.0);
327 print("Set icon rotation angle to 45 degrees: $angleSuccess");
328 // [dart_IconMapObject_setAngle]
329
330 // [dart_IconMapObject_setAngleAnimated]
331 // Set icon rotation with animation
332 bool angleAnimatedSuccess = _iconMapObject!.setAngleAnimated(
333 90.0,
334 2.0,
335 AnimationType.SINE,
336 );
337 print(
338 "Set icon rotation with animation to 90 degrees: $angleAnimatedSuccess",
339 );
340 // [dart_IconMapObject_setAngleAnimated]
341
342 // [dart_IconMapObject_setCollisionEnabled]
343 // Enable collision detection
344 bool collisionSuccess = _iconMapObject!.setCollisionEnabled(true);
345 print("Enabled collision detection for icon: $collisionSuccess");
346 // [dart_IconMapObject_setCollisionEnabled]
347
348 // [dart_IconMapObject_setBuffer]
349 // Set collision buffer
350 bool bufferSuccess = _iconMapObject!.setBuffer(10.0, 10.0);
351 print("Set collision buffer to 10x10 pixels: $bufferSuccess");
352 // [dart_IconMapObject_setBuffer]
353
354 // [dart_IconMapObject_setOffset]
355 // Set position offset
356 bool offsetSuccess = _iconMapObject!.setOffset(0.0, -16.0);
357 print("Set position offset to (0.0, -16.0) pixels: $offsetSuccess");
358 // [dart_IconMapObject_setOffset]
359
360 // [dart_IconMapObject_setPriority]
361 // Set rendering priority
362 bool prioritySuccess = _iconMapObject!.setPriority(2);
363 print("Set rendering priority to 2: $prioritySuccess");
364 // [dart_IconMapObject_setPriority]
365
366 // [dart_IconMapObject_setVisible]
367 // Set visibility
368 bool visibleSuccess = _iconMapObject!.setVisible(true);
369 print("Set icon visibility to true: $visibleSuccess");
370 // [dart_IconMapObject_setVisible]
371
372 // [dart_IconMapObject_getMapObjectType]
373 // Get map object type
374 MapObjectType objectType = _iconMapObject!.mapObjectType;
375 print("Icon map object type: $objectType");
376 // [dart_IconMapObject_getMapObjectType]
377
378 // [dart_IconMapObject_setIcon]
379 // Set icon image
380 bool iconSuccess = _iconMapObject!.setIcon("path/to/icon.png");
381 print("Set icon image: $iconSuccess");
382 // [dart_IconMapObject_setIcon]
383
384 // [dart_IconMapObject_setBitmap]
385 // Set icon bitmap
386 bool bitmapSuccess = _iconMapObject!.setBitmap("path/to/bitmap.png");
387 print("Set icon bitmap: $bitmapSuccess");
388 // [dart_IconMapObject_setBitmap]
389
390 // [dart_IconMapObject_setFlat]
391 // Set icon flat mode
392 bool flatSuccess = _iconMapObject!.setFlat(true);
393 print("Set icon flat mode to true: $flatSuccess");
394 // [dart_IconMapObject_setFlat]
395
396 // [dart_IconMapObject_setPlacement]
397 // Set icon placement
398 bool placementSuccess = _iconMapObject!.setPlacement(Placement.center);
399 print("Set icon placement to center: $placementSuccess");
400 // [dart_IconMapObject_setPlacement]
401
402 // [dart_MapObject_setAlpha_1]
403 // Set alpha transparency
404 bool alphaSuccess = _iconMapObject!.setAlpha(0.7);
405 print("Set icon alpha to 0.7: $alphaSuccess");
406 // [dart_MapObject_setAlpha_1]
407
408 // [dart_MapObject_setInteractive_1]
409 // Set interactive mode
410 bool interactiveSuccess = _iconMapObject!.setInteractive(true);
411 print("Set icon interactive to true: $interactiveSuccess");
412 // [dart_MapObject_setInteractive_1]
413
414 // [dart_MapObject_setTitle_1]
415 // Set title
416 bool titleSuccess = _iconMapObject!.setTitle("Icon Object");
417 print("Set icon title to 'Icon Object': $titleSuccess");
418 // [dart_MapObject_setTitle_1]
419
420 // [dart_MapObject_setData_1]
421 // Set custom data
422 Map<String, dynamic> customData = {"key": "value", "number": 42};
423 bool dataSuccess = _iconMapObject!.setData(customData);
424 print("Set icon custom data: $dataSuccess");
425 // [dart_MapObject_setData_1]
426
427 // [dart_MapObject_getId_1]
428 // Get object ID
429 int objectId = _iconMapObject!.id;
430 print("Icon object ID: $objectId");
431 // [dart_MapObject_getId_1]
432
433 // [dart_MapObject_getType_1]
434 // Get object type
435 String objectTypeString = _iconMapObject!.type;
436 print("Icon object type: $objectTypeString");
437 // [dart_MapObject_getType_1]
438
439 // [dart_MapObject_getData_1]
440 // Get custom data
441 Map<String, dynamic> retrievedData = _iconMapObject!.data;
442 print("Icon custom data: $retrievedData");
443 // [dart_MapObject_getData_1]
444 }
445
446 // [dart_LocationWindow_removeIconMapObject]
447 // Remove icon map object
448 if (_iconMapObject != null) {
449 bool removed = _locationWindow!.removeIconMapObject(_iconMapObject!);
450 print("Removed icon map object: $removed");
451 _iconMapObject = null;
452 }
453 // [dart_LocationWindow_removeIconMapObject]
454
455 // Test multiple icon objects
456 List<IconMapObject> icons = [];
457 for (int i = 0; i < 3; i++) {
458 IconMapObject icon = _locationWindow!.addIconMapObject();
459 if (icon != null) {
460 icon.setPosition(LocationPoint(100.0 * i, 150.0 * i));
461 icon.setSize(24.0, 24.0);
462 icon.setAngle(i * 30.0);
463 icons.add(icon);
464 print(
465 "Created icon $i at (${100.0 * i}, ${150.0 * i}) with angle ${i * 30.0}",
466 );
467 }
468 }
469
470 for (int i = 0; i < icons.length; i++) {
471 _locationWindow!.removeIconMapObject(icons[i]);
472 print("Removed icon $i");
473 }
474 }
475
479 void _demonstratePolygonMapObjects() {
480 print("--- Polygon Map Objects ---");
481
482 if (_locationWindow == null) {
483 print("LocationWindow not available yet");
484 return;
485 }
486
487 // [dart_LocationWindow_addPolygonMapObject]
488 // Add polygon map object
489 _polygonMapObject = _locationWindow!.addPolygonMapObject();
490 print("Added polygon map object");
491 // [dart_LocationWindow_addPolygonMapObject]
492
493 if (_polygonMapObject != null) {
494 // [dart_PolygonMapObject_setPolygon]
495 // Set polygon geometry
496 List<LocationPoint> points = [
497 LocationPoint(100.0, 200.0),
498 LocationPoint(150.0, 250.0),
499 LocationPoint(200.0, 200.0),
500 LocationPoint(150.0, 150.0),
501 ];
502 LocationPolygon polygon = LocationPolygon(points);
503 bool success = _polygonMapObject!.setPolygon(polygon);
504 print("Set polygon with ${points.length} points: $success");
505 // [dart_PolygonMapObject_setPolygon]
506
507 // [dart_PolygonMapObject_setColor]
508 // Set polygon color
509 bool colorSuccess = _polygonMapObject!.setColor(0.0, 1.0, 0.0, 0.7);
510 print("Set polygon color to green with 70% opacity: $colorSuccess");
511 // [dart_PolygonMapObject_setColor]
512
513 // [dart_PolygonMapObject_setOutlineColor]
514 // Set polygon outline color
515 bool outlineColorSuccess = _polygonMapObject!.setOutlineColor(
516 0.0,
517 0.0,
518 1.0,
519 1.0,
520 );
521 print("Set polygon outline color to blue: $outlineColorSuccess");
522 // [dart_PolygonMapObject_setOutlineColor]
523
524 // [dart_PolygonMapObject_setOutlineWidth]
525 // Set polygon outline width
526 bool outlineWidthSuccess = _polygonMapObject!.setOutlineWidth(2.0);
527 print("Set polygon outline width to 2.0 pixels: $outlineWidthSuccess");
528 // [dart_PolygonMapObject_setOutlineWidth]
529
530 // [dart_PolygonMapObject_setOutlineAlpha]
531 // Set polygon outline alpha
532 bool outlineAlphaSuccess = _polygonMapObject!.setOutlineAlpha(0.8);
533 print("Set polygon outline alpha to 0.8: $outlineAlphaSuccess");
534 // [dart_PolygonMapObject_setOutlineAlpha]
535
536 // [dart_PolygonMapObject_setOutlineOrder]
537 // Set polygon outline order
538 bool outlineOrderSuccess = _polygonMapObject!.setOutlineOrder(1);
539 print("Set polygon outline order to 1: $outlineOrderSuccess");
540 // [dart_PolygonMapObject_setOutlineOrder]
541
542 // [dart_PolygonMapObject_setOrder]
543 // Set polygon rendering order
544 bool orderSuccess = _polygonMapObject!.setOrder(2);
545 print("Set polygon rendering order to 2: $orderSuccess");
546 // [dart_PolygonMapObject_setOrder]
547
548 // [dart_PolygonMapObject_setVisible]
549 // Set visibility
550 bool visibleSuccess = _polygonMapObject!.setVisible(true);
551 print("Set polygon visibility to true: $visibleSuccess");
552 // [dart_PolygonMapObject_setVisible]
553
554 // [dart_PolygonMapObject_getMapObjectType]
555 // Get map object type
556 MapObjectType objectType = _polygonMapObject!.mapObjectType;
557 print("Polygon map object type: $objectType");
558 // [dart_PolygonMapObject_getMapObjectType]
559
560 // [dart_MapObject_setAlpha_2]
561 // Set alpha transparency
562 bool alphaSuccess = _polygonMapObject!.setAlpha(0.7);
563 print("Set polygon alpha to 0.7: $alphaSuccess");
564 // [dart_MapObject_setAlpha_2]
565
566 // [dart_MapObject_setInteractive_2]
567 // Set interactive mode
568 bool interactiveSuccess = _polygonMapObject!.setInteractive(true);
569 print("Set polygon interactive to true: $interactiveSuccess");
570 // [dart_MapObject_setInteractive_2]
571
572 // [dart_MapObject_setTitle_2]
573 // Set title
574 bool titleSuccess = _polygonMapObject!.setTitle("Polygon Object");
575 print("Set polygon title to 'Polygon Object': $titleSuccess");
576 // [dart_MapObject_setTitle_2]
577
578 // [dart_MapObject_setData_2]
579 // Set custom data
580 Map<String, dynamic> customData = {"key": "value", "number": 42};
581 bool dataSuccess = _polygonMapObject!.setData(customData);
582 print("Set polygon custom data: $dataSuccess");
583 // [dart_MapObject_setData_2]
584
585 // [dart_MapObject_getId_2]
586 // Get object ID
587 int objectId = _polygonMapObject!.id;
588 print("Polygon object ID: $objectId");
589 // [dart_MapObject_getId_2]
590
591 // [dart_MapObject_getType_2]
592 // Get object type
593 String objectTypeString = _polygonMapObject!.type;
594 print("Polygon object type: $objectTypeString");
595 // [dart_MapObject_getType_2]
596
597 // [dart_MapObject_getData_2]
598 // Get custom data
599 Map<String, dynamic> retrievedData = _polygonMapObject!.data;
600 print("Polygon custom data: $retrievedData");
601 // [dart_MapObject_getData_2]
602 }
603
604 // [dart_LocationWindow_removePolygonMapObject]
605 // Remove polygon map object
606 if (_polygonMapObject != null) {
607 bool removed = _locationWindow!.removePolygonMapObject(
608 _polygonMapObject!,
609 );
610 print("Removed polygon map object: $removed");
611 _polygonMapObject = null;
612 }
613 // [dart_LocationWindow_removePolygonMapObject]
614
615 // Test multiple polygon objects
616 List<PolygonMapObject> polygons = [];
617 for (int i = 0; i < 3; i++) {
618 PolygonMapObject polygon = _locationWindow!.addPolygonMapObject();
619 if (polygon != null) {
620 List<LocationPoint> points = [
621 LocationPoint(300.0 + i * 50, 400.0 + i * 50),
622 LocationPoint(350.0 + i * 50, 450.0 + i * 50),
623 LocationPoint(400.0 + i * 50, 400.0 + i * 50),
624 LocationPoint(350.0 + i * 50, 350.0 + i * 50),
625 ];
626 LocationPolygon polygonGeometry = LocationPolygon(points);
627 polygon.setPolygon(polygonGeometry);
628 polygon.setColor(0.0, 0.0, 1.0, 0.5);
629 polygons.add(polygon);
630 print("Created polygon $i with ${points.length} points");
631 }
632 }
633
634 for (int i = 0; i < polygons.length; i++) {
635 _locationWindow!.removePolygonMapObject(polygons[i]);
636 print("Removed polygon $i");
637 }
638 }
639
643 void _demonstratePolylineMapObjects() {
644 print("--- Polyline Map Objects ---");
645
646 if (_locationWindow == null) {
647 print("LocationWindow not available yet");
648 return;
649 }
650
651 // [dart_PolylineMapObject_constructor]
652 // Create polyline map object
653 List<Point> points = [
654 Point(100.0, 110.0),
655 Point(105.0, 115.0),
656 Point(110.0, 120.0),
657 Point(115.0, 125.0),
658 ];
659 Polyline polyline = Polyline(points);
660 LocationPolyline locationPolyline = LocationPolyline(polyline);
661 _polylineMapObject = _locationWindow!.addPolylineMapObject();
662 print("Created polyline map object with ${points.length} points");
663 // [dart_PolylineMapObject_constructor]
664
665 // [dart_PolylineMapObject_getPolyline]
666 // Access polyline
667 LocationPolyline polylineShape = _polylineMapObject!.getPolyLine();
668 print("Polyline has ${polylineShape.points.length} points");
669 // [dart_PolylineMapObject_getPolyline]
670
671 // [dart_LocationWindow_addPolylineMapObject]
672 // Add polyline map object
673 _polylineMapObject = _locationWindow!.addPolylineMapObject();
674 print("Added polyline map object");
675 // [dart_LocationWindow_addPolylineMapObject]
676
677 if (_polylineMapObject != null) {
678 // [dart_PolylineMapObject_setPolyLine]
679 // Set polyline geometry
680 List<Point> polylinePoints = [
681 Point(0.0, 0.0),
682 Point(50.0, 50.0),
683 Point(100.0, 0.0),
684 Point(150.0, 50.0),
685 ];
686 Polyline polyline = Polyline(polylinePoints);
687 LocationPolyline locationPolyline = LocationPolyline(polyline);
688 bool success = _polylineMapObject!.setPolyLine(locationPolyline);
689 print("Set polyline geometry: $success");
690 // [dart_PolylineMapObject_setPolyLine]
691
692 // [dart_PolylineMapObject_setWidth]
693 // Set polyline width
694 bool widthSuccess = _polylineMapObject!.setWidth(3.0);
695 print("Set polyline width to 3.0 pixels: $widthSuccess");
696 // [dart_PolylineMapObject_setWidth]
697
698 // [dart_PolylineMapObject_setColor]
699 // Set polyline color
700 bool colorSuccess = _polylineMapObject!.setColor(1.0, 0.5, 0.0, 0.9);
701 print("Set polyline color to orange with 90% opacity: $colorSuccess");
702 // [dart_PolylineMapObject_setColor]
703
704 // [dart_PolylineMapObject_setOrder]
705 // Set rendering order
706 bool orderSuccess = _polylineMapObject!.setOrder(2);
707 print("Set rendering order to 2: $orderSuccess");
708 // [dart_PolylineMapObject_setOrder]
709
710 // [dart_PolylineMapObject_setCapType]
711 // Set cap type
712 bool capSuccess = _polylineMapObject!.setCapType(CapType.ROUND);
713 print("Set cap type to ROUND: $capSuccess");
714 // [dart_PolylineMapObject_setCapType]
715
716 // [dart_PolylineMapObject_setJoinType]
717 // Set join type
718 bool joinSuccess = _polylineMapObject!.setJoinType(JoinType.ROUND);
719 print("Set join type to ROUND: $joinSuccess");
720 // [dart_PolylineMapObject_setJoinType]
721
722 // [dart_PolylineMapObject_setMiterLimit]
723 // Set miter limit
724 bool miterSuccess = _polylineMapObject!.setMiterLimit(5.0);
725 print("Set miter limit to 5.0: $miterSuccess");
726 // [dart_PolylineMapObject_setMiterLimit]
727
728 // [dart_PolylineMapObject_setOutlineWidth]
729 // Set outline width
730 bool outlineWidthSuccess = _polylineMapObject!.setOutlineWidth(1.0);
731 print("Set polyline outline width to 1.0: $outlineWidthSuccess");
732 // [dart_PolylineMapObject_setOutlineWidth]
733
734 // [dart_PolylineMapObject_setOutlineColor]
735 // Set outline color
736 bool outlineColorSuccess = _polylineMapObject!.setOutlineColor(
737 0.0,
738 0.0,
739 0.0,
740 1.0,
741 );
742 print("Set polyline outline color to black: $outlineColorSuccess");
743 // [dart_PolylineMapObject_setOutlineColor]
744
745 // [dart_PolylineMapObject_setOutlineAlpha]
746 // Set outline alpha
747 bool outlineAlphaSuccess = _polylineMapObject!.setOutlineAlpha(0.8);
748 print("Set polyline outline alpha to 0.8: $outlineAlphaSuccess");
749 // [dart_PolylineMapObject_setOutlineAlpha]
750
751 // [dart_PolylineMapObject_setOutlineOrder]
752 // Set outline order
753 bool outlineOrderSuccess = _polylineMapObject!.setOutlineOrder(1);
754 print("Set polyline outline order to 1: $outlineOrderSuccess");
755 // [dart_PolylineMapObject_setOutlineOrder]
756
757 // [dart_PolylineMapObject_setOutlineCapType]
758 // Set outline cap type
759 bool outlineCapSuccess = _polylineMapObject!.setOutlineCapType(
760 CapType.ROUND,
761 );
762 print("Set polyline outline cap type to ROUND: $outlineCapSuccess");
763 // [dart_PolylineMapObject_setOutlineCapType]
764
765 // [dart_PolylineMapObject_setOutlineJoinType]
766 // Set outline join type
767 bool outlineJoinSuccess = _polylineMapObject!.setOutlineJoinType(
768 JoinType.ROUND,
769 );
770 print("Set polyline outline join type to ROUND: $outlineJoinSuccess");
771 // [dart_PolylineMapObject_setOutlineJoinType]
772
773 // [dart_PolylineMapObject_setOutlineMiterLimit]
774 // Set outline miter limit
775 bool outlineMiterSuccess = _polylineMapObject!.setOutlineMiterLimit(3.0);
776 print("Set polyline outline miter limit to 3.0: $outlineMiterSuccess");
777 // [dart_PolylineMapObject_setOutlineMiterLimit]
778
779 // [dart_PolylineMapObject_setVisible]
780 // Set visibility
781 bool visibleSuccess = _polylineMapObject!.setVisible(true);
782 print("Set polyline visibility to true: $visibleSuccess");
783 // [dart_PolylineMapObject_setVisible]
784
785 // [dart_PolylineMapObject_getMapObjectType]
786 // Get map object type
787 MapObjectType objectType = _polylineMapObject!.mapObjectType;
788 print("Polyline map object type: $objectType");
789 // [dart_PolylineMapObject_getMapObjectType]
790
791 // [dart_MapObject_setAlpha_3]
792 // Set alpha transparency
793 bool alphaSuccess = _polylineMapObject!.setAlpha(0.7);
794 print("Set polyline alpha to 0.7: $alphaSuccess");
795 // [dart_MapObject_setAlpha_3]
796
797 // [dart_MapObject_setInteractive_3]
798 // Set interactive mode
799 bool interactiveSuccess = _polylineMapObject!.setInteractive(true);
800 print("Set polyline interactive to true: $interactiveSuccess");
801 // [dart_MapObject_setInteractive_3]
802
803 // [dart_MapObject_setTitle_3]
804 // Set title
805 bool titleSuccess = _polylineMapObject!.setTitle("Polyline Object");
806 print("Set polyline title to 'Polyline Object': $titleSuccess");
807 // [dart_MapObject_setTitle_3]
808
809 // [dart_MapObject_setData_3]
810 // Set custom data
811 Map<String, dynamic> customData = {"key": "value", "number": 42};
812 bool dataSuccess = _polylineMapObject!.setData(customData);
813 print("Set polyline custom data: $dataSuccess");
814 // [dart_MapObject_setData_3]
815
816 // [dart_MapObject_getId_3]
817 // Get object ID
818 int objectId = _polylineMapObject!.id;
819 print("Polyline object ID: $objectId");
820 // [dart_MapObject_getId_3]
821
822 // [dart_MapObject_getType_3]
823 // Get object type
824 String objectTypeString = _polylineMapObject!.type;
825 print("Polyline object type: $objectTypeString");
826 // [dart_MapObject_getType_3]
827
828 // [dart_MapObject_getData_3]
829 // Get custom data
830 Map<String, dynamic> retrievedData = _polylineMapObject!.data;
831 print("Polyline custom data: $retrievedData");
832 // [dart_MapObject_getData_3]
833 }
834
835 // [dart_LocationWindow_removePolylineMapObject]
836 // Remove polyline map object
837 if (_polylineMapObject != null) {
838 bool removed = _locationWindow!.removePolylineMapObject(
839 _polylineMapObject!,
840 );
841 print("Removed polyline map object: $removed");
842 _polylineMapObject = null;
843 }
844 // [dart_LocationWindow_removePolylineMapObject]
845
846 // Test multiple polyline objects
847 List<PolylineMapObject> polylines = [];
848 for (int i = 0; i < 3; i++) {
849 PolylineMapObject polyline = _locationWindow!.addPolylineMapObject();
850 if (polyline != null) {
851 List<Point> points = [
852 Point(i * 30.0, i * 30.0),
853 Point((i + 1) * 30.0, (i + 1) * 30.0),
854 ];
855 Polyline poly = Polyline(points);
856 LocationPolyline locPoly = LocationPolyline(poly);
857 polyline.setPolyLine(locPoly);
858 polyline.setWidth(2.0 + i);
859 polyline.setColor(0.0, 1.0, 1.0, 0.8);
860 polylines.add(polyline);
861 print("Created polyline $i with width ${2.0 + i}");
862 }
863 }
864
865 for (int i = 0; i < polylines.length; i++) {
866 _locationWindow!.removePolylineMapObject(polylines[i]);
867 print("Removed polyline $i");
868 }
869 }
870
874 void _demonstrateDottedPolylineMapObjects() {
875 print("--- Dotted Polyline Map Objects ---");
876
877 if (_locationWindow == null) {
878 print("LocationWindow not available yet");
879 return;
880 }
881
882 // [dart_DottedPolylineMapObject_constructor]
883 // Create dotted polyline map object
884 List<Point> points = [
885 Point(160.0, 170.0),
886 Point(165.0, 175.0),
887 Point(170.0, 180.0),
888 Point(175.0, 185.0),
889 ];
890 Polyline polyline = Polyline(points);
891 LocationPolyline locationPolyline = LocationPolyline(polyline);
892 _dottedPolylineMapObject = _locationWindow!.addDottedPolylineMapObject();
893 print("Created dotted polyline map object with ${points.length} points");
894 // [dart_DottedPolylineMapObject_constructor]
895
896 // [dart_DottedPolylineMapObject_getPolyline]
897 // Access dotted polyline
898 LocationPolyline dottedPolylineShape =
899 _dottedPolylineMapObject!.getPolyLine();
900 print("Dotted polyline has ${dottedPolylineShape.points.length} points");
901 // [dart_DottedPolylineMapObject_getPolyline]
902
903 // [dart_LocationWindow_addDottedPolylineMapObject]
904 // Add dotted polyline map object
905 _dottedPolylineMapObject = _locationWindow!.addDottedPolylineMapObject();
906 print("Added dotted polyline map object");
907 // [dart_LocationWindow_addDottedPolylineMapObject]
908
909 if (_dottedPolylineMapObject != null) {
910 // [dart_DottedPolylineMapObject_setPolyline]
911 // Set dotted polyline geometry
912 List<Point> dottedPoints = [
913 Point(0.0, 100.0),
914 Point(50.0, 150.0),
915 Point(100.0, 100.0),
916 Point(150.0, 150.0),
917 ];
918 Polyline dottedPolyline = Polyline(dottedPoints);
919 LocationPolyline locationDottedPolyline = LocationPolyline(
920 dottedPolyline,
921 );
922 bool success = _dottedPolylineMapObject!.setPolyLine(
923 locationDottedPolyline,
924 );
925 print("Set dotted polyline geometry: $success");
926 // [dart_DottedPolylineMapObject_setPolyline]
927
928 // [dart_DottedPolylineMapObject_setWidth]
929 // Set dotted polyline width
930 bool widthSuccess = _dottedPolylineMapObject!.setWidth(2.0);
931 print("Set dotted polyline width to 2.0 pixels: $widthSuccess");
932 // [dart_DottedPolylineMapObject_setWidth]
933
934 // [dart_DottedPolylineMapObject_setColor]
935 // Set dotted polyline color
936 bool colorSuccess = _dottedPolylineMapObject!.setColor(
937 0.5,
938 0.0,
939 1.0,
940 0.8,
941 );
942 print(
943 "Set dotted polyline color to purple with 80% opacity: $colorSuccess",
944 );
945 // [dart_DottedPolylineMapObject_setColor]
946
947 // [dart_DottedPolylineMapObject_setOrder]
948 // Set rendering order
949 bool orderSuccess = _dottedPolylineMapObject!.setOrder(3);
950 print("Set rendering order to 3: $orderSuccess");
951 // [dart_DottedPolylineMapObject_setOrder]
952
953 // [dart_DottedPolylineMapObject_setCollisionEnabled]
954 // Enable collision detection
955 bool collisionSuccess = _dottedPolylineMapObject!.setCollisionEnabled(
956 true,
957 );
958 print(
959 "Enabled collision detection for dotted polyline: $collisionSuccess",
960 );
961 // [dart_DottedPolylineMapObject_setCollisionEnabled]
962
963 // [dart_DottedPolylineMapObject_setPlacement]
964 // Set placement type
965 bool placementSuccess = _dottedPolylineMapObject!.setPlacement(
966 Placement.center,
967 );
968 print("Set dotted polyline placement to center: $placementSuccess");
969 // [dart_DottedPolylineMapObject_setPlacement]
970
971 // [dart_DottedPolylineMapObject_setPlacementMinRatio]
972 // Set placement min ratio
973 bool minRatioSuccess = _dottedPolylineMapObject!.setPlacementMinRatio(
974 0.5,
975 );
976 print("Set dotted polyline placement min ratio to 0.5: $minRatioSuccess");
977 // [dart_DottedPolylineMapObject_setPlacementMinRatio]
978
979 // [dart_DottedPolylineMapObject_setPlacementSpacing]
980 // Set placement spacing
981 bool spacingSuccess = _dottedPolylineMapObject!.setPlacementSpacing(10.0);
982 print("Set dotted polyline placement spacing to 10.0: $spacingSuccess");
983 // [dart_DottedPolylineMapObject_setPlacementSpacing]
984
985 // [dart_DottedPolylineMapObject_setPriority]
986 // Set rendering priority
987 bool prioritySuccess = _dottedPolylineMapObject!.setPriority(1);
988 print("Set dotted polyline rendering priority to 1: $prioritySuccess");
989 // [dart_DottedPolylineMapObject_setPriority]
990
991 // [dart_DottedPolylineMapObject_setRepeatDistance]
992 // Set repeat distance
993 bool repeatDistanceSuccess = _dottedPolylineMapObject!.setRepeatDistance(
994 20.0,
995 );
996 print(
997 "Set dotted polyline repeat distance to 20.0: $repeatDistanceSuccess",
998 );
999 // [dart_DottedPolylineMapObject_setRepeatDistance]
1000
1001 // [dart_DottedPolylineMapObject_setRepeatGroup]
1002 // Set repeat group
1003 bool repeatGroupSuccess = _dottedPolylineMapObject!.setRepeatGroup(1);
1004 print("Set dotted polyline repeat group to 1: $repeatGroupSuccess");
1005 // [dart_DottedPolylineMapObject_setRepeatGroup]
1006
1007 // [dart_DottedPolylineMapObject_setSize]
1008 // Set size
1009 bool sizeSuccess = _dottedPolylineMapObject!.setSize(16.0, 16.0);
1010 print("Set dotted polyline size to 16x16: $sizeSuccess");
1011 // [dart_DottedPolylineMapObject_setSize]
1012
1013 // [dart_DottedPolylineMapObject_setVisible]
1014 // Set visibility
1015 bool visibleSuccess = _dottedPolylineMapObject!.setVisible(true);
1016 print("Set dotted polyline visibility to true: $visibleSuccess");
1017 // [dart_DottedPolylineMapObject_setVisible]
1018
1019 // [dart_DottedPolylineMapObject_getMapObjectType]
1020 // Get map object type
1021 MapObjectType objectType = _dottedPolylineMapObject!.mapObjectType;
1022 print("Dotted polyline map object type: $objectType");
1023 // [dart_DottedPolylineMapObject_getMapObjectType]
1024
1025 // [dart_MapObject_setAlpha_4]
1026 // Set alpha transparency
1027 bool alphaSuccess = _dottedPolylineMapObject!.setAlpha(0.7);
1028 print("Set dotted polyline alpha to 0.7: $alphaSuccess");
1029 // [dart_MapObject_setAlpha_4]
1030
1031 // [dart_MapObject_setInteractive_4]
1032 // Set interactive mode
1033 bool interactiveSuccess = _dottedPolylineMapObject!.setInteractive(true);
1034 print("Set dotted polyline interactive to true: $interactiveSuccess");
1035 // [dart_MapObject_setInteractive_4]
1036
1037 // [dart_MapObject_setTitle_4]
1038 // Set title
1039 bool titleSuccess = _dottedPolylineMapObject!.setTitle(
1040 "Dotted Polyline Object",
1041 );
1042 print(
1043 "Set dotted polyline title to 'Dotted Polyline Object': $titleSuccess",
1044 );
1045 // [dart_MapObject_setTitle_4]
1046
1047 // [dart_MapObject_setData_4]
1048 // Set custom data
1049 Map<String, dynamic> customData = {"key": "value", "number": 42};
1050 bool dataSuccess = _dottedPolylineMapObject!.setData(customData);
1051 print("Set dotted polyline custom data: $dataSuccess");
1052 // [dart_MapObject_setData_4]
1053
1054 // [dart_MapObject_getId_4]
1055 // Get object ID
1056 int objectId = _dottedPolylineMapObject!.id;
1057 print("Dotted polyline object ID: $objectId");
1058 // [dart_MapObject_getId_4]
1059
1060 // [dart_MapObject_getType_4]
1061 // Get object type
1062 String objectTypeString = _dottedPolylineMapObject!.type;
1063 print("Dotted polyline object type: $objectTypeString");
1064 // [dart_MapObject_getType_4]
1065
1066 // [dart_MapObject_getData_4]
1067 // Get custom data
1068 Map<String, dynamic> retrievedData = _dottedPolylineMapObject!.data;
1069 print("Dotted polyline custom data: $retrievedData");
1070 // [dart_MapObject_getData_4]
1071 }
1072
1073 // [dart_LocationWindow_removeDottedPolylineMapObject]
1074 // Remove dotted polyline map object
1075 if (_dottedPolylineMapObject != null) {
1076 bool removed = _locationWindow!.removeDottedPolylineMapObject(
1077 _dottedPolylineMapObject!,
1078 );
1079 print("Removed dotted polyline map object: $removed");
1080 _dottedPolylineMapObject = null;
1081 }
1082 // [dart_LocationWindow_removeDottedPolylineMapObject]
1083
1084 // Test multiple dotted polyline objects
1085 List<DottedPolylineMapObject> dottedPolylines = [];
1086 for (int i = 0; i < 2; i++) {
1087 DottedPolylineMapObject dottedPolyline =
1088 _locationWindow!.addDottedPolylineMapObject();
1089 if (dottedPolyline != null) {
1090 List<Point> points = [
1091 Point(i * 40.0, i * 40.0 + 100.0),
1092 Point((i + 1) * 40.0, (i + 1) * 40.0 + 100.0),
1093 ];
1094 Polyline poly = Polyline(points);
1095 LocationPolyline locPoly = LocationPolyline(poly);
1096 dottedPolyline.setPolyLine(locPoly);
1097 dottedPolyline.setWidth(1.5);
1098 dottedPolyline.setColor(1.0, 0.0, 1.0, 0.6);
1099 dottedPolylines.add(dottedPolyline);
1100 print("Created dotted polyline $i");
1101 }
1102 }
1103
1104 for (int i = 0; i < dottedPolylines.length; i++) {
1105 _locationWindow!.removeDottedPolylineMapObject(dottedPolylines[i]);
1106 print("Removed dotted polyline $i");
1107 }
1108 }
1109
1113 void _demonstrateRemoveAllMapObjects() {
1114 print("--- Remove All Map Objects ---");
1115
1116 if (_locationWindow == null) {
1117 print("LocationWindow not available yet");
1118 return;
1119 }
1120
1121 // Create various map objects
1122 CircleMapObject circle = _locationWindow!.addCircleMapObject();
1123 IconMapObject icon = _locationWindow!.addIconMapObject();
1124 PolygonMapObject polygon = _locationWindow!.addPolygonMapObject();
1125 PolylineMapObject polyline = _locationWindow!.addPolylineMapObject();
1126 DottedPolylineMapObject dottedPolyline =
1127 _locationWindow!.addDottedPolylineMapObject();
1128
1129 print("Created 5 map objects");
1130
1131 // [dart_LocationWindow_removeAllMapObjects]
1132 // Remove all map objects
1133 _locationWindow!.removeAllMapObjects();
1134 print("Removed all map objects");
1135 // [dart_LocationWindow_removeAllMapObjects]
1136 }
1137
1141 void _cleanup() {
1142 if (_circleMapObject != null) {
1143 _locationWindow?.removeCircleMapObject(_circleMapObject!);
1144 _circleMapObject = null;
1145 }
1146 if (_iconMapObject != null) {
1147 _locationWindow?.removeIconMapObject(_iconMapObject!);
1148 _iconMapObject = null;
1149 }
1150 if (_polygonMapObject != null) {
1151 // Polygon objects are removed automatically when LocationWindow is destroyed
1152 _polygonMapObject = null;
1153 }
1154 if (_polylineMapObject != null) {
1155 _locationWindow?.removePolylineMapObject(_polylineMapObject!);
1156 _polylineMapObject = null;
1157 }
1158 if (_dottedPolylineMapObject != null) {
1159 _locationWindow?.removeDottedPolylineMapObject(_dottedPolylineMapObject!);
1160 _dottedPolylineMapObject = null;
1161 }
1162 print("LocationWindowMapObjects example cleanup completed");
1163 }
1164}
1165
1166// Main function
1167void main() {
1169}