34class LocationWindowMapObjectsExample {
42 LocationWindowMapObjectsExample() {
43 _demonstrateLocationWindowMapObjectsMethods();
49 void _demonstrateLocationWindowMapObjectsMethods() {
50 print(
"=== LocationWindowMapObjects Example ===");
52 _demonstrateLocationScopedGeometryRecords();
54 _demonstrateCircleMapObjects();
55 _demonstrateIconMapObjects();
56 _demonstratePolygonMapObjects();
57 _demonstratePolylineMapObjects();
58 _demonstrateDottedPolylineMapObjects();
59 _demonstrateRemoveAllMapObjects();
66 void _demonstrateLocationScopedGeometryRecords() {
67 print(
"--- LocationPolygon / LocationPolyline records ---");
75 Polygon metricPolygon = Polygon(ring);
76 LocationPolygon locationPolygon = LocationPolygon(metricPolygon, 42, 7);
77 Polygon polygonBack = locationPolygon.
polygon;
79 "LocationPolygon: location ${locationPolygon.locationId} sublocation ${locationPolygon.sublocationId} vertices ${polygonBack.points.length}",
84 List<Point> linePts = [Point(0.0, 0.0), Point(10.0, 10.0)];
85 Polyline metricPolyline = Polyline(linePts);
86 LocationPolyline locationPolyline = LocationPolyline(metricPolyline, 42, 7);
87 Polyline polylineBack = locationPolyline.
polyline;
88 print(
"LocationPolyline points ${polylineBack.points.length}");
95 void _demonstrateCircleMapObjects() {
96 print(
"--- Circle Map Objects ---");
99 print(
"LocationWindow not available yet");
105 LocationPoint center = LocationPoint(10.0, 20.0);
108 "Created circle map object with center (${center.x}, ${center.y}) and radius 5.0",
115 print(
"Circle center: (${circleCenter.x}, ${circleCenter.y})");
121 print(
"Circle radius: $radius");
127 print(
"Added circle map object");
133 LocationPoint centerPoint = LocationPoint(100.0, 200.0);
136 "Set circle position to (${centerPoint.x}, ${centerPoint.y}): $success",
142 LocationPoint animatedPoint = LocationPoint(150.0, 250.0);
146 AnimationType.LINEAR,
149 "Set circle position with animation to (${animatedPoint.x}, ${animatedPoint.y}): $animatedSuccess",
156 print(
"Set position offset to (2.0, 3.0) pixels: $offsetSuccess");
167 print(
"Set circle outline color to blue: $outlineColorSuccess");
173 print(
"Set circle outline alpha to 0.5: $outlineAlphaSuccess");
179 print(
"Set circle outline radius to 2.0: $outlineRadiusSuccess");
185 print(
"Set circle color to red with 80% opacity: $colorSuccess");
191 print(
"Set circle radius to 10.0 meters: $radiusSuccess");
197 print(
"Enabled collision detection for circle: $collisionSuccess");
203 print(
"Set collision buffer to 5x5 pixels: $bufferSuccess");
209 print(
"Set rendering priority to 1: $prioritySuccess");
215 print(
"Set circle visibility to true: $visibleSuccess");
221 print(
"Circle map object type: $objectType");
227 print(
"Set circle alpha to 0.7: $alphaSuccess");
233 print(
"Set circle interactive to true: $interactiveSuccess");
239 print(
"Set circle title to 'Circle Object': $titleSuccess");
244 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
246 print(
"Set circle custom data: $dataSuccess");
252 print(
"Circle object ID: $objectId");
258 print(
"Circle object type: $objectTypeString");
264 print(
"Circle custom data: $retrievedData");
272 print(
"Removed circle map object: $removed");
278 List<CircleMapObject> circles = [];
279 for (
int i = 0; i < 3; i++) {
281 if (circle !=
null) {
282 circle.
setPosition(LocationPoint(50.0 * i, 100.0 * i));
283 circle.
setColor(0.0, 1.0, 0.0, 0.6);
287 "Created circle $i at (${50.0 * i}, ${100.0 * i}) with radius ${5.0 + i * 2.0}",
292 for (
int i = 0; i < circles.length; i++) {
294 print(
"Removed circle $i");
301 void _demonstrateIconMapObjects() {
302 print(
"--- Icon Map Objects ---");
305 print(
"LocationWindow not available yet");
311 LocationPoint position = LocationPoint(30.0, 40.0);
313 print(
"Created icon map object at (${position.x}, ${position.y})");
319 print(
"Icon position: (${iconPosition.x}, ${iconPosition.y})");
325 print(
"Added icon map object");
331 LocationPoint iconPoint = LocationPoint(200.0, 300.0);
333 print(
"Set icon position to (${iconPoint.x}, ${iconPoint.y}): $success");
338 LocationPoint animatedIconPoint = LocationPoint(250.0, 350.0);
345 "Set icon position with animation to (${animatedIconPoint.x}, ${animatedIconPoint.y}): $animatedSuccess",
352 print(
"Set icon size to 32x32 pixels: $sizeSuccess");
358 print(
"Set icon rotation angle to 45 degrees: $angleSuccess");
369 "Set icon rotation with animation to 90 degrees: $angleAnimatedSuccess",
375 bool collisionSuccess =
_iconMapObject!.setCollisionEnabled(
true);
376 print(
"Enabled collision detection for icon: $collisionSuccess");
382 print(
"Set collision buffer to 10x10 pixels: $bufferSuccess");
388 print(
"Set position offset to (0.0, -16.0) pixels: $offsetSuccess");
394 print(
"Set rendering priority to 2: $prioritySuccess");
400 print(
"Set icon visibility to true: $visibleSuccess");
406 print(
"Icon map object type: $objectType");
412 print(
"Set icon image: $iconSuccess");
417 bool bitmapSuccess =
_iconMapObject!.setBitmap(
"path/to/bitmap.png");
418 print(
"Set icon bitmap: $bitmapSuccess");
424 print(
"Set icon flat mode to true: $flatSuccess");
429 bool placementSuccess =
_iconMapObject!.setPlacement(Placement.center);
430 print(
"Set icon placement to center: $placementSuccess");
436 print(
"Set icon alpha to 0.7: $alphaSuccess");
442 print(
"Set icon interactive to true: $interactiveSuccess");
448 print(
"Set icon title to 'Icon Object': $titleSuccess");
453 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
455 print(
"Set icon custom data: $dataSuccess");
461 print(
"Icon object ID: $objectId");
467 print(
"Icon object type: $objectTypeString");
473 print(
"Icon custom data: $retrievedData");
481 print(
"Removed icon map object: $removed");
487 List<IconMapObject> icons = [];
488 for (
int i = 0; i < 3; i++) {
491 icon.
setPosition(LocationPoint(100.0 * i, 150.0 * i));
496 "Created icon $i at (${100.0 * i}, ${150.0 * i}) with angle ${i * 30.0}",
501 for (
int i = 0; i < icons.length; i++) {
503 print(
"Removed icon $i");
510 void _demonstratePolygonMapObjects() {
511 print(
"--- Polygon Map Objects ---");
514 print(
"LocationWindow not available yet");
521 print(
"Added polygon map object");
527 List<Point> points = [
533 Polygon metricPolygon = Polygon(points);
534 LocationPolygon polygon = LocationPolygon(metricPolygon, 1, 0);
536 print(
"Set polygon with ${points.length} points: $success");
542 print(
"Set polygon color to green with 70% opacity: $colorSuccess");
553 print(
"Set polygon outline color to blue: $outlineColorSuccess");
559 print(
"Set polygon outline width to 2.0 pixels: $outlineWidthSuccess");
565 print(
"Set polygon outline alpha to 0.8: $outlineAlphaSuccess");
571 print(
"Set polygon outline order to 1: $outlineOrderSuccess");
577 print(
"Set polygon rendering order to 2: $orderSuccess");
583 print(
"Set polygon visibility to true: $visibleSuccess");
589 print(
"Polygon map object type: $objectType");
595 print(
"Set polygon alpha to 0.7: $alphaSuccess");
601 print(
"Set polygon interactive to true: $interactiveSuccess");
607 print(
"Set polygon title to 'Polygon Object': $titleSuccess");
612 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
614 print(
"Set polygon custom data: $dataSuccess");
620 print(
"Polygon object ID: $objectId");
626 print(
"Polygon object type: $objectTypeString");
632 print(
"Polygon custom data: $retrievedData");
642 print(
"Removed polygon map object: $removed");
648 List<PolygonMapObject> polygons = [];
649 for (
int i = 0; i < 3; i++) {
651 if (polygon !=
null) {
652 List<Point> points = [
653 Point(300.0 + i * 50, 400.0 + i * 50),
654 Point(350.0 + i * 50, 450.0 + i * 50),
655 Point(400.0 + i * 50, 400.0 + i * 50),
656 Point(350.0 + i * 50, 350.0 + i * 50),
658 Polygon metricPoly = Polygon(points);
659 LocationPolygon polygonGeometry = LocationPolygon(metricPoly, 1, 0);
661 polygon.
setColor(0.0, 0.0, 1.0, 0.5);
662 polygons.add(polygon);
663 print(
"Created polygon $i with ${points.length} points");
667 for (
int i = 0; i < polygons.length; i++) {
669 print(
"Removed polygon $i");
676 void _demonstratePolylineMapObjects() {
677 print(
"--- Polyline Map Objects ---");
680 print(
"LocationWindow not available yet");
686 List<Point> points = [
692 Polyline polyline = Polyline(points);
693 LocationPolyline locationPolyline = LocationPolyline(polyline, 1, 0);
695 print(
"Created polyline map object with ${points.length} points");
701 print(
"Polyline has ${polylineShape.polyline.points.length} points");
707 print(
"Added polyline map object");
713 List<Point> polylinePoints = [
719 Polyline polyline = Polyline(polylinePoints);
720 LocationPolyline locationPolyline = LocationPolyline(polyline, 1, 0);
722 print(
"Set polyline geometry: $success");
728 print(
"Set polyline width to 3.0 pixels: $widthSuccess");
734 print(
"Set polyline color to orange with 90% opacity: $colorSuccess");
740 print(
"Set rendering order to 2: $orderSuccess");
746 print(
"Set cap type to ROUND: $capSuccess");
752 print(
"Set join type to ROUND: $joinSuccess");
758 print(
"Set miter limit to 5.0: $miterSuccess");
764 print(
"Set polyline outline width to 1.0: $outlineWidthSuccess");
775 print(
"Set polyline outline color to black: $outlineColorSuccess");
781 print(
"Set polyline outline alpha to 0.8: $outlineAlphaSuccess");
787 print(
"Set polyline outline order to 1: $outlineOrderSuccess");
795 print(
"Set polyline outline cap type to ROUND: $outlineCapSuccess");
803 print(
"Set polyline outline join type to ROUND: $outlineJoinSuccess");
809 print(
"Set polyline outline miter limit to 3.0: $outlineMiterSuccess");
815 print(
"Set polyline visibility to true: $visibleSuccess");
821 print(
"Polyline map object type: $objectType");
827 print(
"Set polyline alpha to 0.7: $alphaSuccess");
833 print(
"Set polyline interactive to true: $interactiveSuccess");
839 print(
"Set polyline title to 'Polyline Object': $titleSuccess");
844 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
846 print(
"Set polyline custom data: $dataSuccess");
852 print(
"Polyline object ID: $objectId");
858 print(
"Polyline object type: $objectTypeString");
864 print(
"Polyline custom data: $retrievedData");
874 print(
"Removed polyline map object: $removed");
880 List<PolylineMapObject> polylines = [];
881 for (
int i = 0; i < 3; i++) {
883 if (polyline !=
null) {
884 List<Point> points = [
885 Point(i * 30.0, i * 30.0),
886 Point((i + 1) * 30.0, (i + 1) * 30.0),
888 Polyline poly = Polyline(points);
889 LocationPolyline locPoly = LocationPolyline(poly, 1, 0);
892 polyline.
setColor(0.0, 1.0, 1.0, 0.8);
893 polylines.add(polyline);
894 print(
"Created polyline $i with width ${2.0 + i}");
898 for (
int i = 0; i < polylines.length; i++) {
900 print(
"Removed polyline $i");
907 void _demonstrateDottedPolylineMapObjects() {
908 print(
"--- Dotted Polyline Map Objects ---");
911 print(
"LocationWindow not available yet");
917 List<Point> points = [
923 Polyline polyline = Polyline(points);
924 LocationPolyline locationPolyline = LocationPolyline(polyline, 1, 0);
926 print(
"Created dotted polyline map object with ${points.length} points");
931 LocationPolyline dottedPolylineShape =
934 "Dotted polyline has ${dottedPolylineShape.polyline.points.length} points",
941 print(
"Added dotted polyline map object");
947 List<Point> dottedPoints = [
953 Polyline dottedPolyline = Polyline(dottedPoints);
954 LocationPolyline locationDottedPolyline = LocationPolyline(
960 locationDottedPolyline,
962 print(
"Set dotted polyline geometry: $success");
968 print(
"Set dotted polyline width to 2.0 pixels: $widthSuccess");
980 "Set dotted polyline color to purple with 80% opacity: $colorSuccess",
987 print(
"Set rendering order to 3: $orderSuccess");
996 "Enabled collision detection for dotted polyline: $collisionSuccess",
1005 print(
"Set dotted polyline placement to center: $placementSuccess");
1013 print(
"Set dotted polyline placement min ratio to 0.5: $minRatioSuccess");
1019 print(
"Set dotted polyline placement spacing to 10.0: $spacingSuccess");
1025 print(
"Set dotted polyline rendering priority to 1: $prioritySuccess");
1034 "Set dotted polyline repeat distance to 20.0: $repeatDistanceSuccess",
1041 print(
"Set dotted polyline repeat group to 1: $repeatGroupSuccess");
1047 print(
"Set dotted polyline size to 16x16: $sizeSuccess");
1053 print(
"Set dotted polyline visibility to true: $visibleSuccess");
1059 print(
"Dotted polyline map object type: $objectType");
1065 print(
"Set dotted polyline alpha to 0.7: $alphaSuccess");
1071 print(
"Set dotted polyline interactive to true: $interactiveSuccess");
1077 "Dotted Polyline Object",
1080 "Set dotted polyline title to 'Dotted Polyline Object': $titleSuccess",
1086 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
1088 print(
"Set dotted polyline custom data: $dataSuccess");
1094 print(
"Dotted polyline object ID: $objectId");
1100 print(
"Dotted polyline object type: $objectTypeString");
1106 print(
"Dotted polyline custom data: $retrievedData");
1116 print(
"Removed dotted polyline map object: $removed");
1122 List<DottedPolylineMapObject> dottedPolylines = [];
1123 for (
int i = 0; i < 2; i++) {
1124 DottedPolylineMapObject dottedPolyline =
1126 if (dottedPolyline !=
null) {
1127 List<Point> points = [
1128 Point(i * 40.0, i * 40.0 + 100.0),
1129 Point((i + 1) * 40.0, (i + 1) * 40.0 + 100.0),
1131 Polyline poly = Polyline(points);
1132 LocationPolyline locPoly = LocationPolyline(poly, 1, 0);
1134 dottedPolyline.setWidth(1.5);
1135 dottedPolyline.
setColor(1.0, 0.0, 1.0, 0.6);
1136 dottedPolylines.add(dottedPolyline);
1137 print(
"Created dotted polyline $i");
1141 for (
int i = 0; i < dottedPolylines.length; i++) {
1143 print(
"Removed dotted polyline $i");
1150 void _demonstrateRemoveAllMapObjects() {
1151 print(
"--- Remove All Map Objects ---");
1154 print(
"LocationWindow not available yet");
1163 DottedPolylineMapObject dottedPolyline =
1166 print(
"Created 5 map objects");
1171 print(
"Removed all map objects");
1199 print(
"LocationWindowMapObjects example cleanup completed");