Loading...
Searching...
No Matches
location_window_map_objects_example.dart
Go to the documentation of this file.
1import 'dart:ui';
2import 'dart:ffi';
3import 'dart:io' show File;
4import 'dart:math' as math;
5import 'dart:typed_data';
6import 'package:flutter/painting.dart' show AssetImage;
7import 'package:meta/meta.dart';
8import 'package:navigine_sdk/com/_library_context.dart' as __lib;
9import 'package:navigine_sdk/com/_native_base.dart' as __lib;
10import 'package:navigine_sdk/com/_weak_map.dart';
11import 'package:navigine_sdk/com/containers__conversion.dart';
12import 'package:navigine_sdk/com/navigine/idl/animation_type.dart';
13import 'package:navigine_sdk/com/navigine/idl/cap_type.dart';
14import 'package:navigine_sdk/com/navigine/idl/circle_map_object.dart';
15import 'package:navigine_sdk/com/navigine/idl/dotted_polyline_map_object.dart';
16import 'package:navigine_sdk/com/navigine/idl/cluster_map_object.dart';
17import 'package:navigine_sdk/com/navigine/idl/cluster_map_object_controller.dart';
18import 'package:navigine_sdk/com/navigine/idl/cluster_map_object_controller_listener.dart';
19import 'package:navigine_sdk/com/navigine/idl/cluster_map_object_listener.dart';
20import 'package:navigine_sdk/com/navigine/idl/icon_map_object.dart';
21import 'package:navigine_sdk/com/navigine/idl/join_type.dart';
22import 'package:navigine_sdk/com/navigine/idl/location_point.dart';
23import 'package:navigine_sdk/com/navigine/sdk/location_polygon.dart';
24import 'package:navigine_sdk/com/navigine/sdk/location_polyline.dart';
25import 'package:navigine_sdk/com/navigine/idl/location_window.dart';
26import 'package:navigine_sdk/com/navigine/idl/map_object.dart';
27import 'package:navigine_sdk/com/navigine/idl/map_object_type.dart';
28import 'package:navigine_sdk/com/navigine/idl/model_map_object.dart';
29import 'package:navigine_sdk/com/navigine/idl/placement.dart';
30import 'package:navigine_sdk/com/navigine/idl/point.dart';
31import 'package:navigine_sdk/com/navigine/idl/polygon.dart';
32import 'package:navigine_sdk/com/navigine/idl/polygon_map_object.dart';
33import 'package:navigine_sdk/com/navigine/idl/polyline.dart';
34import 'package:navigine_sdk/com/navigine/idl/polyline_map_object.dart';
35import 'package:navigine_sdk/com/navigine/idl/title_anchor.dart';
36import 'package:navigine_sdk/com/navigine/idl/title_style.dart';
37import 'package:navigine_sdk/image_provider.dart';
38import 'package:navigine_sdk/model_provider.dart';
39
47class LocationWindowMapObjectsExample {
56 DemoClusterMapObjectControllerListener? _clusterMapObjectControllerListener;
57
58 LocationWindowMapObjectsExample() {
59 _demonstrateLocationWindowMapObjectsMethods();
60 }
61
65 void _demonstrateLocationWindowMapObjectsMethods() {
66 print("=== LocationWindowMapObjects Example ===");
67
68 _demonstrateLocationScopedGeometryRecords();
69
70 _demonstrateCircleMapObjects();
71 _demonstrateIconMapObjects();
72 _demonstrateClusterMapObjects();
73 _demonstrateModelMapObjects();
74 _demonstratePolygonMapObjects();
75 _demonstratePolylineMapObjects();
76 _demonstrateDottedPolylineMapObjects();
77 _demonstrateRemoveAllMapObjects();
78 _cleanup();
79 }
80
84 void _demonstrateLocationScopedGeometryRecords() {
85 print("--- LocationPolygon / LocationPolyline records ---");
86
87 // [dart_LocationPolygon_record]
88 List<GlobalPoint> ring = [
89 GlobalPoint(55.751, 37.617),
90 GlobalPoint(55.752, 37.618),
91 GlobalPoint(55.751, 37.619),
92 ];
93 LocationPolygon locationPolygon = LocationPolygon(ring, 7);
94 print(
95 "LocationPolygon: sublocation ${locationPolygon.sublocationId}, vertices ${locationPolygon.points.length}",
96 );
97 // [dart_LocationPolygon_record]
98
99 // [dart_LocationPolyline_record]
100 List<GlobalPoint> linePts = [
101 GlobalPoint(55.751, 37.617),
102 GlobalPoint(55.753, 37.620),
103 ];
104 LocationPolyline locationPolyline = LocationPolyline(linePts, 7);
105 print("LocationPolyline points ${locationPolyline.points.length}");
106 // [dart_LocationPolyline_record]
107 }
108
112 void _demonstrateCircleMapObjects() {
113 print("--- Circle Map Objects ---");
114
115 if (_locationWindow == null) {
116 print("LocationWindow not available yet");
117 return;
118 }
119
120 // [dart_CircleMapObject_constructor]
121 // Create circle map object
122 GlobalPoint center = GlobalPoint(10.0, 20.0);
123 _circleMapObject = _locationWindow!.addCircleMapObject();
124 print(
125 "Created circle map object with center (${center.latitude}, ${center.longitude}) and radius 5.0",
126 );
127 // [dart_CircleMapObject_constructor]
128
129 // [dart_CircleMapObject_getRadius]
130 // Access circle radius
131 double radius = _circleMapObject!.getRadius();
132 print("Circle radius: $radius");
133 // [dart_CircleMapObject_getRadius]
134
135 // [dart_LocationWindow_addCircleMapObject]
136 // Add circle map object
137 _circleMapObject = _locationWindow!.addCircleMapObject();
138 print("Added circle map object");
139 // [dart_LocationWindow_addCircleMapObject]
140
141 if (_circleMapObject != null) {
142 // [dart_CircleMapObject_setPosition]
143 // Set circle position
144 GlobalPoint centerPoint = GlobalPoint(100.0, 200.0);
145 bool success = _circleMapObject!.setPosition(centerPoint, 7);
146 print(
147 "Set circle position to (${centerPoint.latitude}, ${centerPoint.longitude}): $success",
148 );
149 // [dart_CircleMapObject_setPosition]
150
151 // [dart_CircleMapObject_setPositionAnimated]
152 // Set circle position with animation
153 GlobalPoint animatedPoint = GlobalPoint(150.0, 250.0);
154 bool animatedSuccess = _circleMapObject!.setPositionAnimated(animatedPoint, 7, 2.0, AnimationType.LINEAR, );
155 print(
156 "Set circle position with animation to (${animatedPoint.latitude}, ${animatedPoint.longitude}): $animatedSuccess",
157 );
158 // [dart_CircleMapObject_setPositionAnimated]
159
160 // [dart_CircleMapObject_setOffset]
161 // Set position offset
162 bool offsetSuccess = _circleMapObject!.setOffset(2.0, 3.0);
163 print("Set position offset to (2.0, 3.0) pixels: $offsetSuccess");
164 // [dart_CircleMapObject_setOffset]
165
166 // [dart_CircleMapObject_setOutlineColor]
167 // Set outline color
168 bool outlineColorSuccess = _circleMapObject!.setOutlineColor(const Color(0xFF0000FF));
169 print("Set circle outline color to blue: $outlineColorSuccess");
170 // [dart_CircleMapObject_setOutlineColor]
171
172 // [dart_CircleMapObject_setOutlineAlpha]
173 // Set outline alpha
174 bool outlineAlphaSuccess = _circleMapObject!.setOutlineAlpha(0.5);
175 print("Set circle outline alpha to 0.5: $outlineAlphaSuccess");
176 // [dart_CircleMapObject_setOutlineAlpha]
177
178 // [dart_CircleMapObject_setOutlineRadius]
179 // Set outline radius
180 bool outlineRadiusSuccess = _circleMapObject!.setOutlineRadius(2.0);
181 print("Set circle outline radius to 2.0: $outlineRadiusSuccess");
182 // [dart_CircleMapObject_setOutlineRadius]
183
184 // [dart_CircleMapObject_setColor]
185 // Set circle color
186 bool colorSuccess = _circleMapObject!.setColor(const Color(0xCCFF0000));
187 print("Set circle color to red with 80% opacity: $colorSuccess");
188 // [dart_CircleMapObject_setColor]
189
190 // [dart_CircleMapObject_setRadius]
191 // Set circle radius
192 bool radiusSuccess = _circleMapObject!.setRadius(10.0);
193 print("Set circle radius to 10.0 meters: $radiusSuccess");
194 // [dart_CircleMapObject_setRadius]
195
196 // [dart_CircleMapObject_setCollisionEnabled]
197 // Enable collision detection
198 bool collisionSuccess = _circleMapObject!.setCollisionEnabled(true);
199 print("Enabled collision detection for circle: $collisionSuccess");
200 // [dart_CircleMapObject_setCollisionEnabled]
201
202 // [dart_CircleMapObject_setBuffer]
203 // Set collision buffer
204 bool bufferSuccess = _circleMapObject!.setBuffer(5.0, 5.0);
205 print("Set collision buffer to 5x5 pixels: $bufferSuccess");
206 // [dart_CircleMapObject_setBuffer]
207
208 // [dart_CircleMapObject_setPriority]
209 // Set rendering priority
210 bool prioritySuccess = _circleMapObject!.setPriority(1);
211 print("Set rendering priority to 1: $prioritySuccess");
212 // [dart_CircleMapObject_setPriority]
213
214 // [dart_MapObject_setVisible]
215 // Set visibility
216 bool visibleSuccess = _circleMapObject!.setVisible(true);
217 print("Set circle visibility to true: $visibleSuccess");
218 // [dart_MapObject_setVisible]
219
220 // [dart_CircleMapObject_getMapObjectType]
221 // Get map object type
222 MapObjectType objectType = _circleMapObject!.mapObjectType;
223 print("Circle map object type: $objectType");
224 // [dart_CircleMapObject_getMapObjectType]
225
226 // [dart_MapObject_setAlpha]
227 // Set alpha transparency
228 bool alphaSuccess = _circleMapObject!.setAlpha(0.7);
229 print("Set circle alpha to 0.7: $alphaSuccess");
230 // [dart_MapObject_setAlpha]
231
232 // [dart_MapObject_setInteractive]
233 // Set interactive mode
234 bool interactiveSuccess = _circleMapObject!.setInteractive(true);
235 print("Set circle interactive to true: $interactiveSuccess");
236 // [dart_MapObject_setInteractive]
237
238 // [dart_MapObject_setTitle]
239 // Set title
240 bool titleSuccess = _circleMapObject!.setTitle("Circle Object");
241 print("Set circle title to 'Circle Object': $titleSuccess");
242 // [dart_MapObject_setTitle]
243
244 // [dart_TitleStyle_record]
245 TitleStyle titleStyle = TitleStyle(
246 fontSize: 14,
247 color: "#3366CC",
248 outlineColor: "#FFFFFF",
249 anchor: TitleAnchor.TOP,
250 visible: true,
251 );
252 // [dart_TitleStyle_record]
253
254 // [dart_MapObject_setTitleWithStyle]
255 // Set title with style
256 bool titleStyleSuccess =
257 _circleMapObject!.setTitleWithStyle("Styled Circle", titleStyle);
258 print("Set circle title with style: $titleStyleSuccess");
259 // [dart_MapObject_setTitleWithStyle]
260
261 // [dart_MapObject_setData]
262 // Set custom data
263 Map<String, dynamic> customData = {"key": "value", "number": 42};
264 bool dataSuccess = _circleMapObject!.setData(customData);
265 print("Set circle custom data: $dataSuccess");
266 // [dart_MapObject_setData]
267
268 // [dart_MapObject_getId]
269 // Get object ID
270 int objectId = _circleMapObject!.id;
271 print("Circle object ID: $objectId");
272 // [dart_MapObject_getId]
273
274 // [dart_MapObject_getType]
275 // Get object type
276 String objectTypeString = _circleMapObject!.type;
277 print("Circle object type: $objectTypeString");
278 // [dart_MapObject_getType]
279
280 // [dart_MapObject_getData]
281 // Get custom data
282 Map<String, dynamic> retrievedData = _circleMapObject!.data;
283 print("Circle custom data: $retrievedData");
284 // [dart_MapObject_getData]
285 }
286
287 // [dart_LocationWindow_removeCircleMapObject]
288 // Remove circle map object
289 if (_circleMapObject != null) {
290 bool removed = _locationWindow!.removeCircleMapObject(_circleMapObject!);
291 print("Removed circle map object: $removed");
292 _circleMapObject = null;
293 }
294 // [dart_LocationWindow_removeCircleMapObject]
295
296 // Test multiple circle objects
297 List<CircleMapObject> circles = [];
298 for (int i = 0; i < 3; i++) {
299 CircleMapObject circle = _locationWindow!.addCircleMapObject();
300 if (circle != null) {
301 circle.setPosition(GlobalPoint(50.0 * i, 100.0 * i));
302 circle.setColor(const Color(0x9900FF00));
303 circle.setRadius(5.0 + i * 2.0);
304 circles.add(circle);
305 print(
306 "Created circle $i at (${50.0 * i}, ${100.0 * i}) with radius ${5.0 + i * 2.0}",
307 );
308 }
309 }
310
311 for (int i = 0; i < circles.length; i++) {
312 _locationWindow!.removeCircleMapObject(circles[i]);
313 print("Removed circle $i");
314 }
315 }
316
320 void _demonstrateIconMapObjects() {
321 print("--- Icon Map Objects ---");
322
323 if (_locationWindow == null) {
324 print("LocationWindow not available yet");
325 return;
326 }
327
328 // [dart_IconMapObject_constructor]
329 // Create icon map object
330 GlobalPoint position = GlobalPoint(30.0, 40.0);
331 _iconMapObject = _locationWindow!.addIconMapObject();
332 print("Created icon map object at (${position.latitude}, ${position.longitude})");
333 // [dart_IconMapObject_constructor]
334
335 // [dart_LocationWindow_addIconMapObject]
336 // Add icon map object
337 _iconMapObject = _locationWindow!.addIconMapObject();
338 print("Added icon map object");
339 // [dart_LocationWindow_addIconMapObject]
340
341 if (_iconMapObject != null) {
342 // [dart_IconMapObject_setPosition]
343 // Set icon position
344 GlobalPoint iconPoint = GlobalPoint(200.0, 300.0);
345 bool success = _iconMapObject!.setPosition(iconPoint, 7);
346 print("Set icon position to (${iconPoint.latitude}, ${iconPoint.longitude}): $success");
347 // [dart_IconMapObject_setPosition]
348
349 // [dart_IconMapObject_setPositionAnimated]
350 // Set icon position with animation
351 GlobalPoint animatedIconPoint = GlobalPoint(250.0, 350.0);
352 bool animatedSuccess = _iconMapObject!.setPositionAnimated(animatedIconPoint, 7, 1.5, AnimationType.CUBIC, );
353 print(
354 "Set icon position with animation to (${animatedIconPoint.latitude}, ${animatedIconPoint.longitude}): $animatedSuccess",
355 );
356 // [dart_IconMapObject_setPositionAnimated]
357
358 // [dart_IconMapObject_setSize]
359 // Set icon size
360 bool sizeSuccess = _iconMapObject!.setSize(32.0, 32.0);
361 print("Set icon size to 32x32 pixels: $sizeSuccess");
362 // [dart_IconMapObject_setSize]
363
364 // [dart_IconMapObject_setAngle]
365 // Set icon rotation angle (radians)
366 bool angleSuccess = _iconMapObject!.setAngle(math.pi / 4);
367 print("Set icon rotation angle to π/4: $angleSuccess");
368 // [dart_IconMapObject_setAngle]
369
370 // [dart_IconMapObject_setAngleAnimated]
371 // Set icon rotation with animation (radians)
372 bool angleAnimatedSuccess = _iconMapObject!.setAngleAnimated(
373 math.pi / 2,
374 2.0,
375 AnimationType.SINE,
376 );
377 print(
378 "Set icon rotation with animation to π/2: $angleAnimatedSuccess",
379 );
380 // [dart_IconMapObject_setAngleAnimated]
381
382 // [dart_IconMapObject_setCollisionEnabled]
383 // Enable collision detection
384 bool collisionSuccess = _iconMapObject!.setCollisionEnabled(true);
385 print("Enabled collision detection for icon: $collisionSuccess");
386 // [dart_IconMapObject_setCollisionEnabled]
387
388 // [dart_IconMapObject_setBuffer]
389 // Set collision buffer
390 bool bufferSuccess = _iconMapObject!.setBuffer(10.0, 10.0);
391 print("Set collision buffer to 10x10 pixels: $bufferSuccess");
392 // [dart_IconMapObject_setBuffer]
393
394 // [dart_IconMapObject_setOffset]
395 // Set position offset
396 bool offsetSuccess = _iconMapObject!.setOffset(0.0, -16.0);
397 print("Set position offset to (0.0, -16.0) pixels: $offsetSuccess");
398 // [dart_IconMapObject_setOffset]
399
400 // [dart_IconMapObject_setPriority]
401 // Set rendering priority
402 bool prioritySuccess = _iconMapObject!.setPriority(2);
403 print("Set rendering priority to 2: $prioritySuccess");
404 // [dart_IconMapObject_setPriority]
405
406 // [dart_IconMapObject_setVisible]
407 // Set visibility
408 bool visibleSuccess = _iconMapObject!.setVisible(true);
409 print("Set icon visibility to true: $visibleSuccess");
410 // [dart_IconMapObject_setVisible]
411
412 // [dart_IconMapObject_getMapObjectType]
413 // Get map object type
414 MapObjectType objectType = _iconMapObject!.mapObjectType;
415 print("Icon map object type: $objectType");
416 // [dart_IconMapObject_getMapObjectType]
417
418 // [dart_IconMapObject_setBitmap]
419 // Icon pixels come from package:navigine_sdk ImageProvider (async decode in the engine).
420 ImageProvider iconProvider = ImageProvider.fromImageProvider(
421 const AssetImage('assets/icon.png'),
422 cacheable: true,
423 );
424 bool bitmapSuccess = _iconMapObject!.setBitmap(iconProvider);
425 print("Set icon from ImageProvider: $bitmapSuccess");
426 // [dart_IconMapObject_setBitmap]
427
428 // [dart_IconMapObject_setFlat]
429 // Set icon flat mode
430 bool flatSuccess = _iconMapObject!.setFlat(true);
431 print("Set icon flat mode to true: $flatSuccess");
432 // [dart_IconMapObject_setFlat]
433
434 // [dart_MapObject_setAlpha_1]
435 // Set alpha transparency
436 bool alphaSuccess = _iconMapObject!.setAlpha(0.7);
437 print("Set icon alpha to 0.7: $alphaSuccess");
438 // [dart_MapObject_setAlpha_1]
439
440 // [dart_MapObject_setInteractive_1]
441 // Set interactive mode
442 bool interactiveSuccess = _iconMapObject!.setInteractive(true);
443 print("Set icon interactive to true: $interactiveSuccess");
444 // [dart_MapObject_setInteractive_1]
445
446 // [dart_MapObject_setTitle_1]
447 // Set title
448 bool titleSuccess = _iconMapObject!.setTitle("Icon Object");
449 print("Set icon title to 'Icon Object': $titleSuccess");
450 // [dart_MapObject_setTitle_1]
451
452 // [dart_MapObject_setData_1]
453 // Set custom data
454 Map<String, dynamic> customData = {"key": "value", "number": 42};
455 bool dataSuccess = _iconMapObject!.setData(customData);
456 print("Set icon custom data: $dataSuccess");
457 // [dart_MapObject_setData_1]
458
459 // [dart_MapObject_getId_1]
460 // Get object ID
461 int objectId = _iconMapObject!.id;
462 print("Icon object ID: $objectId");
463 // [dart_MapObject_getId_1]
464
465 // [dart_MapObject_getType_1]
466 // Get object type
467 String objectTypeString = _iconMapObject!.type;
468 print("Icon object type: $objectTypeString");
469 // [dart_MapObject_getType_1]
470
471 // [dart_MapObject_getData_1]
472 // Get custom data
473 Map<String, dynamic> retrievedData = _iconMapObject!.data;
474 print("Icon custom data: $retrievedData");
475 // [dart_MapObject_getData_1]
476 }
477
478 // [dart_LocationWindow_removeIconMapObject]
479 // Remove icon map object
480 if (_iconMapObject != null) {
481 bool removed = _locationWindow!.removeIconMapObject(_iconMapObject!);
482 print("Removed icon map object: $removed");
483 _iconMapObject = null;
484 }
485 // [dart_LocationWindow_removeIconMapObject]
486
487 // Test multiple icon objects
488 List<IconMapObject> icons = [];
489 ImageProvider loopIcon = ImageProvider.fromImageProvider(
490 const AssetImage('assets/icon.png'),
491 cacheable: true,
492 );
493 for (int i = 0; i < 3; i++) {
494 final IconMapObject? icon = _locationWindow!.addIconMapObject();
495 if (icon != null) {
496 icon.setPosition(GlobalPoint(100.0 * i, 150.0 * i));
497 icon.setBitmap(loopIcon);
498 icon.setSize(24.0, 24.0);
499 icon.setAngle(i * math.pi / 6);
500 icons.add(icon);
501 print(
502 "Created icon $i at (${100.0 * i}, ${150.0 * i}) with angle ${i * math.pi / 6}",
503 );
504 }
505 }
506
507 for (int i = 0; i < icons.length; i++) {
508 _locationWindow!.removeIconMapObject(icons[i]);
509 print("Removed icon $i");
510 }
511 }
512
516 void _demonstrateModelMapObjects() {
517 print("--- Model Map Objects ---");
518
519 if (_locationWindow == null) {
520 print("LocationWindow not available yet");
521 return;
522 }
523
524 // [dart_LocationWindow_addModelMapObject]
525 _modelMapObject = _locationWindow!.addModelMapObject();
526 print("Added model map object: ${_modelMapObject != null}");
527 // [dart_LocationWindow_addModelMapObject]
528
529 final ModelMapObject? m = _modelMapObject;
530 if (m == null) {
531 return;
532 }
533
534 // [dart_ModelMapObject_setPosition]
535 bool posOk = m.setPosition(GlobalPoint(12.0, 34.0));
536 print("Model setPosition: $posOk");
537 // [dart_ModelMapObject_setPosition]
538
539 // [dart_ModelMapObject_setPositionAnimated]
540 bool posAnimOk = m.setPositionAnimated(GlobalPoint(15.0, 40.0), 0.5, AnimationType.SINE,
541 );
542 print("Model setPositionAnimated: $posAnimOk");
543 // [dart_ModelMapObject_setPositionAnimated]
544
545 // [dart_ModelMapObject_setModel]
546 ImageProvider texture = ImageProvider.fromImageProvider(
547 const AssetImage('assets/model_texture.png'),
548 cacheable: true,
549 );
550 ModelProvider modelProvider = ModelProvider(
551 texture,
552 onModelRequest: () async {
553 final bytes = await File('/path/to/model.obj').readAsBytes();
554 return ByteData.sublistView(bytes);
555 },
556 );
557 bool modelOk = m.setModel(modelProvider);
558 print("Model setModel: $modelOk");
559 // [dart_ModelMapObject_setModel]
560
561 // [dart_ModelMapObject_setSize]
562 bool sizeOk = m.setSize(64.0, 64.0);
563 print("Model setSize: $sizeOk");
564 // [dart_ModelMapObject_setSize]
565
566 // [dart_ModelMapObject_setCollisionEnabled]
567 bool collOk = m.setCollisionEnabled(true);
568 print("Model setCollisionEnabled: $collOk");
569 // [dart_ModelMapObject_setCollisionEnabled]
570
571 // [dart_ModelMapObject_setAngle]
572 bool angleOk = m.setAngle(math.pi / 4);
573 print("Model setAngle: $angleOk");
574 // [dart_ModelMapObject_setAngle]
575
576 // [dart_ModelMapObject_setAngleAnimated]
577 bool angleAnimOk = m.setAngleAnimated(math.pi / 2, 0.5, AnimationType.QUINT);
578 print("Model setAngleAnimated: $angleAnimOk");
579 // [dart_ModelMapObject_setAngleAnimated]
580
581 // [dart_ModelMapObject_setBuffer]
582 bool bufOk = m.setBuffer(4.0, 4.0);
583 print("Model setBuffer: $bufOk");
584 // [dart_ModelMapObject_setBuffer]
585
586 // [dart_ModelMapObject_setPriority]
587 bool priOk = m.setPriority(10.0);
588 print("Model setPriority: $priOk");
589 // [dart_ModelMapObject_setPriority]
590
591 // [dart_LocationWindow_removeModelMapObject]
592 bool removed = _locationWindow!.removeModelMapObject(m);
593 print("Removed model map object: $removed");
594 _modelMapObject = null;
595 // [dart_LocationWindow_removeModelMapObject]
596 }
597
601 void _demonstratePolygonMapObjects() {
602 print("--- Polygon Map Objects ---");
603
604 if (_locationWindow == null) {
605 print("LocationWindow not available yet");
606 return;
607 }
608
609 // [dart_LocationWindow_addPolygonMapObject]
610 // Add polygon map object
611 _polygonMapObject = _locationWindow!.addPolygonMapObject();
612 print("Added polygon map object");
613 // [dart_LocationWindow_addPolygonMapObject]
614
615 if (_polygonMapObject != null) {
616 // [dart_PolygonMapObject_setPolygon]
617 // Set polygon geometry
618 List<GlobalPoint> points = [
619 GlobalPoint(100.0, 200.0),
620 GlobalPoint(150.0, 250.0),
621 GlobalPoint(200.0, 200.0),
622 GlobalPoint(150.0, 150.0),
623 ];
624 LocationPolygon polygon = LocationPolygon(points, 0);
625 bool success = _polygonMapObject!.setPolygon(polygon);
626 print("Set polygon with ${points.length} points: $success");
627 // [dart_PolygonMapObject_setPolygon]
628
629 // [dart_PolygonMapObject_setColor]
630 // Set polygon color
631 bool colorSuccess = _polygonMapObject!.setColor(const Color(0xB300FF00));
632 print("Set polygon color to green with 70% opacity: $colorSuccess");
633 // [dart_PolygonMapObject_setColor]
634
635 // [dart_PolygonMapObject_setOutlineColor]
636 // Set polygon outline color
637 bool outlineColorSuccess = _polygonMapObject!.setOutlineColor(const Color(0xFF0000FF));
638 print("Set polygon outline color to blue: $outlineColorSuccess");
639 // [dart_PolygonMapObject_setOutlineColor]
640
641 // [dart_PolygonMapObject_setOutlineWidth]
642 // Set polygon outline width
643 bool outlineWidthSuccess = _polygonMapObject!.setOutlineWidth(2.0);
644 print("Set polygon outline width to 2.0 pixels: $outlineWidthSuccess");
645 // [dart_PolygonMapObject_setOutlineWidth]
646
647 // [dart_PolygonMapObject_setOutlineAlpha]
648 // Set polygon outline alpha
649 bool outlineAlphaSuccess = _polygonMapObject!.setOutlineAlpha(0.8);
650 print("Set polygon outline alpha to 0.8: $outlineAlphaSuccess");
651 // [dart_PolygonMapObject_setOutlineAlpha]
652
653 // [dart_PolygonMapObject_setOutlineOrder]
654 // Set polygon outline order
655 bool outlineOrderSuccess = _polygonMapObject!.setOutlineOrder(1);
656 print("Set polygon outline order to 1: $outlineOrderSuccess");
657 // [dart_PolygonMapObject_setOutlineOrder]
658
659 // [dart_PolygonMapObject_setOrder]
660 // Set polygon rendering order
661 bool orderSuccess = _polygonMapObject!.setOrder(2);
662 print("Set polygon rendering order to 2: $orderSuccess");
663 // [dart_PolygonMapObject_setOrder]
664
665 // [dart_PolygonMapObject_setVisible]
666 // Set visibility
667 bool visibleSuccess = _polygonMapObject!.setVisible(true);
668 print("Set polygon visibility to true: $visibleSuccess");
669 // [dart_PolygonMapObject_setVisible]
670
671 // [dart_PolygonMapObject_getMapObjectType]
672 // Get map object type
673 MapObjectType objectType = _polygonMapObject!.mapObjectType;
674 print("Polygon map object type: $objectType");
675 // [dart_PolygonMapObject_getMapObjectType]
676
677 // [dart_MapObject_setAlpha_2]
678 // Set alpha transparency
679 bool alphaSuccess = _polygonMapObject!.setAlpha(0.7);
680 print("Set polygon alpha to 0.7: $alphaSuccess");
681 // [dart_MapObject_setAlpha_2]
682
683 // [dart_MapObject_setInteractive_2]
684 // Set interactive mode
685 bool interactiveSuccess = _polygonMapObject!.setInteractive(true);
686 print("Set polygon interactive to true: $interactiveSuccess");
687 // [dart_MapObject_setInteractive_2]
688
689 // [dart_MapObject_setTitle_2]
690 // Set title
691 bool titleSuccess = _polygonMapObject!.setTitle("Polygon Object");
692 print("Set polygon title to 'Polygon Object': $titleSuccess");
693 // [dart_MapObject_setTitle_2]
694
695 // [dart_MapObject_setData_2]
696 // Set custom data
697 Map<String, dynamic> customData = {"key": "value", "number": 42};
698 bool dataSuccess = _polygonMapObject!.setData(customData);
699 print("Set polygon custom data: $dataSuccess");
700 // [dart_MapObject_setData_2]
701
702 // [dart_MapObject_getId_2]
703 // Get object ID
704 int objectId = _polygonMapObject!.id;
705 print("Polygon object ID: $objectId");
706 // [dart_MapObject_getId_2]
707
708 // [dart_MapObject_getType_2]
709 // Get object type
710 String objectTypeString = _polygonMapObject!.type;
711 print("Polygon object type: $objectTypeString");
712 // [dart_MapObject_getType_2]
713
714 // [dart_MapObject_getData_2]
715 // Get custom data
716 Map<String, dynamic> retrievedData = _polygonMapObject!.data;
717 print("Polygon custom data: $retrievedData");
718 // [dart_MapObject_getData_2]
719 }
720
721 // [dart_LocationWindow_removePolygonMapObject]
722 // Remove polygon map object
723 if (_polygonMapObject != null) {
724 bool removed = _locationWindow!.removePolygonMapObject(
726 );
727 print("Removed polygon map object: $removed");
728 _polygonMapObject = null;
729 }
730 // [dart_LocationWindow_removePolygonMapObject]
731
732 // Test multiple polygon objects
733 List<PolygonMapObject> polygons = [];
734 for (int i = 0; i < 3; i++) {
735 PolygonMapObject polygon = _locationWindow!.addPolygonMapObject();
736 if (polygon != null) {
737 List<GlobalPoint> points = [
738 GlobalPoint(300.0 + i * 50, 400.0 + i * 50),
739 GlobalPoint(350.0 + i * 50, 450.0 + i * 50),
740 GlobalPoint(400.0 + i * 50, 400.0 + i * 50),
741 GlobalPoint(350.0 + i * 50, 350.0 + i * 50),
742 ];
743 LocationPolygon polygonGeometry = LocationPolygon(points, 0);
744 polygon.setPolygon(polygonGeometry);
745 polygon.setColor(const Color(0x800000FF));
746 polygons.add(polygon);
747 print("Created polygon $i with ${points.length} points");
748 }
749 }
750
751 for (int i = 0; i < polygons.length; i++) {
752 _locationWindow!.removePolygonMapObject(polygons[i]);
753 print("Removed polygon $i");
754 }
755 }
756
760 void _demonstratePolylineMapObjects() {
761 print("--- Polyline Map Objects ---");
762
763 if (_locationWindow == null) {
764 print("LocationWindow not available yet");
765 return;
766 }
767
768 // [dart_PolylineMapObject_constructor]
769 // Create polyline map object
770 List<GlobalPoint> points = [
771 GlobalPoint(100.0, 110.0),
772 GlobalPoint(105.0, 115.0),
773 GlobalPoint(110.0, 120.0),
774 GlobalPoint(115.0, 125.0),
775 ];
776 LocationPolyline locationPolyline = LocationPolyline(points, 0);
777 _polylineMapObject = _locationWindow!.addPolylineMapObject();
778 print("Created polyline map object with ${points.length} points");
779 // [dart_PolylineMapObject_constructor]
780
781 // [dart_PolylineMapObject_getPolyline]
782 // Access polyline
783 LocationPolyline polylineShape = _polylineMapObject!.getPolyLine();
784 print("Polyline has ${polylineShape.polyline.points.length} points");
785 // [dart_PolylineMapObject_getPolyline]
786
787 // [dart_LocationWindow_addPolylineMapObject]
788 // Add polyline map object
789 _polylineMapObject = _locationWindow!.addPolylineMapObject();
790 print("Added polyline map object");
791 // [dart_LocationWindow_addPolylineMapObject]
792
793 if (_polylineMapObject != null) {
794 // [dart_PolylineMapObject_setPolyLine]
795 // Set polyline geometry
796 List<GlobalPoint> polylinePoints = [
797 GlobalPoint(0.0, 0.0),
798 GlobalPoint(50.0, 50.0),
799 GlobalPoint(100.0, 0.0),
800 GlobalPoint(150.0, 50.0),
801 ];
802 LocationPolyline locationPolyline = LocationPolyline(polylinePoints, 0);
803 bool success = _polylineMapObject!.setPolyLine(locationPolyline);
804 print("Set polyline geometry: $success");
805 // [dart_PolylineMapObject_setPolyLine]
806
807 // [dart_PolylineMapObject_setWidth]
808 // Set polyline width
809 bool widthSuccess = _polylineMapObject!.setWidth(3.0);
810 print("Set polyline width to 3.0 pixels: $widthSuccess");
811 // [dart_PolylineMapObject_setWidth]
812
813 // [dart_PolylineMapObject_setColor]
814 // Set polyline color
815 bool colorSuccess = _polylineMapObject!.setColor(const Color(0xE6FF8000));
816 print("Set polyline color to orange with 90% opacity: $colorSuccess");
817 // [dart_PolylineMapObject_setColor]
818
819 // [dart_PolylineMapObject_setOrder]
820 // Set rendering order
821 bool orderSuccess = _polylineMapObject!.setOrder(2);
822 print("Set rendering order to 2: $orderSuccess");
823 // [dart_PolylineMapObject_setOrder]
824
825 // [dart_PolylineMapObject_setCapType]
826 // Set cap type
827 bool capSuccess = _polylineMapObject!.setCapType(CapType.ROUND);
828 print("Set cap type to ROUND: $capSuccess");
829 // [dart_PolylineMapObject_setCapType]
830
831 // [dart_PolylineMapObject_setJoinType]
832 // Set join type
833 bool joinSuccess = _polylineMapObject!.setJoinType(JoinType.ROUND);
834 print("Set join type to ROUND: $joinSuccess");
835 // [dart_PolylineMapObject_setJoinType]
836
837 // [dart_PolylineMapObject_setMiterLimit]
838 // Set miter limit
839 bool miterSuccess = _polylineMapObject!.setMiterLimit(5.0);
840 print("Set miter limit to 5.0: $miterSuccess");
841 // [dart_PolylineMapObject_setMiterLimit]
842
843 // [dart_PolylineMapObject_setOutlineWidth]
844 // Set outline width
845 bool outlineWidthSuccess = _polylineMapObject!.setOutlineWidth(1.0);
846 print("Set polyline outline width to 1.0: $outlineWidthSuccess");
847 // [dart_PolylineMapObject_setOutlineWidth]
848
849 // [dart_PolylineMapObject_setOutlineColor]
850 // Set outline color
851 bool outlineColorSuccess = _polylineMapObject!.setOutlineColor(const Color(0xFF000000));
852 print("Set polyline outline color to black: $outlineColorSuccess");
853 // [dart_PolylineMapObject_setOutlineColor]
854
855 // [dart_PolylineMapObject_setOutlineAlpha]
856 // Set outline alpha
857 bool outlineAlphaSuccess = _polylineMapObject!.setOutlineAlpha(0.8);
858 print("Set polyline outline alpha to 0.8: $outlineAlphaSuccess");
859 // [dart_PolylineMapObject_setOutlineAlpha]
860
861 // [dart_PolylineMapObject_setOutlineOrder]
862 // Set outline order
863 bool outlineOrderSuccess = _polylineMapObject!.setOutlineOrder(1);
864 print("Set polyline outline order to 1: $outlineOrderSuccess");
865 // [dart_PolylineMapObject_setOutlineOrder]
866
867 // [dart_PolylineMapObject_setOutlineCapType]
868 // Set outline cap type
869 bool outlineCapSuccess = _polylineMapObject!.setOutlineCapType(
870 CapType.ROUND,
871 );
872 print("Set polyline outline cap type to ROUND: $outlineCapSuccess");
873 // [dart_PolylineMapObject_setOutlineCapType]
874
875 // [dart_PolylineMapObject_setOutlineJoinType]
876 // Set outline join type
877 bool outlineJoinSuccess = _polylineMapObject!.setOutlineJoinType(
878 JoinType.ROUND,
879 );
880 print("Set polyline outline join type to ROUND: $outlineJoinSuccess");
881 // [dart_PolylineMapObject_setOutlineJoinType]
882
883 // [dart_PolylineMapObject_setOutlineMiterLimit]
884 // Set outline miter limit
885 bool outlineMiterSuccess = _polylineMapObject!.setOutlineMiterLimit(3.0);
886 print("Set polyline outline miter limit to 3.0: $outlineMiterSuccess");
887 // [dart_PolylineMapObject_setOutlineMiterLimit]
888
889 // [dart_PolylineMapObject_setVisible]
890 // Set visibility
891 bool visibleSuccess = _polylineMapObject!.setVisible(true);
892 print("Set polyline visibility to true: $visibleSuccess");
893 // [dart_PolylineMapObject_setVisible]
894
895 // [dart_PolylineMapObject_getMapObjectType]
896 // Get map object type
897 MapObjectType objectType = _polylineMapObject!.mapObjectType;
898 print("Polyline map object type: $objectType");
899 // [dart_PolylineMapObject_getMapObjectType]
900
901 // [dart_MapObject_setAlpha_3]
902 // Set alpha transparency
903 bool alphaSuccess = _polylineMapObject!.setAlpha(0.7);
904 print("Set polyline alpha to 0.7: $alphaSuccess");
905 // [dart_MapObject_setAlpha_3]
906
907 // [dart_MapObject_setInteractive_3]
908 // Set interactive mode
909 bool interactiveSuccess = _polylineMapObject!.setInteractive(true);
910 print("Set polyline interactive to true: $interactiveSuccess");
911 // [dart_MapObject_setInteractive_3]
912
913 // [dart_MapObject_setTitle_3]
914 // Set title
915 bool titleSuccess = _polylineMapObject!.setTitle("Polyline Object");
916 print("Set polyline title to 'Polyline Object': $titleSuccess");
917 // [dart_MapObject_setTitle_3]
918
919 // [dart_MapObject_setData_3]
920 // Set custom data
921 Map<String, dynamic> customData = {"key": "value", "number": 42};
922 bool dataSuccess = _polylineMapObject!.setData(customData);
923 print("Set polyline custom data: $dataSuccess");
924 // [dart_MapObject_setData_3]
925
926 // [dart_MapObject_getId_3]
927 // Get object ID
928 int objectId = _polylineMapObject!.id;
929 print("Polyline object ID: $objectId");
930 // [dart_MapObject_getId_3]
931
932 // [dart_MapObject_getType_3]
933 // Get object type
934 String objectTypeString = _polylineMapObject!.type;
935 print("Polyline object type: $objectTypeString");
936 // [dart_MapObject_getType_3]
937
938 // [dart_MapObject_getData_3]
939 // Get custom data
940 Map<String, dynamic> retrievedData = _polylineMapObject!.data;
941 print("Polyline custom data: $retrievedData");
942 // [dart_MapObject_getData_3]
943 }
944
945 // [dart_LocationWindow_removePolylineMapObject]
946 // Remove polyline map object
947 if (_polylineMapObject != null) {
948 bool removed = _locationWindow!.removePolylineMapObject(
950 );
951 print("Removed polyline map object: $removed");
952 _polylineMapObject = null;
953 }
954 // [dart_LocationWindow_removePolylineMapObject]
955
956 // Test multiple polyline objects
957 List<PolylineMapObject> polylines = [];
958 for (int i = 0; i < 3; i++) {
959 PolylineMapObject polyline = _locationWindow!.addPolylineMapObject();
960 if (polyline != null) {
961 List<GlobalPoint> points = [
962 GlobalPoint(i * 30.0, i * 30.0),
963 GlobalPoint((i + 1) * 30.0, (i + 1) * 30.0),
964 ];
965 LocationPolyline locPoly = LocationPolyline(points, 0);
966 polyline.setPolyLine(locPoly);
967 polyline.setWidth(2.0 + i);
968 polyline.setColor(const Color(0xCC00FFFF));
969 polylines.add(polyline);
970 print("Created polyline $i with width ${2.0 + i}");
971 }
972 }
973
974 for (int i = 0; i < polylines.length; i++) {
975 _locationWindow!.removePolylineMapObject(polylines[i]);
976 print("Removed polyline $i");
977 }
978 }
979
983 void _demonstrateDottedPolylineMapObjects() {
984 print("--- Dotted Polyline Map Objects ---");
985
986 if (_locationWindow == null) {
987 print("LocationWindow not available yet");
988 return;
989 }
990
991 // [dart_DottedPolylineMapObject_constructor]
992 // Create dotted polyline map object
993 List<GlobalPoint> points = [
994 GlobalPoint(160.0, 170.0),
995 GlobalPoint(165.0, 175.0),
996 GlobalPoint(170.0, 180.0),
997 GlobalPoint(175.0, 185.0),
998 ];
999 LocationPolyline locationPolyline = LocationPolyline(points, 0);
1000 _dottedPolylineMapObject = _locationWindow!.addDottedPolylineMapObject();
1001 print("Created dotted polyline map object with ${points.length} points");
1002 // [dart_DottedPolylineMapObject_constructor]
1003
1004 // [dart_DottedPolylineMapObject_getPolyline]
1005 // Access dotted polyline
1006 LocationPolyline dottedPolylineShape =
1007 _dottedPolylineMapObject!.getPolyLine();
1008 print(
1009 "Dotted polyline has ${dottedPolylineShape.polyline.points.length} points",
1010 );
1011 // [dart_DottedPolylineMapObject_getPolyline]
1012
1013 // [dart_LocationWindow_addDottedPolylineMapObject]
1014 // Add dotted polyline map object
1015 _dottedPolylineMapObject = _locationWindow!.addDottedPolylineMapObject();
1016 print("Added dotted polyline map object");
1017 // [dart_LocationWindow_addDottedPolylineMapObject]
1018
1019 if (_dottedPolylineMapObject != null) {
1020 // [dart_DottedPolylineMapObject_setPolyline]
1021 // Set dotted polyline geometry
1022 List<GlobalPoint> dottedPoints = [
1023 GlobalPoint(0.0, 100.0),
1024 GlobalPoint(50.0, 150.0),
1025 GlobalPoint(100.0, 100.0),
1026 GlobalPoint(150.0, 150.0),
1027 ];
1028 LocationPolyline locationDottedPolyline = LocationPolyline(dottedPoints, 0);
1029 bool success = _dottedPolylineMapObject!.setPolyLine(
1030 locationDottedPolyline,
1031 );
1032 print("Set dotted polyline geometry: $success");
1033 // [dart_DottedPolylineMapObject_setPolyline]
1034
1035 // [dart_DottedPolylineMapObject_setWidth]
1036 // Set dotted polyline width
1037 bool widthSuccess = _dottedPolylineMapObject!.setWidth(2.0);
1038 print("Set dotted polyline width to 2.0 pixels: $widthSuccess");
1039 // [dart_DottedPolylineMapObject_setWidth]
1040
1041 // [dart_DottedPolylineMapObject_setColor]
1042 // Set dotted polyline color
1043 bool colorSuccess = _dottedPolylineMapObject!.setColor(const Color(0xCC8000FF));
1044 print(
1045 "Set dotted polyline color to purple with 80% opacity: $colorSuccess",
1046 );
1047 // [dart_DottedPolylineMapObject_setColor]
1048
1049 // [dart_DottedPolylineMapObject_setOrder]
1050 // Set rendering order
1051 bool orderSuccess = _dottedPolylineMapObject!.setOrder(3);
1052 print("Set rendering order to 3: $orderSuccess");
1053 // [dart_DottedPolylineMapObject_setOrder]
1054
1055 // [dart_DottedPolylineMapObject_setCollisionEnabled]
1056 // Enable collision detection
1057 bool collisionSuccess = _dottedPolylineMapObject!.setCollisionEnabled(
1058 true,
1059 );
1060 print(
1061 "Enabled collision detection for dotted polyline: $collisionSuccess",
1062 );
1063 // [dart_DottedPolylineMapObject_setCollisionEnabled]
1064
1065 // [dart_DottedPolylineMapObject_setPlacement]
1066 // Set placement type
1067 bool placementSuccess = _dottedPolylineMapObject!.setPlacement(
1068 Placement.center,
1069 );
1070 print("Set dotted polyline placement to center: $placementSuccess");
1071 // [dart_DottedPolylineMapObject_setPlacement]
1072
1073 // [dart_DottedPolylineMapObject_setPlacementMinRatio]
1074 // Set placement min ratio
1075 bool minRatioSuccess = _dottedPolylineMapObject!.setPlacementMinRatio(
1076 0.5,
1077 );
1078 print("Set dotted polyline placement min ratio to 0.5: $minRatioSuccess");
1079 // [dart_DottedPolylineMapObject_setPlacementMinRatio]
1080
1081 // [dart_DottedPolylineMapObject_setPlacementSpacing]
1082 // Set placement spacing
1083 bool spacingSuccess = _dottedPolylineMapObject!.setPlacementSpacing(10.0);
1084 print("Set dotted polyline placement spacing to 10.0: $spacingSuccess");
1085 // [dart_DottedPolylineMapObject_setPlacementSpacing]
1086
1087 // [dart_DottedPolylineMapObject_setPriority]
1088 // Set rendering priority
1089 bool prioritySuccess = _dottedPolylineMapObject!.setPriority(1);
1090 print("Set dotted polyline rendering priority to 1: $prioritySuccess");
1091 // [dart_DottedPolylineMapObject_setPriority]
1092
1093 // [dart_DottedPolylineMapObject_setRepeatDistance]
1094 // Set repeat distance
1095 bool repeatDistanceSuccess = _dottedPolylineMapObject!.setRepeatDistance(
1096 20.0,
1097 );
1098 print(
1099 "Set dotted polyline repeat distance to 20.0: $repeatDistanceSuccess",
1100 );
1101 // [dart_DottedPolylineMapObject_setRepeatDistance]
1102
1103 // [dart_DottedPolylineMapObject_setRepeatGroup]
1104 // Set repeat group
1105 bool repeatGroupSuccess = _dottedPolylineMapObject!.setRepeatGroup(1);
1106 print("Set dotted polyline repeat group to 1: $repeatGroupSuccess");
1107 // [dart_DottedPolylineMapObject_setRepeatGroup]
1108
1109 // [dart_DottedPolylineMapObject_setSize]
1110 // Set size
1111 bool sizeSuccess = _dottedPolylineMapObject!.setSize(16.0, 16.0);
1112 print("Set dotted polyline size to 16x16: $sizeSuccess");
1113 // [dart_DottedPolylineMapObject_setSize]
1114
1115 // [dart_DottedPolylineMapObject_setVisible]
1116 // Set visibility
1117 bool visibleSuccess = _dottedPolylineMapObject!.setVisible(true);
1118 print("Set dotted polyline visibility to true: $visibleSuccess");
1119 // [dart_DottedPolylineMapObject_setVisible]
1120
1121 // [dart_DottedPolylineMapObject_getMapObjectType]
1122 // Get map object type
1123 MapObjectType objectType = _dottedPolylineMapObject!.mapObjectType;
1124 print("Dotted polyline map object type: $objectType");
1125 // [dart_DottedPolylineMapObject_getMapObjectType]
1126
1127 // [dart_MapObject_setAlpha_4]
1128 // Set alpha transparency
1129 bool alphaSuccess = _dottedPolylineMapObject!.setAlpha(0.7);
1130 print("Set dotted polyline alpha to 0.7: $alphaSuccess");
1131 // [dart_MapObject_setAlpha_4]
1132
1133 // [dart_MapObject_setInteractive_4]
1134 // Set interactive mode
1135 bool interactiveSuccess = _dottedPolylineMapObject!.setInteractive(true);
1136 print("Set dotted polyline interactive to true: $interactiveSuccess");
1137 // [dart_MapObject_setInteractive_4]
1138
1139 // [dart_MapObject_setTitle_4]
1140 // Set title
1141 bool titleSuccess = _dottedPolylineMapObject!.setTitle(
1142 "Dotted Polyline Object",
1143 );
1144 print(
1145 "Set dotted polyline title to 'Dotted Polyline Object': $titleSuccess",
1146 );
1147 // [dart_MapObject_setTitle_4]
1148
1149 // [dart_MapObject_setData_4]
1150 // Set custom data
1151 Map<String, dynamic> customData = {"key": "value", "number": 42};
1152 bool dataSuccess = _dottedPolylineMapObject!.setData(customData);
1153 print("Set dotted polyline custom data: $dataSuccess");
1154 // [dart_MapObject_setData_4]
1155
1156 // [dart_MapObject_getId_4]
1157 // Get object ID
1158 int objectId = _dottedPolylineMapObject!.id;
1159 print("Dotted polyline object ID: $objectId");
1160 // [dart_MapObject_getId_4]
1161
1162 // [dart_MapObject_getType_4]
1163 // Get object type
1164 String objectTypeString = _dottedPolylineMapObject!.type;
1165 print("Dotted polyline object type: $objectTypeString");
1166 // [dart_MapObject_getType_4]
1167
1168 // [dart_MapObject_getData_4]
1169 // Get custom data
1170 Map<String, dynamic> retrievedData = _dottedPolylineMapObject!.data;
1171 print("Dotted polyline custom data: $retrievedData");
1172 // [dart_MapObject_getData_4]
1173 }
1174
1175 // [dart_LocationWindow_removeDottedPolylineMapObject]
1176 // Remove dotted polyline map object
1177 if (_dottedPolylineMapObject != null) {
1178 bool removed = _locationWindow!.removeDottedPolylineMapObject(
1180 );
1181 print("Removed dotted polyline map object: $removed");
1183 }
1184 // [dart_LocationWindow_removeDottedPolylineMapObject]
1185
1186 // Test multiple dotted polyline objects
1187 List<DottedPolylineMapObject> dottedPolylines = [];
1188 for (int i = 0; i < 2; i++) {
1189 DottedPolylineMapObject dottedPolyline =
1190 _locationWindow!.addDottedPolylineMapObject();
1191 if (dottedPolyline != null) {
1192 List<GlobalPoint> points = [
1193 GlobalPoint(i * 40.0, i * 40.0 + 100.0),
1194 GlobalPoint((i + 1) * 40.0, (i + 1) * 40.0 + 100.0),
1195 ];
1196 LocationPolyline locPoly = LocationPolyline(points, 0);
1197 dottedPolyline.setPolyLine(locPoly);
1198 dottedPolyline.setWidth(1.5);
1199 dottedPolyline.setColor(const Color(0x99FF00FF));
1200 dottedPolylines.add(dottedPolyline);
1201 print("Created dotted polyline $i");
1202 }
1203 }
1204
1205 for (int i = 0; i < dottedPolylines.length; i++) {
1206 _locationWindow!.removeDottedPolylineMapObject(dottedPolylines[i]);
1207 print("Removed dotted polyline $i");
1208 }
1209 }
1210
1214 void _demonstrateClusterMapObjects() {
1215 print("--- Cluster map objects ---");
1216
1217 if (_locationWindow == null) {
1218 print("LocationWindow not available");
1219 return;
1220 }
1221
1222 // [dart_LocationWindow_addClusterMapObjectController]
1223 _clusterMapObjectController = _locationWindow!.addClusterMapObjectController();
1224 print("Added cluster map object controller");
1225 // [dart_LocationWindow_addClusterMapObjectController]
1226
1227 final controller = _clusterMapObjectController;
1228 if (controller == null) {
1229 return;
1230 }
1231
1232 final clusterIcon1 = _locationWindow!.addIconMapObject();
1233 final clusterIcon2 = _locationWindow!.addIconMapObject();
1234 clusterIcon1?.setPosition(GlobalPoint(100.0, 100.0));
1235 clusterIcon2?.setPosition(GlobalPoint(105.0, 102.0));
1236
1237 // [dart_ClusterMapObjectController_addIconMapObject]
1238 final added1 = controller.addIconMapObject(clusterIcon1);
1239 final added2 = controller.addIconMapObject(clusterIcon2);
1240 print("Registered icons for clustering: $added1, $added2");
1241 // [dart_ClusterMapObjectController_addIconMapObject]
1242
1243 // [dart_ClusterMapObjectController_setEnabled]
1244 controller.setEnabled(true);
1245 print("Clustering enabled");
1246 // [dart_ClusterMapObjectController_setEnabled]
1247
1248 // [dart_ClusterMapObjectController_isEnabled]
1249 final clusteringEnabled = controller.isEnabled;
1250 print("Clustering is enabled: $clusteringEnabled");
1251 // [dart_ClusterMapObjectController_isEnabled]
1252
1253 // [dart_ClusterMapObjectController_setRadius]
1254 controller.setRadius(40.0);
1255 print("Set cluster radius to 40 px");
1256 // [dart_ClusterMapObjectController_setRadius]
1257
1258 // [dart_ClusterMapObjectController_getRadius]
1259 final clusterRadius = controller.getRadius();
1260 print("Cluster radius: $clusterRadius");
1261 // [dart_ClusterMapObjectController_getRadius]
1262
1263 // [dart_ClusterMapObjectController_setInteractive]
1264 final interactiveSuccess = controller.setInteractive(true);
1265 print("Set cluster markers interactive: $interactiveSuccess");
1266 // [dart_ClusterMapObjectController_setInteractive]
1267
1268 // [dart_ClusterMapObjectController_setClusterSize]
1269 final sizeSuccess = controller.setClusterSize(32.0, 32.0);
1270 print("Set default cluster icon size: $sizeSuccess");
1271 // [dart_ClusterMapObjectController_setClusterSize]
1272
1273 _clusterMapObjectControllerListener = DemoClusterMapObjectControllerListener();
1274
1275 // [dart_ClusterMapObjectController_addListener]
1276 controller.addListener(_clusterMapObjectControllerListener!);
1277 print("Added cluster map object listener");
1278 // [dart_ClusterMapObjectController_addListener]
1279
1280 // [dart_ClusterMapObjectController_getClusters]
1281 final clusters = controller.getClusters();
1282 print("Visible clusters: ${clusters.length}");
1283 // [dart_ClusterMapObjectController_getClusters]
1284
1285 if (clusters.isNotEmpty) {
1286 final cluster = clusters.first;
1287 // [dart_ClusterMapObject_setBitmap]
1288 final clusterBitmap = ImageProvider.fromFile("/path/to/cluster.png");
1289 final bitmapSuccess = cluster.setBitmap(clusterBitmap);
1290 print("Set cluster bitmap from ImageProvider: $bitmapSuccess");
1291 // [dart_ClusterMapObject_setBitmap]
1292 }
1293
1294 // [dart_ClusterMapObjectController_removeListener]
1295 controller.removeListener(_clusterMapObjectControllerListener!);
1296 print("Removed cluster map object listener");
1297 // [dart_ClusterMapObjectController_removeListener]
1298
1299 if (clusterIcon1 != null) {
1300 // [dart_ClusterMapObjectController_removeIconMapObject]
1301 final removed = controller.removeIconMapObject(clusterIcon1);
1302 print("Removed icon from cluster controller: $removed");
1303 // [dart_ClusterMapObjectController_removeIconMapObject]
1304 _locationWindow!.removeIconMapObject(clusterIcon1);
1305 }
1306 if (clusterIcon2 != null) {
1307 _locationWindow!.removeIconMapObject(clusterIcon2);
1308 }
1309
1310 // [dart_ClusterMapObjectController_clear]
1311 controller.clear();
1312 print("Cleared cluster controller");
1313 // [dart_ClusterMapObjectController_clear]
1314
1315 // [dart_LocationWindow_removeClusterMapObjectController]
1316 final controllerRemoved =
1317 _locationWindow!.removeClusterMapObjectController(controller);
1318 print("Removed cluster map object controller: $controllerRemoved");
1319 // [dart_LocationWindow_removeClusterMapObjectController]
1320
1323 }
1324
1325 void _demonstrateRemoveAllMapObjects() {
1326 print("--- Remove All Map Objects ---");
1327
1328 if (_locationWindow == null) {
1329 print("LocationWindow not available yet");
1330 return;
1331 }
1332
1333 // Create various map objects
1334 CircleMapObject circle = _locationWindow!.addCircleMapObject();
1335 IconMapObject icon = _locationWindow!.addIconMapObject();
1336 PolygonMapObject polygon = _locationWindow!.addPolygonMapObject();
1337 PolylineMapObject polyline = _locationWindow!.addPolylineMapObject();
1338 DottedPolylineMapObject dottedPolyline =
1339 _locationWindow!.addDottedPolylineMapObject();
1340
1341 print("Created 5 map objects");
1342
1343 // [dart_LocationWindow_removeAllMapObjects]
1344 // Remove all map objects
1345 _locationWindow!.removeAllMapObjects();
1346 print("Removed all map objects");
1347 // [dart_LocationWindow_removeAllMapObjects]
1348 }
1349
1353 void _cleanup() {
1354 if (_circleMapObject != null) {
1355 _locationWindow?.removeCircleMapObject(_circleMapObject!);
1356 _circleMapObject = null;
1357 }
1358 if (_iconMapObject != null) {
1359 _locationWindow?.removeIconMapObject(_iconMapObject!);
1360 _iconMapObject = null;
1361 }
1362 if (_polygonMapObject != null) {
1363 // Polygon objects are removed automatically when LocationWindow is destroyed
1364 _polygonMapObject = null;
1365 }
1366 if (_polylineMapObject != null) {
1367 _locationWindow?.removePolylineMapObject(_polylineMapObject!);
1368 _polylineMapObject = null;
1369 }
1370 if (_dottedPolylineMapObject != null) {
1371 _locationWindow?.removeDottedPolylineMapObject(_dottedPolylineMapObject!);
1373 }
1374 if (_modelMapObject != null) {
1375 _locationWindow?.removeModelMapObject(_modelMapObject!);
1376 _modelMapObject = null;
1377 }
1378 print("LocationWindowMapObjects example cleanup completed");
1379 }
1380}
1381
1382class DemoClusterMapObjectControllerListener implements ClusterMapObjectControllerListener {
1383 final DemoClusterMapObjectListener _clusterChangeListener = DemoClusterMapObjectListener();
1384 ClusterMapObject? _activeCluster;
1385
1386 // [dart_ClusterMapObjectControllerListener_onClusterCreated]
1387 @override
1388 void onClusterCreated(ClusterMapObjectController controller, ClusterMapObject cluster) {
1389 // [dart_ClusterMapObject_addListener]
1390 cluster.addListener(_clusterChangeListener);
1391 print('Added cluster change listener, initial count: ${cluster.count}');
1392 // [dart_ClusterMapObject_addListener]
1393 _activeCluster = cluster;
1394 }
1395 // [dart_ClusterMapObjectControllerListener_onClusterCreated]
1396
1397 // [dart_ClusterMapObjectControllerListener_onClusterDestroyed]
1398 @override
1399 void onClusterDestroyed(ClusterMapObjectController controller, int clusterId) {
1400 final cluster = _activeCluster;
1401 if (cluster != null && cluster.id == clusterId) {
1402 // [dart_ClusterMapObject_removeListener]
1403 cluster.removeListener(_clusterChangeListener);
1404 print('Removed cluster change listener');
1405 // [dart_ClusterMapObject_removeListener]
1406 _activeCluster = null;
1407 }
1408 print('Cluster destroyed, id: $clusterId');
1409 }
1410 // [dart_ClusterMapObjectControllerListener_onClusterDestroyed]
1411}
1412
1413class DemoClusterMapObjectListener implements ClusterMapObjectListener {
1414 // [dart_ClusterMapObjectListener_onClusterChanged]
1415 @override
1416 void onClusterChanged(ClusterMapObject cluster) {
1417 final memberCount = cluster.getCount();
1418 print("Cluster changed, member count: $memberCount");
1419 }
1420 // [dart_ClusterMapObjectListener_onClusterChanged]
1421}
1422
1423// Main function