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