44class LocationWindowMapObjectsExample {
55 LocationWindowMapObjectsExample() {
56 _demonstrateLocationWindowMapObjectsMethods();
62 void _demonstrateLocationWindowMapObjectsMethods() {
63 print(
"=== LocationWindowMapObjects Example ===");
65 _demonstrateLocationScopedGeometryRecords();
67 _demonstrateCircleMapObjects();
68 _demonstrateIconMapObjects();
69 _demonstrateClusterMapObjects();
70 _demonstrateModelMapObjects();
71 _demonstratePolygonMapObjects();
72 _demonstratePolylineMapObjects();
73 _demonstrateDottedPolylineMapObjects();
74 _demonstrateRemoveAllMapObjects();
81 void _demonstrateLocationScopedGeometryRecords() {
82 print(
"--- LocationPolygon / LocationPolyline records ---");
90 Polygon metricPolygon = Polygon(ring);
91 LocationPolygon locationPolygon = LocationPolygon(metricPolygon, 42, 7);
92 Polygon polygonBack = locationPolygon.
polygon;
94 "LocationPolygon: location ${locationPolygon.locationId} sublocation ${locationPolygon.sublocationId} vertices ${polygonBack.points.length}",
99 List<Point> linePts = [Point(0.0, 0.0), Point(10.0, 10.0)];
100 Polyline metricPolyline = Polyline(linePts);
101 LocationPolyline locationPolyline = LocationPolyline(metricPolyline, 42, 7);
102 Polyline polylineBack = locationPolyline.
polyline;
103 print(
"LocationPolyline points ${polylineBack.points.length}");
110 void _demonstrateCircleMapObjects() {
111 print(
"--- Circle Map Objects ---");
114 print(
"LocationWindow not available yet");
120 LocationPoint center = LocationPoint(10.0, 20.0);
123 "Created circle map object with center (${center.x}, ${center.y}) and radius 5.0",
130 print(
"Circle center: (${circleCenter.x}, ${circleCenter.y})");
136 print(
"Circle radius: $radius");
142 print(
"Added circle map object");
148 LocationPoint centerPoint = LocationPoint(100.0, 200.0);
151 "Set circle position to (${centerPoint.x}, ${centerPoint.y}): $success",
157 LocationPoint animatedPoint = LocationPoint(150.0, 250.0);
161 AnimationType.LINEAR,
164 "Set circle position with animation to (${animatedPoint.x}, ${animatedPoint.y}): $animatedSuccess",
171 print(
"Set position offset to (2.0, 3.0) pixels: $offsetSuccess");
182 print(
"Set circle outline color to blue: $outlineColorSuccess");
188 print(
"Set circle outline alpha to 0.5: $outlineAlphaSuccess");
194 print(
"Set circle outline radius to 2.0: $outlineRadiusSuccess");
200 print(
"Set circle color to red with 80% opacity: $colorSuccess");
206 print(
"Set circle radius to 10.0 meters: $radiusSuccess");
212 print(
"Enabled collision detection for circle: $collisionSuccess");
218 print(
"Set collision buffer to 5x5 pixels: $bufferSuccess");
224 print(
"Set rendering priority to 1: $prioritySuccess");
230 print(
"Set circle visibility to true: $visibleSuccess");
236 print(
"Circle map object type: $objectType");
242 print(
"Set circle alpha to 0.7: $alphaSuccess");
248 print(
"Set circle interactive to true: $interactiveSuccess");
254 print(
"Set circle title to 'Circle Object': $titleSuccess");
259 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
261 print(
"Set circle custom data: $dataSuccess");
267 print(
"Circle object ID: $objectId");
273 print(
"Circle object type: $objectTypeString");
279 print(
"Circle custom data: $retrievedData");
287 print(
"Removed circle map object: $removed");
293 List<CircleMapObject> circles = [];
294 for (
int i = 0; i < 3; i++) {
296 if (circle !=
null) {
297 circle.
setPosition(LocationPoint(50.0 * i, 100.0 * i));
298 circle.
setColor(0.0, 1.0, 0.0, 0.6);
302 "Created circle $i at (${50.0 * i}, ${100.0 * i}) with radius ${5.0 + i * 2.0}",
307 for (
int i = 0; i < circles.length; i++) {
309 print(
"Removed circle $i");
316 void _demonstrateIconMapObjects() {
317 print(
"--- Icon Map Objects ---");
320 print(
"LocationWindow not available yet");
326 LocationPoint position = LocationPoint(30.0, 40.0);
328 print(
"Created icon map object at (${position.x}, ${position.y})");
334 print(
"Icon position: (${iconPosition.x}, ${iconPosition.y})");
340 print(
"Added icon map object");
346 LocationPoint iconPoint = LocationPoint(200.0, 300.0);
348 print(
"Set icon position to (${iconPoint.x}, ${iconPoint.y}): $success");
353 LocationPoint animatedIconPoint = LocationPoint(250.0, 350.0);
360 "Set icon position with animation to (${animatedIconPoint.x}, ${animatedIconPoint.y}): $animatedSuccess",
367 print(
"Set icon size to 32x32 pixels: $sizeSuccess");
373 print(
"Set icon rotation angle to 45 degrees: $angleSuccess");
384 "Set icon rotation with animation to 90 degrees: $angleAnimatedSuccess",
390 bool collisionSuccess =
_iconMapObject!.setCollisionEnabled(
true);
391 print(
"Enabled collision detection for icon: $collisionSuccess");
397 print(
"Set collision buffer to 10x10 pixels: $bufferSuccess");
403 print(
"Set position offset to (0.0, -16.0) pixels: $offsetSuccess");
409 print(
"Set rendering priority to 2: $prioritySuccess");
415 print(
"Set icon visibility to true: $visibleSuccess");
421 print(
"Icon map object type: $objectType");
426 ImageProvider iconProvider = ImageProvider.fromImageProvider(
427 const AssetImage(
'assets/icon.png'),
431 print(
"Set icon from ImageProvider: $bitmapSuccess");
437 print(
"Set icon flat mode to true: $flatSuccess");
443 print(
"Set icon alpha to 0.7: $alphaSuccess");
449 print(
"Set icon interactive to true: $interactiveSuccess");
455 print(
"Set icon title to 'Icon Object': $titleSuccess");
460 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
462 print(
"Set icon custom data: $dataSuccess");
468 print(
"Icon object ID: $objectId");
474 print(
"Icon object type: $objectTypeString");
480 print(
"Icon custom data: $retrievedData");
488 print(
"Removed icon map object: $removed");
494 List<IconMapObject> icons = [];
495 ImageProvider loopIcon = ImageProvider.fromImageProvider(
496 const AssetImage(
'assets/icon.png'),
499 for (
int i = 0; i < 3; i++) {
502 icon.
setPosition(LocationPoint(100.0 * i, 150.0 * i));
508 "Created icon $i at (${100.0 * i}, ${150.0 * i}) with angle ${i * 30.0}",
513 for (
int i = 0; i < icons.length; i++) {
515 print(
"Removed icon $i");
522 void _demonstrateModelMapObjects() {
523 print(
"--- Model Map Objects ---");
526 print(
"LocationWindow not available yet");
532 print(
"Added model map object: ${_modelMapObject != null}");
541 bool posOk = m.
setPosition(LocationPoint(12.0, 34.0));
542 print(
"Model setPosition: $posOk");
547 LocationPoint(15.0, 40.0),
551 print(
"Model setPositionAnimated: $posAnimOk");
555 ImageProvider texture = ImageProvider.fromImageProvider(
556 const AssetImage(
'assets/model_texture.png'),
559 ModelProvider modelProvider = ModelProvider(
561 onModelRequest: () async {
562 final bytes = await File(
'/path/to/model.obj').readAsBytes();
563 return ByteData.sublistView(bytes);
566 bool modelOk = m.
setModel(modelProvider);
567 print(
"Model setModel: $modelOk");
571 bool sizeOk = m.
setSize(64.0, 64.0);
572 print(
"Model setSize: $sizeOk");
577 print(
"Model setCollisionEnabled: $collOk");
582 print(
"Model setAngle: $angleOk");
587 print(
"Model setAngleAnimated: $angleAnimOk");
592 print(
"Model setBuffer: $bufOk");
597 print(
"Model setPriority: $priOk");
602 print(
"Removed model map object: $removed");
610 void _demonstratePolygonMapObjects() {
611 print(
"--- Polygon Map Objects ---");
614 print(
"LocationWindow not available yet");
621 print(
"Added polygon map object");
627 List<Point> points = [
633 Polygon metricPolygon = Polygon(points);
634 LocationPolygon polygon = LocationPolygon(metricPolygon, 1, 0);
636 print(
"Set polygon with ${points.length} points: $success");
642 print(
"Set polygon color to green with 70% opacity: $colorSuccess");
653 print(
"Set polygon outline color to blue: $outlineColorSuccess");
659 print(
"Set polygon outline width to 2.0 pixels: $outlineWidthSuccess");
665 print(
"Set polygon outline alpha to 0.8: $outlineAlphaSuccess");
671 print(
"Set polygon outline order to 1: $outlineOrderSuccess");
677 print(
"Set polygon rendering order to 2: $orderSuccess");
683 print(
"Set polygon visibility to true: $visibleSuccess");
689 print(
"Polygon map object type: $objectType");
695 print(
"Set polygon alpha to 0.7: $alphaSuccess");
701 print(
"Set polygon interactive to true: $interactiveSuccess");
707 print(
"Set polygon title to 'Polygon Object': $titleSuccess");
712 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
714 print(
"Set polygon custom data: $dataSuccess");
720 print(
"Polygon object ID: $objectId");
726 print(
"Polygon object type: $objectTypeString");
732 print(
"Polygon custom data: $retrievedData");
742 print(
"Removed polygon map object: $removed");
748 List<PolygonMapObject> polygons = [];
749 for (
int i = 0; i < 3; i++) {
751 if (polygon !=
null) {
752 List<Point> points = [
753 Point(300.0 + i * 50, 400.0 + i * 50),
754 Point(350.0 + i * 50, 450.0 + i * 50),
755 Point(400.0 + i * 50, 400.0 + i * 50),
756 Point(350.0 + i * 50, 350.0 + i * 50),
758 Polygon metricPoly = Polygon(points);
759 LocationPolygon polygonGeometry = LocationPolygon(metricPoly, 1, 0);
761 polygon.
setColor(0.0, 0.0, 1.0, 0.5);
762 polygons.add(polygon);
763 print(
"Created polygon $i with ${points.length} points");
767 for (
int i = 0; i < polygons.length; i++) {
769 print(
"Removed polygon $i");
776 void _demonstratePolylineMapObjects() {
777 print(
"--- Polyline Map Objects ---");
780 print(
"LocationWindow not available yet");
786 List<Point> points = [
792 Polyline polyline = Polyline(points);
793 LocationPolyline locationPolyline = LocationPolyline(polyline, 1, 0);
795 print(
"Created polyline map object with ${points.length} points");
801 print(
"Polyline has ${polylineShape.polyline.points.length} points");
807 print(
"Added polyline map object");
813 List<Point> polylinePoints = [
819 Polyline polyline = Polyline(polylinePoints);
820 LocationPolyline locationPolyline = LocationPolyline(polyline, 1, 0);
822 print(
"Set polyline geometry: $success");
828 print(
"Set polyline width to 3.0 pixels: $widthSuccess");
834 print(
"Set polyline color to orange with 90% opacity: $colorSuccess");
840 print(
"Set rendering order to 2: $orderSuccess");
846 print(
"Set cap type to ROUND: $capSuccess");
852 print(
"Set join type to ROUND: $joinSuccess");
858 print(
"Set miter limit to 5.0: $miterSuccess");
864 print(
"Set polyline outline width to 1.0: $outlineWidthSuccess");
875 print(
"Set polyline outline color to black: $outlineColorSuccess");
881 print(
"Set polyline outline alpha to 0.8: $outlineAlphaSuccess");
887 print(
"Set polyline outline order to 1: $outlineOrderSuccess");
895 print(
"Set polyline outline cap type to ROUND: $outlineCapSuccess");
903 print(
"Set polyline outline join type to ROUND: $outlineJoinSuccess");
909 print(
"Set polyline outline miter limit to 3.0: $outlineMiterSuccess");
915 print(
"Set polyline visibility to true: $visibleSuccess");
921 print(
"Polyline map object type: $objectType");
927 print(
"Set polyline alpha to 0.7: $alphaSuccess");
933 print(
"Set polyline interactive to true: $interactiveSuccess");
939 print(
"Set polyline title to 'Polyline Object': $titleSuccess");
944 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
946 print(
"Set polyline custom data: $dataSuccess");
952 print(
"Polyline object ID: $objectId");
958 print(
"Polyline object type: $objectTypeString");
964 print(
"Polyline custom data: $retrievedData");
974 print(
"Removed polyline map object: $removed");
980 List<PolylineMapObject> polylines = [];
981 for (
int i = 0; i < 3; i++) {
983 if (polyline !=
null) {
984 List<Point> points = [
985 Point(i * 30.0, i * 30.0),
986 Point((i + 1) * 30.0, (i + 1) * 30.0),
988 Polyline poly = Polyline(points);
989 LocationPolyline locPoly = LocationPolyline(poly, 1, 0);
992 polyline.
setColor(0.0, 1.0, 1.0, 0.8);
993 polylines.add(polyline);
994 print(
"Created polyline $i with width ${2.0 + i}");
998 for (
int i = 0; i < polylines.length; i++) {
1000 print(
"Removed polyline $i");
1007 void _demonstrateDottedPolylineMapObjects() {
1008 print(
"--- Dotted Polyline Map Objects ---");
1011 print(
"LocationWindow not available yet");
1017 List<Point> points = [
1018 Point(160.0, 170.0),
1019 Point(165.0, 175.0),
1020 Point(170.0, 180.0),
1021 Point(175.0, 185.0),
1023 Polyline polyline = Polyline(points);
1024 LocationPolyline locationPolyline = LocationPolyline(polyline, 1, 0);
1026 print(
"Created dotted polyline map object with ${points.length} points");
1031 LocationPolyline dottedPolylineShape =
1034 "Dotted polyline has ${dottedPolylineShape.polyline.points.length} points",
1041 print(
"Added dotted polyline map object");
1047 List<Point> dottedPoints = [
1050 Point(100.0, 100.0),
1051 Point(150.0, 150.0),
1053 Polyline dottedPolyline = Polyline(dottedPoints);
1054 LocationPolyline locationDottedPolyline = LocationPolyline(
1060 locationDottedPolyline,
1062 print(
"Set dotted polyline geometry: $success");
1068 print(
"Set dotted polyline width to 2.0 pixels: $widthSuccess");
1080 "Set dotted polyline color to purple with 80% opacity: $colorSuccess",
1087 print(
"Set rendering order to 3: $orderSuccess");
1096 "Enabled collision detection for dotted polyline: $collisionSuccess",
1105 print(
"Set dotted polyline placement to center: $placementSuccess");
1113 print(
"Set dotted polyline placement min ratio to 0.5: $minRatioSuccess");
1119 print(
"Set dotted polyline placement spacing to 10.0: $spacingSuccess");
1125 print(
"Set dotted polyline rendering priority to 1: $prioritySuccess");
1134 "Set dotted polyline repeat distance to 20.0: $repeatDistanceSuccess",
1141 print(
"Set dotted polyline repeat group to 1: $repeatGroupSuccess");
1147 print(
"Set dotted polyline size to 16x16: $sizeSuccess");
1153 print(
"Set dotted polyline visibility to true: $visibleSuccess");
1159 print(
"Dotted polyline map object type: $objectType");
1165 print(
"Set dotted polyline alpha to 0.7: $alphaSuccess");
1171 print(
"Set dotted polyline interactive to true: $interactiveSuccess");
1177 "Dotted Polyline Object",
1180 "Set dotted polyline title to 'Dotted Polyline Object': $titleSuccess",
1186 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
1188 print(
"Set dotted polyline custom data: $dataSuccess");
1194 print(
"Dotted polyline object ID: $objectId");
1200 print(
"Dotted polyline object type: $objectTypeString");
1206 print(
"Dotted polyline custom data: $retrievedData");
1216 print(
"Removed dotted polyline map object: $removed");
1222 List<DottedPolylineMapObject> dottedPolylines = [];
1223 for (
int i = 0; i < 2; i++) {
1224 DottedPolylineMapObject dottedPolyline =
1226 if (dottedPolyline !=
null) {
1227 List<Point> points = [
1228 Point(i * 40.0, i * 40.0 + 100.0),
1229 Point((i + 1) * 40.0, (i + 1) * 40.0 + 100.0),
1231 Polyline poly = Polyline(points);
1232 LocationPolyline locPoly = LocationPolyline(poly, 1, 0);
1234 dottedPolyline.setWidth(1.5);
1235 dottedPolyline.
setColor(1.0, 0.0, 1.0, 0.6);
1236 dottedPolylines.add(dottedPolyline);
1237 print(
"Created dotted polyline $i");
1241 for (
int i = 0; i < dottedPolylines.length; i++) {
1243 print(
"Removed dotted polyline $i");
1250 void _demonstrateClusterMapObjects() {
1251 print(
"--- Cluster map objects ---");
1254 print(
"LocationWindow not available");
1260 print(
"Added cluster map object controller");
1264 if (controller ==
null) {
1270 clusterIcon1?.setPosition(LocationPoint(100.0, 100.0));
1271 clusterIcon2?.setPosition(LocationPoint(105.0, 102.0));
1274 final added1 = controller.addIconMapObject(clusterIcon1);
1275 final added2 = controller.addIconMapObject(clusterIcon2);
1276 print(
"Registered icons for clustering: $added1, $added2");
1280 controller.setEnabled(
true);
1281 print(
"Clustering enabled");
1285 final clusteringEnabled = controller.isEnabled;
1286 print(
"Clustering is enabled: $clusteringEnabled");
1290 controller.setRadius(40.0);
1291 print(
"Set cluster radius to 40 px");
1295 final clusterRadius = controller.getRadius();
1296 print(
"Cluster radius: $clusterRadius");
1300 final interactiveSuccess = controller.setInteractive(
true);
1301 print(
"Set cluster markers interactive: $interactiveSuccess");
1305 final sizeSuccess = controller.setClusterSize(32.0, 32.0);
1306 print(
"Set default cluster icon size: $sizeSuccess");
1313 print(
"Added cluster map object listener");
1317 final clusters = controller.getClusters();
1318 print(
"Visible clusters: ${clusters.length}");
1321 if (clusters.isNotEmpty) {
1322 final cluster = clusters.first;
1324 final clusterBitmap = ImageProvider.fromFile(
"/path/to/cluster.png");
1325 final bitmapSuccess = cluster.setBitmap(clusterBitmap);
1326 print(
"Set cluster bitmap from ImageProvider: $bitmapSuccess");
1332 print(
"Removed cluster map object listener");
1335 if (clusterIcon1 !=
null) {
1337 final removed = controller.removeIconMapObject(clusterIcon1);
1338 print(
"Removed icon from cluster controller: $removed");
1342 if (clusterIcon2 !=
null) {
1348 print(
"Cleared cluster controller");
1352 final controllerRemoved =
1354 print(
"Removed cluster map object controller: $controllerRemoved");
1361 void _demonstrateRemoveAllMapObjects() {
1362 print(
"--- Remove All Map Objects ---");
1365 print(
"LocationWindow not available yet");
1374 DottedPolylineMapObject dottedPolyline =
1377 print(
"Created 5 map objects");
1382 print(
"Removed all map objects");
1414 print(
"LocationWindowMapObjects example cleanup completed");