56 demonstrateLocationWindowMapObjectsMethods();
62 private void demonstrateLocationWindowMapObjectsMethods() {
63 System.out.println(
"=== LocationWindowMapObjects Example ===");
65 demonstrateLocationScopedGeometryRecords();
67 demonstrateCircleMapObjects();
68 demonstrateIconMapObjects();
69 demonstrateClusterMapObjects();
70 demonstrateModelMapObjects();
71 demonstratePolygonMapObjects();
72 demonstratePolylineMapObjects();
73 demonstrateDottedPolylineMapObjects();
74 demonstrateRemoveAllMapObjects();
81 private void demonstrateLocationScopedGeometryRecords() {
82 System.out.println(
"--- LocationPolygon / LocationPolyline records ---");
85 List<GlobalPoint> ring = Arrays.asList(
90 List<List<GlobalPoint>> holes = Arrays.asList(Arrays.asList(
96 int polygonSublocationId = locationPolygon.getSublocationId();
97 System.out.println(
"LocationPolygon: sublocation "
98 + polygonSublocationId +
", vertices " + locationPolygon.getPoints().size()
99 +
", holes " + locationPolygon.getInnerRings().size());
104 java.util.List<
PointSprite> sprites = java.util.Arrays.asList(
108 Integer hit = batch.
hitTest(
new android.graphics.PointF(12.f, 8.f), 8.f);
109 System.out.println(
"PointBatch hit " + hit);
113 String geoJson =
"{\"type\":\"FeatureCollection\",\"features\":["
114 +
"{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":["
115 +
"[[37.617,55.751],[37.619,55.751],[37.619,55.752],[37.617,55.751]],"
116 +
"[[37.6174,55.7512],[37.6176,55.7512],[37.6176,55.7514],[37.6174,55.7512]]]}},"
117 +
"{\"type\":\"Feature\",\"geometry\":{\"type\":\"LineString\",\"coordinates\":"
118 +
"[[37.617,55.751],[37.620,55.753]]}}]}";
120 System.out.println(
"GeoJSON polygons " + imported.getPolygons().size()
121 +
", lines " + imported.getPolylines().size());
125 List<GlobalPoint> linePoints = Arrays.asList(
130 System.out.println(
"LocationPolyline: points " + locationPolyline.getPoints().size());
137 private void demonstrateCircleMapObjects() {
138 System.out.println(
"--- Circle Map Objects ---");
140 if (locationWindow ==
null) {
141 System.out.println(
"LocationWindow not available yet");
149 System.out.println(
"Created circle map object with center (" + center.getLatitude() +
", " + center.getLongitude() +
") and radius 5.0");
154 double radius = circleMapObject.getRadius();
155 System.out.println(
"Circle radius: " + radius);
161 System.out.println(
"Added circle map object");
164 if (circleMapObject !=
null) {
168 boolean success = circleMapObject.
setPosition(centerPoint, 7);
169 System.out.println(
"Set circle position to (" + centerPoint.getLatitude() +
", " + centerPoint.getLongitude() +
"): " + success);
176 System.out.println(
"Set circle position with animation to (" + animatedPoint.getLatitude() +
", " + animatedPoint.getLongitude() +
"): " + animatedSuccess);
181 boolean radiusSuccess = circleMapObject.
setRadius(10.0);
182 System.out.println(
"Set circle radius to 10.0 meters: " + radiusSuccess);
188 System.out.println(
"Enabled collision detection for circle: " + collisionSuccess);
193 boolean bufferSuccess = circleMapObject.
setBuffer(5.0, 5.0);
194 System.out.println(
"Set collision buffer to 5x5 pixels: " + bufferSuccess);
199 boolean offsetSuccess = circleMapObject.
setOffset(2.0, 3.0);
200 System.out.println(
"Set position offset to (2.0, 3.0) pixels: " + offsetSuccess);
205 boolean outlineColorSuccess = circleMapObject.
setOutlineColor(0xFF0000FF);
206 System.out.println(
"Set circle outline color to blue: " + outlineColorSuccess);
212 System.out.println(
"Set circle outline alpha to 0.5: " + outlineAlphaSuccess);
218 System.out.println(
"Set circle outline radius to 2.0: " + outlineRadiusSuccess);
223 boolean colorSuccess = circleMapObject.
setColor(0xCCFF0000);
224 System.out.println(
"Set circle color to red with 80% opacity: " + colorSuccess);
229 boolean prioritySuccess = circleMapObject.
setPriority(1);
230 System.out.println(
"Set rendering priority to 1: " + prioritySuccess);
235 boolean visibleSuccess = circleMapObject.
setVisible(
true);
236 System.out.println(
"Set circle visibility to true: " + visibleSuccess);
241 MapObjectType objectType = circleMapObject.getMapObjectType();
242 System.out.println(
"Circle map object type: " + objectType);
247 boolean alphaSuccess = circleMapObject.
setAlpha(0.7);
248 System.out.println(
"Set circle alpha to 0.7: " + alphaSuccess);
253 boolean interactiveSuccess = circleMapObject.
setInteractive(
true);
254 System.out.println(
"Set circle interactive to true: " + interactiveSuccess);
259 boolean titleSuccess = circleMapObject.
setTitle(
"Circle Object");
260 System.out.println(
"Set circle title to 'Circle Object': " + titleSuccess);
265 titleStyle.fontSize = 14f;
266 titleStyle.color = 0xFF3366CC;
267 titleStyle.outlineColor = 0xFFFFFFFF;
269 titleStyle.visible =
true;
274 boolean titleStyleSuccess = circleMapObject.
setTitleWithStyle(
"Styled Circle", titleStyle);
275 System.out.println(
"Set circle title with style: " + titleStyleSuccess);
280 Map<String, String> customData =
new HashMap<>();
281 customData.put(
"key",
"value");
282 customData.put(
"number",
"42");
283 boolean dataSuccess = circleMapObject.
setData(customData);
284 System.out.println(
"Set circle custom data: " + dataSuccess);
289 int objectId = circleMapObject.
getId();
290 System.out.println(
"Circle object ID: " + objectId);
295 String objectTypeString = circleMapObject.
getType();
296 System.out.println(
"Circle object type: " + objectTypeString);
301 Map<String, String> retrievedData = circleMapObject.
getData();
302 System.out.println(
"Circle custom data: " + retrievedData);
308 if (circleMapObject !=
null) {
309 boolean removed = locationWindow.removeCircleMapObject(circleMapObject);
310 System.out.println(
"Removed circle map object: " + removed);
311 circleMapObject =
null;
316 List<CircleMapObject> circles =
new ArrayList<>();
317 for (
int i = 0; i < 3; i++) {
318 CircleMapObject circle = locationWindow.addCircleMapObject();
319 if (circle !=
null) {
320 circle.
setPosition(
new GlobalPoint(50.0 * i, 100.0 * i));
324 System.out.println(
"Created circle " + i +
" at (" + (50.0 * i) +
", " + (100.0 * i) +
") with radius " + (5.0 + i * 2.0));
328 for (
int i = 0; i < circles.size(); i++) {
329 locationWindow.removeCircleMapObject(circles.get(i));
330 System.out.println(
"Removed circle " + i);
337 private void demonstrateIconMapObjects() {
338 System.out.println(
"--- Icon Map Objects ---");
340 if (locationWindow ==
null) {
341 System.out.println(
"LocationWindow not available yet");
347 GlobalPoint position =
new GlobalPoint(30.0, 40.0);
348 iconMapObject = locationWindow.addIconMapObject();
349 System.out.println(
"Created icon map object at (" + position.getLatitude() +
", " + position.getLongitude() +
")");
354 iconMapObject = locationWindow.addIconMapObject();
355 System.out.println(
"Added icon map object");
358 if (iconMapObject !=
null) {
361 GlobalPoint iconPoint =
new GlobalPoint(200.0, 300.0);
362 boolean success = iconMapObject.setPosition(iconPoint, 7);
363 System.out.println(
"Set icon position to (" + iconPoint.getLatitude() +
", " + iconPoint.getLongitude() +
"): " + success);
368 GlobalPoint animatedIconPoint =
new GlobalPoint(250.0, 350.0);
369 boolean animatedSuccess = iconMapObject.setPositionAnimated(animatedIconPoint, 7, 1.5, AnimationType.CUBIC);
370 System.out.println(
"Set icon position with animation to (" + animatedIconPoint.getLatitude() +
", " + animatedIconPoint.getLongitude() +
"): " + animatedSuccess);
375 boolean sizeSuccess = iconMapObject.setSize(32.0, 32.0);
376 System.out.println(
"Set icon size to 32x32 pixels: " + sizeSuccess);
381 boolean angleSuccess = iconMapObject.setAngle((
float) Math.toRadians(45.0));
382 System.out.println(
"Set icon rotation angle to π/4: " + angleSuccess);
387 boolean angleAnimatedSuccess = iconMapObject.setAngleAnimated((
float) Math.toRadians(90.0), 2.0, AnimationType.SINE);
388 System.out.println(
"Set icon rotation with animation to π/2: " + angleAnimatedSuccess);
393 boolean collisionSuccess = iconMapObject.setCollisionEnabled(
true);
394 System.out.println(
"Enabled collision detection for icon: " + collisionSuccess);
399 boolean bufferSuccess = iconMapObject.setBuffer(10.0, 10.0);
400 System.out.println(
"Set collision buffer to 10x10 pixels: " + bufferSuccess);
405 boolean offsetSuccess = iconMapObject.setOffset(0.0, -16.0);
406 System.out.println(
"Set position offset to (0.0, -16.0) pixels: " + offsetSuccess);
411 boolean prioritySuccess = iconMapObject.setPriority(2);
412 System.out.println(
"Set rendering priority to 2: " + prioritySuccess);
417 boolean visibleSuccess = iconMapObject.setVisible(
true);
418 System.out.println(
"Set icon visibility to true: " + visibleSuccess);
423 MapObjectType objectType = iconMapObject.getMapObjectType();
424 System.out.println(
"Icon map object type: " + objectType);
429 ImageProvider iconBitmap = ImageProvider.fromFile(
"/path/to/icon.png",
true);
430 boolean bitmapSuccess = iconMapObject.setBitmap(iconBitmap);
431 System.out.println(
"Set icon from ImageProvider: " + bitmapSuccess);
436 boolean flatSuccess = iconMapObject.setFlat(
true);
437 System.out.println(
"Set icon flat mode to true: " + flatSuccess);
442 boolean alphaSuccess = iconMapObject.setAlpha(0.8f);
443 System.out.println(
"Set icon alpha to 0.8: " + alphaSuccess);
448 boolean interactiveSuccess = iconMapObject.setInteractive(
true);
449 System.out.println(
"Set icon interactive to true: " + interactiveSuccess);
454 boolean titleSuccess = iconMapObject.setTitle(
"Icon Object");
455 System.out.println(
"Set icon title to 'Icon Object': " + titleSuccess);
460 Map<String, Object> customData =
new HashMap<>();
461 customData.put(
"key",
"value");
462 customData.put(
"number", 42);
463 boolean dataSuccess = iconMapObject.setData(customData);
464 System.out.println(
"Set icon custom data: " + dataSuccess);
469 int objectId = iconMapObject.getId();
470 System.out.println(
"Icon object ID: " + objectId);
475 String objectTypeString = iconMapObject.getType();
476 System.out.println(
"Icon object type: " + objectTypeString);
481 Map<String, Object> retrievedData = iconMapObject.getData();
482 System.out.println(
"Icon custom data: " + retrievedData);
488 if (iconMapObject !=
null) {
489 boolean removed = locationWindow.removeIconMapObject(iconMapObject);
490 System.out.println(
"Removed icon map object: " + removed);
491 iconMapObject =
null;
496 List<IconMapObject> icons =
new ArrayList<>();
497 for (
int i = 0; i < 3; i++) {
498 IconMapObject icon = locationWindow.addIconMapObject();
500 icon.
setPosition(
new GlobalPoint(100.0 * i, 150.0 * i));
502 icon.
setAngle((
float) (i * Math.toRadians(30.0)));
504 System.out.println(
"Created icon " + i +
" at (" + (100.0 * i) +
", " + (150.0 * i) +
") with angle " + (i * Math.toRadians(30.0)) +
" rad");
508 for (
int i = 0; i < icons.size(); i++) {
509 locationWindow.removeIconMapObject(icons.get(i));
510 System.out.println(
"Removed icon " + i);
517 private void demonstrateModelMapObjects() {
518 System.out.println(
"--- Model Map Objects ---");
520 if (locationWindow ==
null) {
521 System.out.println(
"LocationWindow not available yet");
526 modelMapObject = locationWindow.addModelMapObject();
527 System.out.println(
"Added model map object: " + (modelMapObject !=
null));
530 if (modelMapObject ==
null) {
535 GlobalPoint modelPoint =
new GlobalPoint(12.0, 34.0);
536 boolean posOk = modelMapObject.setPosition(modelPoint, 7);
537 System.out.println(
"Model setPosition: " + posOk);
541 boolean posAnimOk = modelMapObject.setPositionAnimated(
new GlobalPoint(15.0, 40.0), 7, 0.5f, AnimationType.SINE);
542 System.out.println(
"Model setPositionAnimated: " + posAnimOk);
546 ImageProvider texture = ImageProvider.fromFile(
"/path/to/model_texture.png",
true);
547 ModelProvider model = ModelProvider.fromFile(
"/path/to/model.obj", texture);
548 boolean modelOk = modelMapObject.setModel(model);
549 System.out.println(
"Model setModel: " + modelOk);
553 boolean sizeOk = modelMapObject.setSize(64.0f, 64.0f);
554 System.out.println(
"Model setSize: " + sizeOk);
558 boolean collOk = modelMapObject.setCollisionEnabled(
true);
559 System.out.println(
"Model setCollisionEnabled: " + collOk);
563 boolean angleOk = modelMapObject.setAngle((
float) Math.toRadians(45.0));
564 System.out.println(
"Model setAngle: " + angleOk);
568 boolean angleAnimOk = modelMapObject.setAngleAnimated((
float) Math.toRadians(90.0), 0.5f, AnimationType.QUINT);
569 System.out.println(
"Model setAngleAnimated: " + angleAnimOk);
573 boolean bufOk = modelMapObject.setBuffer(4.0f, 4.0f);
574 System.out.println(
"Model setBuffer: " + bufOk);
578 boolean priOk = modelMapObject.setPriority(10.0f);
579 System.out.println(
"Model setPriority: " + priOk);
583 boolean removed = locationWindow.removeModelMapObject(modelMapObject);
584 System.out.println(
"Removed model map object: " + removed);
585 modelMapObject =
null;
592 private void demonstratePolygonMapObjects() {
593 System.out.println(
"--- Polygon Map Objects ---");
595 if (locationWindow ==
null) {
596 System.out.println(
"LocationWindow not available yet");
602 polygonMapObject = locationWindow.addPolygonMapObject();
603 System.out.println(
"Added polygon map object");
606 if (polygonMapObject !=
null) {
609 List<GlobalPoint> points = Arrays.asList(
610 new GlobalPoint(100.0, 200.0),
611 new GlobalPoint(150.0, 250.0),
612 new GlobalPoint(200.0, 200.0),
613 new GlobalPoint(150.0, 150.0)
615 LocationPolygon polygon =
new LocationPolygon(points, 0, java.util.Collections.emptyList());
616 boolean success = polygonMapObject.setPolygon(polygon);
617 System.out.println(
"Set polygon with " + points.size() +
" points: " + success);
622 boolean colorSuccess = polygonMapObject.setColor(0xB300FF00);
623 System.out.println(
"Set polygon color to green with 70% opacity: " + colorSuccess);
628 boolean visibleSuccess = polygonMapObject.setVisible(
true);
629 System.out.println(
"Set polygon visibility to true: " + visibleSuccess);
634 MapObjectType objectType = polygonMapObject.getMapObjectType();
635 System.out.println(
"Polygon map object type: " + objectType);
640 boolean orderSuccess = polygonMapObject.setOrder(2);
641 System.out.println(
"Set polygon rendering order to 2: " + orderSuccess);
646 boolean outlineColorSuccess = polygonMapObject.setOutlineColor(0xFF0000FF);
647 System.out.println(
"Set polygon outline color to blue: " + outlineColorSuccess);
652 boolean outlineWidthSuccess = polygonMapObject.setOutlineWidth(2.0);
653 System.out.println(
"Set polygon outline width to 2.0 pixels: " + outlineWidthSuccess);
658 boolean outlineAlphaSuccess = polygonMapObject.setOutlineAlpha(0.8);
659 System.out.println(
"Set polygon outline alpha to 0.8: " + outlineAlphaSuccess);
664 boolean outlineOrderSuccess = polygonMapObject.setOutlineOrder(1);
665 System.out.println(
"Set polygon outline order to 1: " + outlineOrderSuccess);
670 boolean alphaSuccess = polygonMapObject.setAlpha(0.7);
671 System.out.println(
"Set polygon alpha to 0.7: " + alphaSuccess);
676 boolean interactiveSuccess = polygonMapObject.setInteractive(
true);
677 System.out.println(
"Set polygon interactive to true: " + interactiveSuccess);
682 boolean titleSuccess = polygonMapObject.setTitle(
"Polygon Object");
683 System.out.println(
"Set polygon title to 'Polygon Object': " + titleSuccess);
688 Map<String, Object> customData =
new HashMap<>();
689 customData.put(
"key",
"value");
690 customData.put(
"number", 42);
691 boolean dataSuccess = polygonMapObject.setData(customData);
692 System.out.println(
"Set polygon custom data: " + dataSuccess);
697 int objectId = polygonMapObject.getId();
698 System.out.println(
"Polygon object ID: " + objectId);
703 String objectTypeString = polygonMapObject.getType();
704 System.out.println(
"Polygon object type: " + objectTypeString);
709 Map<String, Object> retrievedData = polygonMapObject.getData();
710 System.out.println(
"Polygon custom data: " + retrievedData);
716 if (polygonMapObject !=
null) {
717 boolean removed = locationWindow.removePolygonMapObject(polygonMapObject);
718 System.out.println(
"Removed polygon map object: " + removed);
719 polygonMapObject =
null;
724 List<PolygonMapObject> polygons =
new ArrayList<>();
725 for (
int i = 0; i < 3; i++) {
726 PolygonMapObject polygon = locationWindow.addPolygonMapObject();
727 if (polygon !=
null) {
728 List<GlobalPoint> points = Arrays.asList(
729 new GlobalPoint(300.0 + i * 50, 400.0 + i * 50),
730 new GlobalPoint(350.0 + i * 50, 450.0 + i * 50),
731 new GlobalPoint(400.0 + i * 50, 400.0 + i * 50),
732 new GlobalPoint(350.0 + i * 50, 350.0 + i * 50)
734 LocationPolygon polygonGeometry =
new LocationPolygon(points, 0, java.util.Collections.emptyList());
737 polygons.add(polygon);
738 System.out.println(
"Created polygon " + i +
" with " + points.size() +
" points");
742 for (
int i = 0; i < polygons.size(); i++) {
743 locationWindow.removePolygonMapObject(polygons.get(i));
744 System.out.println(
"Removed polygon " + i);
751 private void demonstratePolylineMapObjects() {
752 System.out.println(
"--- Polyline Map Objects ---");
754 if (locationWindow ==
null) {
755 System.out.println(
"LocationWindow not available yet");
761 List<GlobalPoint> points =
new ArrayList<>();
762 points.add(
new GlobalPoint(100.0, 110.0));
763 points.add(
new GlobalPoint(105.0, 115.0));
764 points.add(
new GlobalPoint(110.0, 120.0));
765 points.add(
new GlobalPoint(115.0, 125.0));
766 LocationPolyline locationPolyline =
new LocationPolyline(points, 0);
767 polylineMapObject = locationWindow.addPolylineMapObject();
768 System.out.println(
"Created polyline map object with " + points.size() +
" points");
773 LocationPolyline polylineShape = polylineMapObject.getPolyLine();
774 System.out.println(
"Polyline has " + polylineShape.getPoints().size() +
" points");
779 polylineMapObject = locationWindow.addPolylineMapObject();
780 System.out.println(
"Added polyline map object");
783 if (polylineMapObject !=
null) {
786 List<GlobalPoint> polylinePoints =
new ArrayList<>();
787 polylinePoints.add(
new GlobalPoint(0.0, 0.0));
788 polylinePoints.add(
new GlobalPoint(50.0, 50.0));
789 polylinePoints.add(
new GlobalPoint(100.0, 0.0));
790 polylinePoints.add(
new GlobalPoint(150.0, 50.0));
791 LocationPolyline locationPolyline =
new LocationPolyline(polylinePoints, 0);
792 boolean success = polylineMapObject.setPolyLine(locationPolyline);
793 System.out.println(
"Set polyline geometry: " + success);
797 polylineMapObject.setDrawnFraction(0f);
801 boolean grew = polylineMapObject.setDrawnFractionAnimated(1f, 1.0f, AnimationType.LINEAR);
802 System.out.println(
"Polyline grow started: " + grew);
806 System.out.println(
"Drawn fraction: " + polylineMapObject.drawnFraction());
811 boolean widthSuccess = polylineMapObject.setWidth(3.0);
812 System.out.println(
"Set polyline width to 3.0 pixels: " + widthSuccess);
817 boolean colorSuccess = polylineMapObject.setColor(0xE6FF8000);
818 System.out.println(
"Set polyline color to orange with 90% opacity: " + colorSuccess);
823 boolean dashSuccess = polylineMapObject.setDashLength(3.0);
824 System.out.println(
"Set polyline dash length: " + dashSuccess);
829 double dashLength = polylineMapObject.dashLength();
830 System.out.println(
"Polyline dash length: " + dashLength);
835 boolean gapSuccess = polylineMapObject.setGapLength(1.0);
836 System.out.println(
"Set polyline gap length: " + gapSuccess);
841 double gapLength = polylineMapObject.gapLength();
842 System.out.println(
"Polyline gap length: " + gapLength);
847 boolean orderSuccess = polylineMapObject.setOrder(2);
848 System.out.println(
"Set rendering order to 2: " + orderSuccess);
853 boolean capSuccess = polylineMapObject.setCapType(CapType.ROUND);
854 System.out.println(
"Set cap type to ROUND: " + capSuccess);
859 boolean joinSuccess = polylineMapObject.setJoinType(JoinType.ROUND);
860 System.out.println(
"Set join type to ROUND: " + joinSuccess);
865 boolean miterSuccess = polylineMapObject.setMiterLimit(5.0);
866 System.out.println(
"Set miter limit to 5.0: " + miterSuccess);
871 boolean visibleSuccess = polylineMapObject.setVisible(
true);
872 System.out.println(
"Set polyline visibility to true: " + visibleSuccess);
877 MapObjectType objectType = polylineMapObject.getMapObjectType();
878 System.out.println(
"Polyline map object type: " + objectType);
883 boolean alphaSuccess = polylineMapObject.setAlpha(0.7);
884 System.out.println(
"Set polyline alpha to 0.7: " + alphaSuccess);
889 boolean interactiveSuccess = polylineMapObject.setInteractive(
true);
890 System.out.println(
"Set polyline interactive to true: " + interactiveSuccess);
895 boolean titleSuccess = polylineMapObject.setTitle(
"Polyline Object");
896 System.out.println(
"Set polyline title to 'Polyline Object': " + titleSuccess);
901 Map<String, Object> customData =
new HashMap<>();
902 customData.put(
"key",
"value");
903 customData.put(
"number", 42);
904 boolean dataSuccess = polylineMapObject.setData(customData);
905 System.out.println(
"Set polyline custom data: " + dataSuccess);
910 int objectId = polylineMapObject.getId();
911 System.out.println(
"Polyline object ID: " + objectId);
916 String objectTypeString = polylineMapObject.getType();
917 System.out.println(
"Polyline object type: " + objectTypeString);
922 Map<String, Object> retrievedData = polylineMapObject.getData();
923 System.out.println(
"Polyline custom data: " + retrievedData);
928 boolean outlineWidthSuccess2 = polylineMapObject.setOutlineWidth(1.0);
929 System.out.println(
"Set polyline outline width to 1.0 pixels: " + outlineWidthSuccess2);
934 boolean outlineColorSuccess2 = polylineMapObject.setOutlineColor(0xFF000000);
935 System.out.println(
"Set polyline outline color to black: " + outlineColorSuccess2);
940 boolean outlineAlphaSuccess2 = polylineMapObject.setOutlineAlpha(0.5);
941 System.out.println(
"Set polyline outline alpha to 0.5: " + outlineAlphaSuccess2);
946 boolean outlineOrderSuccess2 = polylineMapObject.setOutlineOrder(0);
947 System.out.println(
"Set polyline outline rendering order to 0: " + outlineOrderSuccess2);
952 boolean outlineCapTypeSuccess2 = polylineMapObject.setOutlineCapType(CapType.SQUARE);
953 System.out.println(
"Set polyline outline cap type to SQUARE: " + outlineCapTypeSuccess2);
958 boolean outlineJoinTypeSuccess2 = polylineMapObject.setOutlineJoinType(JoinType.MITER);
959 System.out.println(
"Set polyline outline join type to MITER: " + outlineJoinTypeSuccess2);
964 boolean outlineMiterLimitSuccess2 = polylineMapObject.setOutlineMiterLimit(3.0);
965 System.out.println(
"Set polyline outline miter limit to 3.0: " + outlineMiterLimitSuccess2);
971 if (polylineMapObject !=
null) {
972 boolean removed = locationWindow.removePolylineMapObject(polylineMapObject);
973 System.out.println(
"Removed polyline map object: " + removed);
974 polylineMapObject =
null;
979 List<PolylineMapObject> polylines =
new ArrayList<>();
980 for (
int i = 0; i < 3; i++) {
981 PolylineMapObject polyline = locationWindow.addPolylineMapObject();
982 if (polyline !=
null) {
983 List<GlobalPoint> points =
new ArrayList<>();
984 points.add(
new GlobalPoint(i * 30.0, i * 30.0));
985 points.add(
new GlobalPoint((i + 1) * 30.0, (i + 1) * 30.0));
986 LocationPolyline locPoly =
new LocationPolyline(points, 0);
990 polylines.add(polyline);
991 System.out.println(
"Created polyline " + i +
" with width " + (2.0 + i));
995 for (
int i = 0; i < polylines.size(); i++) {
996 locationWindow.removePolylineMapObject(polylines.get(i));
997 System.out.println(
"Removed polyline " + i);
1004 private void demonstrateDottedPolylineMapObjects() {
1005 System.out.println(
"--- Dotted Polyline Map Objects ---");
1007 if (locationWindow ==
null) {
1008 System.out.println(
"LocationWindow not available yet");
1014 List<GlobalPoint> points =
new ArrayList<>();
1015 points.add(
new GlobalPoint(160.0, 170.0));
1016 points.add(
new GlobalPoint(165.0, 175.0));
1017 points.add(
new GlobalPoint(170.0, 180.0));
1018 points.add(
new GlobalPoint(175.0, 185.0));
1019 LocationPolyline locationPolyline =
new LocationPolyline(points, 0);
1020 dottedPolylineMapObject = locationWindow.addDottedPolylineMapObject();
1021 System.out.println(
"Created dotted polyline map object with " + points.size() +
" points");
1026 LocationPolyline dottedPolylineShape = dottedPolylineMapObject.getPolyLine();
1027 System.out.println(
"Dotted polyline has " + dottedPolylineShape.getPoints().size() +
" points");
1032 dottedPolylineMapObject = locationWindow.addDottedPolylineMapObject();
1033 System.out.println(
"Added dotted polyline map object");
1036 if (dottedPolylineMapObject !=
null) {
1039 List<GlobalPoint> dottedPoints =
new ArrayList<>();
1040 dottedPoints.add(
new GlobalPoint(0.0, 100.0));
1041 dottedPoints.add(
new GlobalPoint(50.0, 150.0));
1042 dottedPoints.add(
new GlobalPoint(100.0, 100.0));
1043 dottedPoints.add(
new GlobalPoint(150.0, 150.0));
1044 LocationPolyline locationDottedPolyline =
new LocationPolyline(dottedPoints, 0);
1045 boolean success = dottedPolylineMapObject.setPolyLine(locationDottedPolyline);
1046 System.out.println(
"Set dotted polyline geometry: " + success);
1051 boolean widthSuccess = dottedPolylineMapObject.setWidth(2.0);
1052 System.out.println(
"Set dotted polyline width to 2.0 pixels: " + widthSuccess);
1057 boolean colorSuccess = dottedPolylineMapObject.setColor(0xCC8000FF);
1058 System.out.println(
"Set dotted polyline color to purple with 80% opacity: " + colorSuccess);
1063 boolean orderSuccess = dottedPolylineMapObject.setOrder(3);
1064 System.out.println(
"Set rendering order to 3: " + orderSuccess);
1069 boolean visibleSuccess = dottedPolylineMapObject.setVisible(
true);
1070 System.out.println(
"Set dotted polyline visibility to true: " + visibleSuccess);
1075 MapObjectType objectType = dottedPolylineMapObject.getMapObjectType();
1076 System.out.println(
"Dotted polyline map object type: " + objectType);
1081 boolean alphaSuccess = dottedPolylineMapObject.setAlpha(0.8);
1082 System.out.println(
"Set dotted polyline alpha to 0.8: " + alphaSuccess);
1087 boolean interactiveSuccess = dottedPolylineMapObject.setInteractive(
true);
1088 System.out.println(
"Set dotted polyline interactive to true: " + interactiveSuccess);
1093 boolean titleSuccess = dottedPolylineMapObject.setTitle(
"Dotted Polyline Object");
1094 System.out.println(
"Set dotted polyline title to 'Dotted Polyline Object': " + titleSuccess);
1099 Map<String, Object> customData =
new HashMap<>();
1100 customData.put(
"key",
"value");
1101 customData.put(
"number", 42);
1102 boolean dataSuccess = dottedPolylineMapObject.setData(customData);
1103 System.out.println(
"Set dotted polyline custom data: " + dataSuccess);
1108 int objectId = dottedPolylineMapObject.getId();
1109 System.out.println(
"Dotted polyline object ID: " + objectId);
1114 String objectTypeString = dottedPolylineMapObject.getType();
1115 System.out.println(
"Dotted polyline object type: " + objectTypeString);
1120 Map<String, Object> retrievedData = dottedPolylineMapObject.getData();
1121 System.out.println(
"Dotted polyline custom data: " + retrievedData);
1126 boolean dottedCollisionSuccess = dottedPolylineMapObject.setCollisionEnabled(
true);
1127 System.out.println(
"Enabled collision detection for dotted polyline: " + dottedCollisionSuccess);
1132 boolean dottedPlacementSuccess = dottedPolylineMapObject.setPlacement(Placement.CENTER);
1133 System.out.println(
"Set dotted polyline placement to CENTER: " + dottedPlacementSuccess);
1138 boolean dottedMinRatioSuccess = dottedPolylineMapObject.setPlacementMinRatio(0.5);
1139 System.out.println(
"Set dotted polyline placement min ratio to 0.5: " + dottedMinRatioSuccess);
1144 boolean dottedSpacingSuccess = dottedPolylineMapObject.setPlacementSpacing(10.0);
1145 System.out.println(
"Set dotted polyline placement spacing to 10.0: " + dottedSpacingSuccess);
1150 boolean dottedPrioritySuccess = dottedPolylineMapObject.setPriority(1);
1151 System.out.println(
"Set dotted polyline rendering priority to 1: " + dottedPrioritySuccess);
1156 boolean dottedRepeatDistanceSuccess = dottedPolylineMapObject.setRepeatDistance(20.0);
1157 System.out.println(
"Set dotted polyline repeat distance to 20.0: " + dottedRepeatDistanceSuccess);
1162 boolean dottedRepeatGroupSuccess = dottedPolylineMapObject.setRepeatGroup(1);
1163 System.out.println(
"Set dotted polyline repeat group to 1: " + dottedRepeatGroupSuccess);
1168 Size dottedSize =
new Size(16.0, 16.0);
1169 boolean dottedSizeSuccess = dottedPolylineMapObject.setSize(dottedSize);
1170 System.out.println(
"Set dotted polyline size to (" + dottedSize.getWidth() +
", " + dottedSize.getHeight() +
"): " + dottedSizeSuccess);
1176 if (dottedPolylineMapObject !=
null) {
1177 boolean removed = locationWindow.removeDottedPolylineMapObject(dottedPolylineMapObject);
1178 System.out.println(
"Removed dotted polyline map object: " + removed);
1179 dottedPolylineMapObject =
null;
1184 List<DottedPolylineMapObject> dottedPolylines =
new ArrayList<>();
1185 for (
int i = 0; i < 2; i++) {
1186 DottedPolylineMapObject dottedPolyline = locationWindow.addDottedPolylineMapObject();
1187 if (dottedPolyline !=
null) {
1188 List<GlobalPoint> points =
new ArrayList<>();
1189 points.add(
new GlobalPoint(i * 40.0, i * 40.0 + 100.0));
1190 points.add(
new GlobalPoint((i + 1) * 40.0, (i + 1) * 40.0 + 100.0));
1191 LocationPolyline locPoly =
new LocationPolyline(points, 0);
1193 dottedPolyline.setWidth(1.5);
1194 dottedPolyline.
setColor(0x99FF00FF);
1195 dottedPolylines.add(dottedPolyline);
1196 System.out.println(
"Created dotted polyline " + i);
1200 for (
int i = 0; i < dottedPolylines.size(); i++) {
1201 locationWindow.removeDottedPolylineMapObject(dottedPolylines.get(i));
1202 System.out.println(
"Removed dotted polyline " + i);
1209 private void demonstrateRemoveAllMapObjects() {
1210 System.out.println(
"--- Remove All Map Objects ---");
1212 if (locationWindow ==
null) {
1213 System.out.println(
"LocationWindow not available yet");
1218 CircleMapObject circle = locationWindow.addCircleMapObject();
1219 IconMapObject icon = locationWindow.addIconMapObject();
1220 PolygonMapObject polygon = locationWindow.addPolygonMapObject();
1221 PolylineMapObject polyline = locationWindow.addPolylineMapObject();
1222 DottedPolylineMapObject dottedPolyline = locationWindow.addDottedPolylineMapObject();
1224 System.out.println(
"Created 5 map objects");
1228 locationWindow.removeAllMapObjects();
1229 System.out.println(
"Removed all map objects");
1236 private void demonstrateClusterMapObjects() {
1237 System.out.println(
"--- Cluster map objects ---");
1239 if (locationWindow ==
null) {
1240 System.out.println(
"LocationWindow not available");
1245 clusterMapObjectController = locationWindow.addClusterMapObjectController();
1246 System.out.println(
"Added cluster map object controller");
1249 if (clusterMapObjectController ==
null) {
1253 IconMapObject clusterIcon1 = locationWindow.addIconMapObject();
1254 IconMapObject clusterIcon2 = locationWindow.addIconMapObject();
1255 if (clusterIcon1 !=
null) {
1256 clusterIcon1.
setPosition(
new GlobalPoint(100.0, 100.0));
1258 if (clusterIcon2 !=
null) {
1259 clusterIcon2.
setPosition(
new GlobalPoint(105.0, 102.0));
1263 boolean added1 = clusterMapObjectController.addIconMapObject(clusterIcon1);
1264 boolean added2 = clusterMapObjectController.addIconMapObject(clusterIcon2);
1265 System.out.println(
"Registered icons for clustering: " + added1 +
", " + added2);
1269 clusterMapObjectController.setEnabled(
true);
1270 System.out.println(
"Clustering enabled");
1274 boolean clusteringEnabled = clusterMapObjectController.isEnabled();
1275 System.out.println(
"Clustering is enabled: " + clusteringEnabled);
1279 clusterMapObjectController.setRadius(40.0f);
1280 System.out.println(
"Set cluster radius to 40 px");
1284 float clusterRadius = clusterMapObjectController.getRadius();
1285 System.out.println(
"Cluster radius: " + clusterRadius);
1289 boolean interactiveSuccess = clusterMapObjectController.setInteractive(
true);
1290 System.out.println(
"Set cluster markers interactive: " + interactiveSuccess);
1294 boolean sizeSuccess = clusterMapObjectController.setClusterSize(32.0f, 32.0f);
1295 System.out.println(
"Set default cluster icon size: " + sizeSuccess);
1298 clusterMapObjectControllerListener =
new DemoClusterMapObjectControllerListener();
1301 clusterMapObjectController.addListener(clusterMapObjectControllerListener);
1302 System.out.println(
"Added cluster map object controller listener");
1306 List<ClusterMapObject> clusters = clusterMapObjectController.getClusters();
1307 System.out.println(
"Visible clusters: " + clusters.size());
1310 if (!clusters.isEmpty()) {
1311 ClusterMapObject cluster = clusters.get(0);
1313 ImageProvider clusterBitmap = ImageProvider.fromFile(
"/path/to/cluster.png",
true);
1314 boolean bitmapSuccess = cluster.
setBitmap(clusterBitmap);
1315 System.out.println(
"Set cluster bitmap from ImageProvider: " + bitmapSuccess);
1320 clusterMapObjectController.removeListener(clusterMapObjectControllerListener);
1321 System.out.println(
"Removed cluster map object controller listener");
1324 if (clusterIcon1 !=
null) {
1326 boolean removed = clusterMapObjectController.removeIconMapObject(clusterIcon1);
1327 System.out.println(
"Removed icon from cluster controller: " + removed);
1329 locationWindow.removeIconMapObject(clusterIcon1);
1331 if (clusterIcon2 !=
null) {
1332 locationWindow.removeIconMapObject(clusterIcon2);
1336 clusterMapObjectController.clear();
1337 System.out.println(
"Cleared cluster controller");
1341 boolean controllerRemoved =
1342 locationWindow.removeClusterMapObjectController(clusterMapObjectController);
1343 System.out.println(
"Removed cluster map object controller: " + controllerRemoved);
1346 clusterMapObjectController =
null;
1347 clusterMapObjectControllerListener =
null;
1354 if (circleMapObject !=
null) {
1355 locationWindow.removeCircleMapObject(circleMapObject);
1356 circleMapObject =
null;
1358 if (iconMapObject !=
null) {
1359 locationWindow.removeIconMapObject(iconMapObject);
1360 iconMapObject =
null;
1362 if (polygonMapObject !=
null) {
1364 polygonMapObject =
null;
1366 if (polylineMapObject !=
null) {
1367 locationWindow.removePolylineMapObject(polylineMapObject);
1368 polylineMapObject =
null;
1370 if (dottedPolylineMapObject !=
null) {
1371 locationWindow.removeDottedPolylineMapObject(dottedPolylineMapObject);
1372 dottedPolylineMapObject =
null;
1374 if (modelMapObject !=
null) {
1375 locationWindow.removeModelMapObject(modelMapObject);
1376 modelMapObject =
null;
1378 System.out.println(
"LocationWindowMapObjects example cleanup completed");