47class LocationWindowMapObjectsExample {
58 LocationWindowMapObjectsExample() {
59 _demonstrateLocationWindowMapObjectsMethods();
65 void _demonstrateLocationWindowMapObjectsMethods() {
66 print(
"=== LocationWindowMapObjects Example ===");
68 _demonstrateLocationScopedGeometryRecords();
70 _demonstrateCircleMapObjects();
71 _demonstrateIconMapObjects();
72 _demonstrateClusterMapObjects();
73 _demonstrateModelMapObjects();
74 _demonstratePolygonMapObjects();
75 _demonstratePolylineMapObjects();
76 _demonstrateDottedPolylineMapObjects();
77 _demonstrateRemoveAllMapObjects();
84 void _demonstrateLocationScopedGeometryRecords() {
85 print(
"--- LocationPolygon / LocationPolyline records ---");
88 List<GlobalPoint> ring = [
89 GlobalPoint(55.751, 37.617),
90 GlobalPoint(55.752, 37.618),
91 GlobalPoint(55.751, 37.619),
93 LocationPolygon locationPolygon = LocationPolygon(ring, 7);
95 "LocationPolygon: sublocation ${locationPolygon.sublocationId}, vertices ${locationPolygon.points.length}",
100 List<GlobalPoint> linePts = [
101 GlobalPoint(55.751, 37.617),
102 GlobalPoint(55.753, 37.620),
104 LocationPolyline locationPolyline = LocationPolyline(linePts, 7);
105 print(
"LocationPolyline points ${locationPolyline.points.length}");
112 void _demonstrateCircleMapObjects() {
113 print(
"--- Circle Map Objects ---");
116 print(
"LocationWindow not available yet");
122 GlobalPoint center = GlobalPoint(10.0, 20.0);
125 "Created circle map object with center (${center.latitude}, ${center.longitude}) and radius 5.0",
132 print(
"Circle radius: $radius");
138 print(
"Added circle map object");
144 GlobalPoint centerPoint = GlobalPoint(100.0, 200.0);
147 "Set circle position to (${centerPoint.latitude}, ${centerPoint.longitude}): $success",
153 GlobalPoint animatedPoint = GlobalPoint(150.0, 250.0);
154 bool animatedSuccess =
_circleMapObject!.setPositionAnimated(animatedPoint, 7, 2.0, AnimationType.LINEAR, );
156 "Set circle position with animation to (${animatedPoint.latitude}, ${animatedPoint.longitude}): $animatedSuccess",
163 print(
"Set position offset to (2.0, 3.0) pixels: $offsetSuccess");
168 bool outlineColorSuccess =
_circleMapObject!.setOutlineColor(
const Color(0xFF0000FF));
169 print(
"Set circle outline color to blue: $outlineColorSuccess");
175 print(
"Set circle outline alpha to 0.5: $outlineAlphaSuccess");
181 print(
"Set circle outline radius to 2.0: $outlineRadiusSuccess");
187 print(
"Set circle color to red with 80% opacity: $colorSuccess");
193 print(
"Set circle radius to 10.0 meters: $radiusSuccess");
199 print(
"Enabled collision detection for circle: $collisionSuccess");
205 print(
"Set collision buffer to 5x5 pixels: $bufferSuccess");
211 print(
"Set rendering priority to 1: $prioritySuccess");
217 print(
"Set circle visibility to true: $visibleSuccess");
223 print(
"Circle map object type: $objectType");
229 print(
"Set circle alpha to 0.7: $alphaSuccess");
235 print(
"Set circle interactive to true: $interactiveSuccess");
241 print(
"Set circle title to 'Circle Object': $titleSuccess");
245 TitleStyle titleStyle = TitleStyle(
248 outlineColor:
"#FFFFFF",
249 anchor: TitleAnchor.TOP,
256 bool titleStyleSuccess =
258 print(
"Set circle title with style: $titleStyleSuccess");
263 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
265 print(
"Set circle custom data: $dataSuccess");
271 print(
"Circle object ID: $objectId");
277 print(
"Circle object type: $objectTypeString");
283 print(
"Circle custom data: $retrievedData");
291 print(
"Removed circle map object: $removed");
297 List<CircleMapObject> circles = [];
298 for (
int i = 0; i < 3; i++) {
300 if (circle !=
null) {
301 circle.
setPosition(GlobalPoint(50.0 * i, 100.0 * i));
302 circle.
setColor(
const Color(0x9900FF00));
306 "Created circle $i at (${50.0 * i}, ${100.0 * i}) with radius ${5.0 + i * 2.0}",
311 for (
int i = 0; i < circles.length; i++) {
313 print(
"Removed circle $i");
320 void _demonstrateIconMapObjects() {
321 print(
"--- Icon Map Objects ---");
324 print(
"LocationWindow not available yet");
330 GlobalPoint position = GlobalPoint(30.0, 40.0);
332 print(
"Created icon map object at (${position.latitude}, ${position.longitude})");
338 print(
"Added icon map object");
344 GlobalPoint iconPoint = GlobalPoint(200.0, 300.0);
346 print(
"Set icon position to (${iconPoint.latitude}, ${iconPoint.longitude}): $success");
351 GlobalPoint animatedIconPoint = GlobalPoint(250.0, 350.0);
352 bool animatedSuccess =
_iconMapObject!.setPositionAnimated(animatedIconPoint, 7, 1.5, AnimationType.CUBIC, );
354 "Set icon position with animation to (${animatedIconPoint.latitude}, ${animatedIconPoint.longitude}): $animatedSuccess",
361 print(
"Set icon size to 32x32 pixels: $sizeSuccess");
367 print(
"Set icon rotation angle to π/4: $angleSuccess");
378 "Set icon rotation with animation to π/2: $angleAnimatedSuccess",
384 bool collisionSuccess =
_iconMapObject!.setCollisionEnabled(
true);
385 print(
"Enabled collision detection for icon: $collisionSuccess");
391 print(
"Set collision buffer to 10x10 pixels: $bufferSuccess");
397 print(
"Set position offset to (0.0, -16.0) pixels: $offsetSuccess");
403 print(
"Set rendering priority to 2: $prioritySuccess");
409 print(
"Set icon visibility to true: $visibleSuccess");
415 print(
"Icon map object type: $objectType");
420 ImageProvider iconProvider = ImageProvider.fromImageProvider(
421 const AssetImage(
'assets/icon.png'),
425 print(
"Set icon from ImageProvider: $bitmapSuccess");
431 print(
"Set icon flat mode to true: $flatSuccess");
437 print(
"Set icon alpha to 0.7: $alphaSuccess");
443 print(
"Set icon interactive to true: $interactiveSuccess");
449 print(
"Set icon title to 'Icon Object': $titleSuccess");
454 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
456 print(
"Set icon custom data: $dataSuccess");
462 print(
"Icon object ID: $objectId");
468 print(
"Icon object type: $objectTypeString");
474 print(
"Icon custom data: $retrievedData");
482 print(
"Removed icon map object: $removed");
488 List<IconMapObject> icons = [];
489 ImageProvider loopIcon = ImageProvider.fromImageProvider(
490 const AssetImage(
'assets/icon.png'),
493 for (
int i = 0; i < 3; i++) {
496 icon.
setPosition(GlobalPoint(100.0 * i, 150.0 * i));
502 "Created icon $i at (${100.0 * i}, ${150.0 * i}) with angle ${i * math.pi / 6}",
507 for (
int i = 0; i < icons.length; i++) {
509 print(
"Removed icon $i");
516 void _demonstrateModelMapObjects() {
517 print(
"--- Model Map Objects ---");
520 print(
"LocationWindow not available yet");
526 print(
"Added model map object: ${_modelMapObject != null}");
535 bool posOk = m.
setPosition(GlobalPoint(12.0, 34.0));
536 print(
"Model setPosition: $posOk");
542 print(
"Model setPositionAnimated: $posAnimOk");
546 ImageProvider texture = ImageProvider.fromImageProvider(
547 const AssetImage(
'assets/model_texture.png'),
550 ModelProvider modelProvider = ModelProvider(
552 onModelRequest: () async {
553 final bytes = await File(
'/path/to/model.obj').readAsBytes();
554 return ByteData.sublistView(bytes);
557 bool modelOk = m.
setModel(modelProvider);
558 print(
"Model setModel: $modelOk");
562 bool sizeOk = m.
setSize(64.0, 64.0);
563 print(
"Model setSize: $sizeOk");
568 print(
"Model setCollisionEnabled: $collOk");
572 bool angleOk = m.
setAngle(math.pi / 4);
573 print(
"Model setAngle: $angleOk");
577 bool angleAnimOk = m.
setAngleAnimated(math.pi / 2, 0.5, AnimationType.QUINT);
578 print(
"Model setAngleAnimated: $angleAnimOk");
583 print(
"Model setBuffer: $bufOk");
588 print(
"Model setPriority: $priOk");
593 print(
"Removed model map object: $removed");
601 void _demonstratePolygonMapObjects() {
602 print(
"--- Polygon Map Objects ---");
605 print(
"LocationWindow not available yet");
612 print(
"Added polygon map object");
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),
624 LocationPolygon polygon = LocationPolygon(points, 0);
626 print(
"Set polygon with ${points.length} points: $success");
632 print(
"Set polygon color to green with 70% opacity: $colorSuccess");
637 bool outlineColorSuccess =
_polygonMapObject!.setOutlineColor(
const Color(0xFF0000FF));
638 print(
"Set polygon outline color to blue: $outlineColorSuccess");
644 print(
"Set polygon outline width to 2.0 pixels: $outlineWidthSuccess");
650 print(
"Set polygon outline alpha to 0.8: $outlineAlphaSuccess");
656 print(
"Set polygon outline order to 1: $outlineOrderSuccess");
662 print(
"Set polygon rendering order to 2: $orderSuccess");
668 print(
"Set polygon visibility to true: $visibleSuccess");
674 print(
"Polygon map object type: $objectType");
680 print(
"Set polygon alpha to 0.7: $alphaSuccess");
686 print(
"Set polygon interactive to true: $interactiveSuccess");
692 print(
"Set polygon title to 'Polygon Object': $titleSuccess");
697 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
699 print(
"Set polygon custom data: $dataSuccess");
705 print(
"Polygon object ID: $objectId");
711 print(
"Polygon object type: $objectTypeString");
717 print(
"Polygon custom data: $retrievedData");
727 print(
"Removed polygon map object: $removed");
733 List<PolygonMapObject> polygons = [];
734 for (
int i = 0; i < 3; i++) {
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),
743 LocationPolygon polygonGeometry = LocationPolygon(points, 0);
745 polygon.
setColor(
const Color(0x800000FF));
746 polygons.add(polygon);
747 print(
"Created polygon $i with ${points.length} points");
751 for (
int i = 0; i < polygons.length; i++) {
753 print(
"Removed polygon $i");
760 void _demonstratePolylineMapObjects() {
761 print(
"--- Polyline Map Objects ---");
764 print(
"LocationWindow not available yet");
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),
776 LocationPolyline locationPolyline = LocationPolyline(points, 0);
778 print(
"Created polyline map object with ${points.length} points");
784 print(
"Polyline has ${polylineShape.polyline.points.length} points");
790 print(
"Added polyline map object");
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),
802 LocationPolyline locationPolyline = LocationPolyline(polylinePoints, 0);
804 print(
"Set polyline geometry: $success");
810 print(
"Set polyline width to 3.0 pixels: $widthSuccess");
816 print(
"Set polyline color to orange with 90% opacity: $colorSuccess");
822 print(
"Set rendering order to 2: $orderSuccess");
828 print(
"Set cap type to ROUND: $capSuccess");
834 print(
"Set join type to ROUND: $joinSuccess");
840 print(
"Set miter limit to 5.0: $miterSuccess");
846 print(
"Set polyline outline width to 1.0: $outlineWidthSuccess");
851 bool outlineColorSuccess =
_polylineMapObject!.setOutlineColor(
const Color(0xFF000000));
852 print(
"Set polyline outline color to black: $outlineColorSuccess");
858 print(
"Set polyline outline alpha to 0.8: $outlineAlphaSuccess");
864 print(
"Set polyline outline order to 1: $outlineOrderSuccess");
872 print(
"Set polyline outline cap type to ROUND: $outlineCapSuccess");
880 print(
"Set polyline outline join type to ROUND: $outlineJoinSuccess");
886 print(
"Set polyline outline miter limit to 3.0: $outlineMiterSuccess");
892 print(
"Set polyline visibility to true: $visibleSuccess");
898 print(
"Polyline map object type: $objectType");
904 print(
"Set polyline alpha to 0.7: $alphaSuccess");
910 print(
"Set polyline interactive to true: $interactiveSuccess");
916 print(
"Set polyline title to 'Polyline Object': $titleSuccess");
921 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
923 print(
"Set polyline custom data: $dataSuccess");
929 print(
"Polyline object ID: $objectId");
935 print(
"Polyline object type: $objectTypeString");
941 print(
"Polyline custom data: $retrievedData");
951 print(
"Removed polyline map object: $removed");
957 List<PolylineMapObject> polylines = [];
958 for (
int i = 0; i < 3; i++) {
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),
965 LocationPolyline locPoly = LocationPolyline(points, 0);
968 polyline.
setColor(
const Color(0xCC00FFFF));
969 polylines.add(polyline);
970 print(
"Created polyline $i with width ${2.0 + i}");
974 for (
int i = 0; i < polylines.length; i++) {
976 print(
"Removed polyline $i");
983 void _demonstrateDottedPolylineMapObjects() {
984 print(
"--- Dotted Polyline Map Objects ---");
987 print(
"LocationWindow not available yet");
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),
999 LocationPolyline locationPolyline = LocationPolyline(points, 0);
1001 print(
"Created dotted polyline map object with ${points.length} points");
1006 LocationPolyline dottedPolylineShape =
1009 "Dotted polyline has ${dottedPolylineShape.polyline.points.length} points",
1016 print(
"Added dotted polyline map object");
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),
1028 LocationPolyline locationDottedPolyline = LocationPolyline(dottedPoints, 0);
1030 locationDottedPolyline,
1032 print(
"Set dotted polyline geometry: $success");
1038 print(
"Set dotted polyline width to 2.0 pixels: $widthSuccess");
1045 "Set dotted polyline color to purple with 80% opacity: $colorSuccess",
1052 print(
"Set rendering order to 3: $orderSuccess");
1061 "Enabled collision detection for dotted polyline: $collisionSuccess",
1070 print(
"Set dotted polyline placement to center: $placementSuccess");
1078 print(
"Set dotted polyline placement min ratio to 0.5: $minRatioSuccess");
1084 print(
"Set dotted polyline placement spacing to 10.0: $spacingSuccess");
1090 print(
"Set dotted polyline rendering priority to 1: $prioritySuccess");
1099 "Set dotted polyline repeat distance to 20.0: $repeatDistanceSuccess",
1106 print(
"Set dotted polyline repeat group to 1: $repeatGroupSuccess");
1112 print(
"Set dotted polyline size to 16x16: $sizeSuccess");
1118 print(
"Set dotted polyline visibility to true: $visibleSuccess");
1124 print(
"Dotted polyline map object type: $objectType");
1130 print(
"Set dotted polyline alpha to 0.7: $alphaSuccess");
1136 print(
"Set dotted polyline interactive to true: $interactiveSuccess");
1142 "Dotted Polyline Object",
1145 "Set dotted polyline title to 'Dotted Polyline Object': $titleSuccess",
1151 Map<String, dynamic> customData = {
"key":
"value",
"number": 42};
1153 print(
"Set dotted polyline custom data: $dataSuccess");
1159 print(
"Dotted polyline object ID: $objectId");
1165 print(
"Dotted polyline object type: $objectTypeString");
1171 print(
"Dotted polyline custom data: $retrievedData");
1181 print(
"Removed dotted polyline map object: $removed");
1187 List<DottedPolylineMapObject> dottedPolylines = [];
1188 for (
int i = 0; i < 2; i++) {
1189 DottedPolylineMapObject dottedPolyline =
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),
1196 LocationPolyline locPoly = LocationPolyline(points, 0);
1198 dottedPolyline.setWidth(1.5);
1199 dottedPolyline.
setColor(
const Color(0x99FF00FF));
1200 dottedPolylines.add(dottedPolyline);
1201 print(
"Created dotted polyline $i");
1205 for (
int i = 0; i < dottedPolylines.length; i++) {
1207 print(
"Removed dotted polyline $i");
1214 void _demonstrateClusterMapObjects() {
1215 print(
"--- Cluster map objects ---");
1218 print(
"LocationWindow not available");
1224 print(
"Added cluster map object controller");
1228 if (controller ==
null) {
1234 clusterIcon1?.setPosition(GlobalPoint(100.0, 100.0));
1235 clusterIcon2?.setPosition(GlobalPoint(105.0, 102.0));
1238 final added1 = controller.addIconMapObject(clusterIcon1);
1239 final added2 = controller.addIconMapObject(clusterIcon2);
1240 print(
"Registered icons for clustering: $added1, $added2");
1244 controller.setEnabled(
true);
1245 print(
"Clustering enabled");
1249 final clusteringEnabled = controller.isEnabled;
1250 print(
"Clustering is enabled: $clusteringEnabled");
1254 controller.setRadius(40.0);
1255 print(
"Set cluster radius to 40 px");
1259 final clusterRadius = controller.getRadius();
1260 print(
"Cluster radius: $clusterRadius");
1264 final interactiveSuccess = controller.setInteractive(
true);
1265 print(
"Set cluster markers interactive: $interactiveSuccess");
1269 final sizeSuccess = controller.setClusterSize(32.0, 32.0);
1270 print(
"Set default cluster icon size: $sizeSuccess");
1277 print(
"Added cluster map object listener");
1281 final clusters = controller.getClusters();
1282 print(
"Visible clusters: ${clusters.length}");
1285 if (clusters.isNotEmpty) {
1286 final cluster = clusters.first;
1288 final clusterBitmap = ImageProvider.fromFile(
"/path/to/cluster.png");
1289 final bitmapSuccess = cluster.setBitmap(clusterBitmap);
1290 print(
"Set cluster bitmap from ImageProvider: $bitmapSuccess");
1296 print(
"Removed cluster map object listener");
1299 if (clusterIcon1 !=
null) {
1301 final removed = controller.removeIconMapObject(clusterIcon1);
1302 print(
"Removed icon from cluster controller: $removed");
1306 if (clusterIcon2 !=
null) {
1312 print(
"Cleared cluster controller");
1316 final controllerRemoved =
1318 print(
"Removed cluster map object controller: $controllerRemoved");
1325 void _demonstrateRemoveAllMapObjects() {
1326 print(
"--- Remove All Map Objects ---");
1329 print(
"LocationWindow not available yet");
1338 DottedPolylineMapObject dottedPolyline =
1341 print(
"Created 5 map objects");
1346 print(
"Removed all map objects");
1378 print(
"LocationWindowMapObjects example cleanup completed");