1package com.navigine.examples
3import com.navigine.image.ImageProvider
4import com.navigine.idl.kotlin.ModelMapObject
5import com.navigine.model.ModelProvider
7import com.navigine.idl.kotlin.LocationWindow
8import com.navigine.idl.kotlin.CircleMapObject
9import com.navigine.idl.kotlin.ClusterMapObject
10import com.navigine.idl.kotlin.ClusterMapObjectController
11import com.navigine.idl.kotlin.ClusterMapObjectControllerListener
12import com.navigine.idl.kotlin.ClusterMapObjectListener
13import com.navigine.idl.kotlin.IconMapObject
14import com.navigine.idl.kotlin.PolygonMapObject
15import com.navigine.idl.kotlin.PolylineMapObject
16import com.navigine.idl.kotlin.DottedPolylineMapObject
17import com.navigine.idl.kotlin.AnimationType
18import com.navigine.idl.kotlin.CapType
19import com.navigine.idl.kotlin.JoinType
20import com.navigine.idl.kotlin.LocationPoint
21import com.navigine.idl.kotlin.LocationPolygon
22import com.navigine.idl.kotlin.LocationPolyline
23import com.navigine.idl.kotlin.MapObjectType
24import com.navigine.idl.kotlin.Placement
25import com.navigine.idl.kotlin.Color
26import com.navigine.idl.kotlin.Size
27import com.navigine.idl.kotlin.Point
28import com.navigine.idl.kotlin.Polygon
29import com.navigine.idl.kotlin.Polyline
32 * LocationWindowMapObjects usage example for Kotlin
33 * Demonstrates specific methods: addCircleMapObject, removeCircleMapObject, addIconMapObject,
34 * removeIconMapObject, addPolygonMapObject, addPolylineMapObject, removePolylineMapObject,
35 * addDottedPolylineMapObject, removeDottedPolylineMapObject, removeAllMapObjects
37class LocationWindowMapObjectsExample {
38 private var locationWindow: LocationWindow? = null
39 private var circleMapObject: CircleMapObject? = null
40 private var iconMapObject: IconMapObject? = null
41 private var modelMapObject: ModelMapObject? = null
42 private var polygonMapObject: PolygonMapObject? = null
43 private var polylineMapObject: PolylineMapObject? = null
44 private var dottedPolylineMapObject: DottedPolylineMapObject? = null
45 private var clusterMapObjectController: ClusterMapObjectController? = null
46 private var clusterMapObjectControllerListener: ClusterMapObjectControllerListener? = null
49 demonstrateLocationWindowMapObjectsMethods()
53 * Demonstrate LocationWindowMapObjects methods
55 private fun demonstrateLocationWindowMapObjectsMethods() {
56 println("=== LocationWindowMapObjects Example ===")
58 // Initialize LocationWindow (in real app, this would be provided by the framework)
59 // locationWindow = getLocationWindow()
61 demonstrateLocationScopedGeometryRecords()
63 demonstrateCircleMapObjects()
64 demonstrateIconMapObjects()
65 demonstrateClusterMapObjects()
66 demonstrateModelMapObjects()
67 demonstratePolygonMapObjects()
68 demonstratePolylineMapObjects()
69 demonstrateDottedPolylineMapObjects()
70 demonstrateRemoveAllMapObjects()
76 * Metrics geometry scoped to a location / sublocation (@see LocationPolygon, LocationPolyline).
78 private fun demonstrateLocationScopedGeometryRecords() {
79 println("--- LocationPolygon / LocationPolyline records ---")
81 // [kotlin_LocationPolygon_record]
82 val ring = listOf(Point(1.0, 2.0), Point(3.0, 4.0), Point(5.0, 2.0))
83 val metricPolygon = Polygon(ring)
84 val locationPolygon = LocationPolygon(metricPolygon, 42, 7)
85 val polygonBack = locationPolygon.getPolygon()
86 val polygonLocationId = locationPolygon.getLocationId()
87 val polygonSublocationId = locationPolygon.getSublocationId()
88 println("LocationPolygon: location $polygonLocationId, sublocation $polygonSublocationId, vertices ${polygonBack.getPoints().size}")
89 // [kotlin_LocationPolygon_record]
91 // [kotlin_LocationPolyline_record]
92 val linePoints = listOf(Point(0.0, 0.0), Point(10.0, 10.0))
93 val metricPolyline = Polyline(linePoints)
94 val locationPolyline = LocationPolyline(metricPolyline, 42, 7)
95 val polylineBack = locationPolyline.getPolyline()
96 println("LocationPolyline: points ${polylineBack.getPoints().size}")
97 // [kotlin_LocationPolyline_record]
101 * Demonstrate circle map objects
103 private fun demonstrateCircleMapObjects() {
104 println("--- Circle Map Objects ---")
106 if (locationWindow == null) {
107 println("LocationWindow not available yet")
111 // [kotlin_CircleMapObject_constructor]
112 // Create circle map object
113 val center = LocationPoint(10.0, 20.0)
114 circleMapObject = locationWindow!!.addCircleMapObject()
115 println("Created circle map object with center (${center.x}, ${center.y}) and radius 5.0")
116 // [kotlin_CircleMapObject_constructor]
118 // [kotlin_CircleMapObject_getCenter]
119 // Access circle center
120 val circleCenter = circleMapObject!!.getPosition()
121 println("Circle center: (${circleCenter.x}, ${circleCenter.y})")
122 // [kotlin_CircleMapObject_getCenter]
124 // [kotlin_CircleMapObject_getRadius]
125 // Access circle radius
126 val radius = circleMapObject!!.getRadius()
127 println("Circle radius: $radius")
128 // [kotlin_CircleMapObject_getRadius]
130 // [kotlin_LocationWindow_addCircleMapObject]
131 // Add circle map object
132 circleMapObject = locationWindow!!.addCircleMapObject()
133 println("Added circle map object")
134 // [kotlin_LocationWindow_addCircleMapObject]
136 if (circleMapObject != null) {
137 // [kotlin_CircleMapObject_setPosition]
138 // Set circle position
139 val centerPoint = LocationPoint(100.0, 200.0)
140 val success = circleMapObject!!.setPosition(centerPoint)
141 println("Set circle position to (${centerPoint.x}, ${centerPoint.y}): $success")
142 // [kotlin_CircleMapObject_setPosition]
144 // [kotlin_CircleMapObject_setPositionAnimated]
145 // Set circle position with animation
146 val animatedPoint = LocationPoint(150.0, 250.0)
147 val animatedSuccess = circleMapObject!!.setPositionAnimated(animatedPoint, 2.0, AnimationType.LINEAR)
148 println("Set circle position with animation to (${animatedPoint.x}, ${animatedPoint.y}): $animatedSuccess")
149 // [kotlin_CircleMapObject_setPositionAnimated]
151 // [kotlin_CircleMapObject_setRadius]
153 val radiusSuccess = circleMapObject!!.setRadius(10.0)
154 println("Set circle radius to 10.0 meters: $radiusSuccess")
155 // [kotlin_CircleMapObject_setRadius]
157 // [kotlin_CircleMapObject_setCollisionEnabled]
158 // Enable collision detection
159 val collisionSuccess = circleMapObject!!.setCollisionEnabled(true)
160 println("Enabled collision detection for circle: $collisionSuccess")
161 // [kotlin_CircleMapObject_setCollisionEnabled]
163 // [kotlin_CircleMapObject_setBuffer]
164 // Set collision buffer
165 val bufferSuccess = circleMapObject!!.setBuffer(5.0, 5.0)
166 println("Set collision buffer to 5x5 pixels: $bufferSuccess")
167 // [kotlin_CircleMapObject_setBuffer]
169 // [kotlin_CircleMapObject_setOffset]
170 // Set position offset
171 val offsetSuccess = circleMapObject!!.setOffset(2.0, 3.0)
172 println("Set position offset to (2.0, 3.0) pixels: $offsetSuccess")
173 // [kotlin_CircleMapObject_setOffset]
175 // [kotlin_CircleMapObject_setOutlineColor]
177 val outlineColorSuccess = circleMapObject!!.setOutlineColor(0.0, 0.0, 1.0, 1.0)
178 println("Set circle outline color to blue: $outlineColorSuccess")
179 // [kotlin_CircleMapObject_setOutlineColor]
181 // [kotlin_CircleMapObject_setOutlineAlpha]
183 val outlineAlphaSuccess = circleMapObject!!.setOutlineAlpha(0.5)
184 println("Set circle outline alpha to 0.5: $outlineAlphaSuccess")
185 // [kotlin_CircleMapObject_setOutlineAlpha]
187 // [kotlin_CircleMapObject_setOutlineRadius]
188 // Set outline radius
189 val outlineRadiusSuccess = circleMapObject!!.setOutlineRadius(2.0)
190 println("Set circle outline radius to 2.0: $outlineRadiusSuccess")
191 // [kotlin_CircleMapObject_setOutlineRadius]
193 // [kotlin_CircleMapObject_setColor]
195 val colorSuccess = circleMapObject!!.setColor(1.0, 0.0, 0.0, 0.8)
196 println("Set circle color to red with 80% opacity: $colorSuccess")
197 // [kotlin_CircleMapObject_setColor]
199 // [kotlin_CircleMapObject_setPriority]
200 // Set rendering priority
201 val prioritySuccess = circleMapObject!!.setPriority(1)
202 println("Set rendering priority to 1: $prioritySuccess")
203 // [kotlin_CircleMapObject_setPriority]
205 // [kotlin_MapObject_setVisible]
207 val visibleSuccess = circleMapObject!!.setVisible(true)
208 println("Set circle visibility to true: $visibleSuccess")
209 // [kotlin_MapObject_setVisible]
211 // [kotlin_CircleMapObject_getMapObjectType]
212 // Get map object type
213 val objectType = circleMapObject!!.mapObjectType
214 println("Circle map object type: $objectType")
215 // [kotlin_CircleMapObject_getMapObjectType]
217 // [kotlin_MapObject_setAlpha]
218 // Set alpha transparency
219 val alphaSuccess = circleMapObject!!.setAlpha(0.7)
220 println("Set circle alpha to 0.7: $alphaSuccess")
221 // [kotlin_MapObject_setAlpha]
223 // [kotlin_MapObject_setInteractive]
224 // Set interactive mode
225 val interactiveSuccess = circleMapObject!!.setInteractive(true)
226 println("Set circle interactive to true: $interactiveSuccess")
227 // [kotlin_MapObject_setInteractive]
229 // [kotlin_MapObject_setTitle]
231 val titleSuccess = circleMapObject!!.setTitle("Circle Object")
232 println("Set circle title to 'Circle Object': $titleSuccess")
233 // [kotlin_MapObject_setTitle]
235 // [kotlin_MapObject_setData]
237 val customData = mapOf("key" to "value", "number" to "42")
238 val dataSuccess = circleMapObject!!.setData(customData)
239 println("Set circle custom data: $dataSuccess")
240 // [kotlin_MapObject_setData]
242 // [kotlin_MapObject_getId]
244 val objectId = circleMapObject!!.id
245 println("Circle object ID: $objectId")
246 // [kotlin_MapObject_getId]
248 // [kotlin_MapObject_getType]
250 val objectTypeString = circleMapObject!!.type
251 println("Circle object type: $objectTypeString")
252 // [kotlin_MapObject_getType]
254 // [kotlin_MapObject_getData]
256 val retrievedData = circleMapObject!!.data
257 println("Circle custom data: $retrievedData")
258 // [kotlin_MapObject_getData]
261 // [kotlin_LocationWindow_removeCircleMapObject]
262 // Remove circle map object
263 if (circleMapObject != null) {
264 val removed = locationWindow!!.removeCircleMapObject(circleMapObject!!)
265 println("Removed circle map object: $removed")
266 circleMapObject = null
268 // [kotlin_LocationWindow_removeCircleMapObject]
270 // Test multiple circle objects
271 val circles = mutableListOf<CircleMapObject>()
273 val circle = locationWindow!!.addCircleMapObject()
274 if (circle != null) {
275 circle.setPosition(LocationPoint(50.0 * i, 100.0 * i))
276 circle.setColor(0.0, 1.0, 0.0, 0.6)
277 circle.setRadius(5.0 + i * 2.0)
279 println("Created circle $i at (${50.0 * i}, ${100.0 * i}) with radius ${5.0 + i * 2.0}")
283 for (i in circles.indices) {
284 locationWindow!!.removeCircleMapObject(circles[i])
285 println("Removed circle $i")
290 * Demonstrate icon map objects
292 private fun demonstrateIconMapObjects() {
293 println("--- Icon Map Objects ---")
295 if (locationWindow == null) {
296 println("LocationWindow not available yet")
300 // [kotlin_IconMapObject_constructor]
301 // Create icon map object
302 val position = LocationPoint(30.0, 40.0)
303 iconMapObject = locationWindow!!.addIconMapObject()
304 println("Created icon map object at (${position.x}, ${position.y})")
305 // [kotlin_IconMapObject_constructor]
307 // [kotlin_IconMapObject_getPosition]
308 // Access icon position
309 val iconPosition = iconMapObject!!.getPosition()
310 println("Icon position: (${iconPosition.x}, ${iconPosition.y})")
311 // [kotlin_IconMapObject_getPosition]
313 // [kotlin_LocationWindow_addIconMapObject]
314 // Add icon map object
315 iconMapObject = locationWindow!!.addIconMapObject()
316 println("Added icon map object")
317 // [kotlin_LocationWindow_addIconMapObject]
319 if (iconMapObject != null) {
320 // [kotlin_IconMapObject_setPosition]
322 val position = LocationPoint(30.0, 40.0)
323 val success = iconMapObject!!.setPosition(position)
324 println("Set icon position to (${position.x}, ${position.y}): $success")
325 // [kotlin_IconMapObject_setPosition]
327 // [kotlin_IconMapObject_setPositionAnimated]
328 // Set icon position with animation
329 val animatedPosition = LocationPoint(35.0, 45.0)
330 val animatedSuccess = iconMapObject!!.setPositionAnimated(animatedPosition, 1.5, AnimationType.CUBIC)
331 println("Set icon position with animation to (${animatedPosition.x}, ${animatedPosition.y}): $animatedSuccess")
332 // [kotlin_IconMapObject_setPositionAnimated]
334 // [kotlin_IconMapObject_setBitmap]
335 val iconBitmap = ImageProvider.fromFile("/path/to/icon.png", true)
336 val bitmapSuccess = iconMapObject!!.setBitmap(iconBitmap)
337 println("Set icon from ImageProvider: $bitmapSuccess")
338 // [kotlin_IconMapObject_setBitmap]
340 // [kotlin_IconMapObject_setFlat]
341 // Set icon flat mode
342 val flatSuccess = iconMapObject!!.setFlat(true)
343 println("Set icon flat mode to true: $flatSuccess")
344 // [kotlin_IconMapObject_setFlat]
346 // [kotlin_IconMapObject_setSize]
348 val size = Size(32.0, 32.0)
349 val sizeSuccess = iconMapObject!!.setSize(size)
350 println("Set icon size to (${size.width}, ${size.height}): $sizeSuccess")
351 // [kotlin_IconMapObject_setSize]
353 // [kotlin_IconMapObject_setAngle]
354 // Set icon rotation angle
355 val angleSuccess = iconMapObject!!.setAngle(45.0)
356 println("Set icon rotation angle to 45 degrees: $angleSuccess")
357 // [kotlin_IconMapObject_setAngle]
359 // [kotlin_IconMapObject_setAngleAnimated]
360 // Set icon rotation with animation
361 val angleAnimatedSuccess = iconMapObject!!.setAngleAnimated(90.0, 2.0, AnimationType.SINE)
362 println("Set icon rotation with animation to 90 degrees: $angleAnimatedSuccess")
363 // [kotlin_IconMapObject_setAngleAnimated]
365 // [kotlin_IconMapObject_setCollisionEnabled]
366 // Enable collision detection
367 val collisionSuccess = iconMapObject!!.setCollisionEnabled(true)
368 println("Enabled collision detection for icon: $collisionSuccess")
369 // [kotlin_IconMapObject_setCollisionEnabled]
371 // [kotlin_IconMapObject_setBuffer]
372 // Set collision buffer
373 val bufferSuccess = iconMapObject!!.setBuffer(10.0, 10.0)
374 println("Set collision buffer to 10x10 pixels: $bufferSuccess")
375 // [kotlin_IconMapObject_setBuffer]
377 // [kotlin_IconMapObject_setBuffer]
378 // Set position offset
379 val offsetSuccess = iconMapObject!!.setOffset(0.0, -16.0)
380 println("Set position offset to (0.0, -16.0) pixels: $offsetSuccess")
381 // [kotlin_IconMapObject_setOffset]
383 // [kotlin_IconMapObject_setPriority]
384 // Set rendering priority
385 val prioritySuccess = iconMapObject!!.setPriority(2)
386 println("Set rendering priority to 2: $prioritySuccess")
387 // [kotlin_IconMapObject_setPriority]
389 // [kotlin_IconMapObject_setVisible]
391 val visibleSuccess = iconMapObject!!.setVisible(true)
392 println("Set icon visibility to true: $visibleSuccess")
393 // [kotlin_IconMapObject_setVisible]
395 // [kotlin_IconMapObject_getMapObjectType]
396 // Get map object type
397 val objectType = iconMapObject!!.mapObjectType
398 println("Icon map object type: $objectType")
399 // [kotlin_IconMapObject_getMapObjectType]
401 // [kotlin_MapObject_setAlpha_1]
402 // Set alpha transparency
403 val alphaSuccess = iconMapObject!!.setAlpha(0.8)
404 println("Set icon alpha to 0.8: $alphaSuccess")
405 // [kotlin_MapObject_setAlpha_1]
407 // [kotlin_MapObject_setInteractive_1]
408 // Set interactive mode
409 val interactiveSuccess = iconMapObject!!.setInteractive(true)
410 println("Set icon interactive to true: $interactiveSuccess")
411 // [kotlin_MapObject_setInteractive_1]
413 // [kotlin_MapObject_setTitle_1]
415 val titleSuccess = iconMapObject!!.setTitle("Icon Object")
416 println("Set icon title to 'Icon Object': $titleSuccess")
417 // [kotlin_MapObject_setTitle_1]
419 // [kotlin_MapObject_setData_1]
421 val customData = mapOf("key" to "value", "number" to "42")
422 val dataSuccess = iconMapObject!!.setData(customData)
423 println("Set icon custom data: $dataSuccess")
424 // [kotlin_MapObject_setData_1]
426 // [kotlin_MapObject_getId_1]
428 val objectId = iconMapObject!!.id
429 println("Icon object ID: $objectId")
430 // [kotlin_MapObject_getId_1]
432 // [kotlin_MapObject_getType_1]
434 val objectTypeString = iconMapObject!!.type
435 println("Icon object type: $objectTypeString")
436 // [kotlin_MapObject_getType_1]
438 // [kotlin_MapObject_getData_1]
440 val retrievedData = iconMapObject!!.data
441 println("Icon custom data: $retrievedData")
442 // [kotlin_MapObject_getData_1]
445 // [kotlin_LocationWindow_removeIconMapObject]
446 // Remove icon map object
447 if (iconMapObject != null) {
448 val removed = locationWindow!!.removeIconMapObject(iconMapObject!!)
449 println("Removed icon map object: $removed")
452 // [kotlin_LocationWindow_removeIconMapObject]
454 // Test multiple icon objects
455 val icons = mutableListOf<IconMapObject>()
457 val icon = locationWindow!!.addIconMapObject()
459 icon.setPosition(LocationPoint(60.0 * i, 120.0 * i))
460 icon.setBitmap(ImageProvider.fromFile("/path/to/icon.png", true))
461 icon.setSize(Size(24.0, 24.0))
463 println("Created icon $i at (${60.0 * i}, ${120.0 * i})")
467 for (i in icons.indices) {
468 locationWindow!!.removeIconMapObject(icons[i])
469 println("Removed icon $i")
473 private fun demonstrateModelMapObjects() {
474 println("--- Model Map Objects ---")
475 if (locationWindow == null) {
476 println("LocationWindow not available yet")
480 // [kotlin_LocationWindow_addModelMapObject]
481 modelMapObject = locationWindow!!.addModelMapObject()
482 println("Added model map object: ${modelMapObject != null}")
483 // [kotlin_LocationWindow_addModelMapObject]
485 val m = modelMapObject ?: return
487 // [kotlin_ModelMapObject_setPosition]
488 val posOk = m.setPosition(LocationPoint(12.0, 34.0))
489 println("Model setPosition: $posOk")
490 // [kotlin_ModelMapObject_setPosition]
492 // [kotlin_ModelMapObject_setPositionAnimated]
493 val posAnimOk = m.setPositionAnimated(LocationPoint(15.0, 40.0), 0.5f, AnimationType.SINE)
494 println("Model setPositionAnimated: $posAnimOk")
495 // [kotlin_ModelMapObject_setPositionAnimated]
497 // [kotlin_ModelMapObject_setModel]
498 val texture = ImageProvider.fromFile("/path/to/model_texture.png", true)
499 val model = ModelProvider.fromFile("/path/to/model.obj", texture)
500 val modelOk = m.setModel(model)
501 println("Model setModel: $modelOk")
502 // [kotlin_ModelMapObject_setModel]
504 // [kotlin_ModelMapObject_setSize]
505 val sizeOk = m.setSize(64.0f, 64.0f)
506 println("Model setSize: $sizeOk")
507 // [kotlin_ModelMapObject_setSize]
509 // [kotlin_ModelMapObject_setCollisionEnabled]
510 println("Model setCollisionEnabled: ${m.setCollisionEnabled(true)}")
511 // [kotlin_ModelMapObject_setCollisionEnabled]
513 // [kotlin_ModelMapObject_setAngle]
514 println("Model setAngle: ${m.setAngle(45.0f)}")
515 // [kotlin_ModelMapObject_setAngle]
517 // [kotlin_ModelMapObject_setAngleAnimated]
518 println("Model setAngleAnimated: ${m.setAngleAnimated(90.0f, 0.5f, AnimationType.QUINT)}")
519 // [kotlin_ModelMapObject_setAngleAnimated]
521 // [kotlin_ModelMapObject_setBuffer]
522 println("Model setBuffer: ${m.setBuffer(4.0f, 4.0f)}")
523 // [kotlin_ModelMapObject_setBuffer]
525 // [kotlin_ModelMapObject_setPriority]
526 println("Model setPriority: ${m.setPriority(10.0f)}")
527 // [kotlin_ModelMapObject_setPriority]
529 // [kotlin_LocationWindow_removeModelMapObject]
530 println("Removed model: ${locationWindow!!.removeModelMapObject(m)}")
531 modelMapObject = null
532 // [kotlin_LocationWindow_removeModelMapObject]
536 * Demonstrate polygon map objects
538 private fun demonstratePolygonMapObjects() {
539 println("--- Polygon Map Objects ---")
541 if (locationWindow == null) {
542 println("LocationWindow not available yet")
546 // [kotlin_LocationWindow_addPolygonMapObject]
547 // Add polygon map object
548 polygonMapObject = locationWindow!!.addPolygonMapObject()
549 println("Added polygon map object")
550 // [kotlin_LocationWindow_addPolygonMapObject]
552 if (polygonMapObject != null) {
553 // [kotlin_PolygonMapObject_setPolygon]
554 // Set polygon geometry
561 val metricPolygon = Polygon(points)
562 val polygon = LocationPolygon(metricPolygon, 1, 0)
563 val success = polygonMapObject!!.setPolygon(polygon)
564 println("Set polygon with ${points.size} points: $success")
565 // [kotlin_PolygonMapObject_setPolygon]
567 // [kotlin_PolygonMapObject_setColor]
569 val colorSuccess = polygonMapObject!!.setColor(0.0, 1.0, 0.0, 0.7)
570 println("Set polygon color to green with 70% opacity: $colorSuccess")
571 // [kotlin_PolygonMapObject_setColor]
573 // [kotlin_PolygonMapObject_setOrder]
574 // Set polygon rendering order
575 val orderSuccess = polygonMapObject!!.setOrder(2)
576 println("Set polygon rendering order to 2: $orderSuccess")
577 // [kotlin_PolygonMapObject_setOrder]
579 // [kotlin_PolygonMapObject_setOutlineColor]
580 // Set polygon outline color
581 val outlineColorSuccess = polygonMapObject!!.setOutlineColor(0.0, 0.0, 1.0, 1.0)
582 println("Set polygon outline color to blue: $outlineColorSuccess")
583 // [kotlin_PolygonMapObject_setOutlineColor]
585 // [kotlin_PolygonMapObject_setOutlineWidth]
586 // Set polygon outline width
587 val outlineWidthSuccess = polygonMapObject!!.setOutlineWidth(2.0)
588 println("Set polygon outline width to 2.0 pixels: $outlineWidthSuccess")
589 // [kotlin_PolygonMapObject_setOutlineWidth]
591 // [kotlin_PolygonMapObject_setOutlineAlpha]
592 // Set polygon outline alpha
593 val outlineAlphaSuccess = polygonMapObject!!.setOutlineAlpha(0.8)
594 println("Set polygon outline alpha to 0.8: $outlineAlphaSuccess")
595 // [kotlin_PolygonMapObject_setOutlineAlpha]
597 // [kotlin_PolygonMapObject_setOutlineOrder]
598 // Set polygon outline order
599 val outlineOrderSuccess = polygonMapObject!!.setOutlineOrder(1)
600 println("Set polygon outline order to 1: $outlineOrderSuccess")
601 // [kotlin_PolygonMapObject_setOutlineOrder]
603 // [kotlin_PolygonMapObject_setVisible]
605 val visibleSuccess = polygonMapObject!!.setVisible(true)
606 println("Set polygon visibility to true: $visibleSuccess")
607 // [kotlin_PolygonMapObject_setVisible]
609 // [kotlin_PolygonMapObject_getMapObjectType]
610 // Get map object type
611 val objectType = polygonMapObject!!.mapObjectType
612 println("Polygon map object type: $objectType")
613 // [kotlin_PolygonMapObject_getMapObjectType]
615 // [kotlin_MapObject_setAlpha_2]
616 // Set alpha transparency
617 val alphaSuccess = polygonMapObject!!.setAlpha(0.6)
618 println("Set polygon alpha to 0.6: $alphaSuccess")
619 // [kotlin_MapObject_setAlpha_2]
621 // [kotlin_MapObject_setInteractive_2]
622 // Set interactive mode
623 val interactiveSuccess = polygonMapObject!!.setInteractive(true)
624 println("Set polygon interactive to true: $interactiveSuccess")
625 // [kotlin_MapObject_setInteractive_2]
627 // [kotlin_MapObject_setTitle_2]
629 val titleSuccess = polygonMapObject!!.setTitle("Polygon Object")
630 println("Set polygon title to 'Polygon Object': $titleSuccess")
631 // [kotlin_MapObject_setTitle_2]
633 // [kotlin_MapObject_setData_2]
635 val customData = mapOf("key" to "value", "number" to "42")
636 val dataSuccess = polygonMapObject!!.setData(customData)
637 println("Set polygon custom data: $dataSuccess")
638 // [kotlin_MapObject_setData_2]
640 // [kotlin_MapObject_getId_2]
642 val objectId = polygonMapObject!!.id
643 println("Polygon object ID: $objectId")
644 // [kotlin_MapObject_getId_2]
646 // [kotlin_MapObject_getType_2]
648 val objectTypeString = polygonMapObject!!.type
649 println("Polygon object type: $objectTypeString")
650 // [kotlin_MapObject_getType_2]
652 // [kotlin_MapObject_getData_2]
654 val retrievedData = polygonMapObject!!.data
655 println("Polygon custom data: $retrievedData")
656 // [kotlin_MapObject_getData_2]
659 // [kotlin_LocationWindow_removePolygonMapObject]
660 // Remove polygon map object
661 if (polygonMapObject != null) {
662 val removed = locationWindow!!.removePolygonMapObject(polygonMapObject!!)
663 println("Removed polygon map object: $removed")
664 polygonMapObject = null
666 // [kotlin_LocationWindow_removePolygonMapObject]
668 // Test multiple polygon objects
669 val polygons = mutableListOf<PolygonMapObject>()
671 val polygon = locationWindow!!.addPolygonMapObject()
672 if (polygon != null) {
674 Point(300.0 + i * 50, 400.0 + i * 50),
675 Point(350.0 + i * 50, 450.0 + i * 50),
676 Point(400.0 + i * 50, 400.0 + i * 50),
677 Point(350.0 + i * 50, 350.0 + i * 50)
679 val metricPoly = Polygon(points)
680 val polygonGeometry = LocationPolygon(metricPoly, 1, 0)
681 polygon.setPolygon(polygonGeometry)
682 polygon.setColor(0.0, 0.0, 1.0, 0.5)
683 polygons.add(polygon)
684 println("Created polygon $i with ${points.size} points")
688 for (i in polygons.indices) {
689 locationWindow!!.removePolygonMapObject(polygons[i])
690 println("Removed polygon $i")
695 * Demonstrate polyline map objects
697 private fun demonstratePolylineMapObjects() {
698 println("--- Polyline Map Objects ---")
700 if (locationWindow == null) {
701 println("LocationWindow not available yet")
705 // [kotlin_PolylineMapObject_constructor]
706 // Create polyline map object
713 val metricPolyline = Polyline(points)
714 val polyline = LocationPolyline(metricPolyline, 1, 0)
715 polylineMapObject = locationWindow!!.addPolylineMapObject()
716 println("Created polyline map object with ${points.size} points")
717 // [kotlin_PolylineMapObject_constructor]
719 // [kotlin_PolylineMapObject_getPolyline]
721 val polylineShape = polylineMapObject!!.getPolyLine()
722 println("Polyline has ${polylineShape.getPolyline().getPoints().size} points")
723 // [kotlin_PolylineMapObject_getPolyline]
725 // [kotlin_LocationWindow_addPolylineMapObject]
726 // Add polyline map object
727 polylineMapObject = locationWindow!!.addPolylineMapObject()
728 println("Added polyline map object")
729 // [kotlin_LocationWindow_addPolylineMapObject]
731 if (polylineMapObject != null) {
732 // [kotlin_PolylineMapObject_setPolyLine]
733 // Set polyline geometry
740 val metricPl = Polyline(points)
741 val polyline = LocationPolyline(metricPl, 1, 0)
742 val success = polylineMapObject!!.setPolyLine(polyline)
743 println("Set polyline with ${points.size} points: $success")
744 // [kotlin_PolylineMapObject_setPolyLine]
746 // [kotlin_PolylineMapObject_setWidth]
747 // Set polyline width
748 val widthSuccess = polylineMapObject!!.setWidth(3.0)
749 println("Set polyline width to 3.0 pixels: $widthSuccess")
750 // [kotlin_PolylineMapObject_setWidth]
752 // [kotlin_PolylineMapObject_setColor]
753 // Set polyline color
754 val colorSuccess = polylineMapObject!!.setColor(0.0, 1.0, 0.0, 0.8)
755 println("Set polyline color to green with 80% opacity: $colorSuccess")
756 // [kotlin_PolylineMapObject_setColor]
758 // [kotlin_PolylineMapObject_setOrder]
759 // Set polyline rendering order
760 val orderSuccess = polylineMapObject!!.setOrder(1)
761 println("Set polyline rendering order to 1: $orderSuccess")
762 // [kotlin_PolylineMapObject_setOrder]
764 // [kotlin_PolylineMapObject_setCapType]
765 // Set polyline cap type
766 val capTypeSuccess = polylineMapObject!!.setCapType(CapType.ROUND)
767 println("Set polyline cap type to ROUND: $capTypeSuccess")
768 // [kotlin_PolylineMapObject_setCapType]
770 // [kotlin_PolylineMapObject_setJoinType]
771 // Set polyline join type
772 val joinTypeSuccess = polylineMapObject!!.setJoinType(JoinType.ROUND)
773 println("Set polyline join type to ROUND: $joinTypeSuccess")
774 // [kotlin_PolylineMapObject_setJoinType]
776 // [kotlin_PolylineMapObject_setMiterLimit]
777 // Set polyline miter limit
778 val miterLimitSuccess = polylineMapObject!!.setMiterLimit(2.0)
779 println("Set polyline miter limit to 2.0: $miterLimitSuccess")
780 // [kotlin_PolylineMapObject_setMiterLimit]
782 // [kotlin_PolylineMapObject_setOutlineWidth]
783 // Set polyline outline width
784 val outlineWidthSuccess = polylineMapObject!!.setOutlineWidth(1.0)
785 println("Set polyline outline width to 1.0 pixels: $outlineWidthSuccess")
786 // [kotlin_PolylineMapObject_setOutlineWidth]
788 // [kotlin_PolylineMapObject_setOutlineColor]
789 // Set polyline outline color
790 val outlineColorSuccess = polylineMapObject!!.setOutlineColor(0.0, 0.0, 0.0, 1.0)
791 println("Set polyline outline color to black: $outlineColorSuccess")
792 // [kotlin_PolylineMapObject_setOutlineColor]
794 // [kotlin_PolylineMapObject_setOutlineAlpha]
795 // Set polyline outline alpha
796 val outlineAlphaSuccess = polylineMapObject!!.setOutlineAlpha(0.5)
797 println("Set polyline outline alpha to 0.5: $outlineAlphaSuccess")
798 // [kotlin_PolylineMapObject_setOutlineAlpha]
800 // [kotlin_PolylineMapObject_setOutlineOrder]
801 // Set polyline outline rendering order
802 val outlineOrderSuccess = polylineMapObject!!.setOutlineOrder(0)
803 println("Set polyline outline rendering order to 0: $outlineOrderSuccess")
804 // [kotlin_PolylineMapObject_setOutlineOrder]
806 // [kotlin_PolylineMapObject_setOutlineCapType]
807 // Set polyline outline cap type
808 val outlineCapTypeSuccess = polylineMapObject!!.setOutlineCapType(CapType.SQUARE)
809 println("Set polyline outline cap type to SQUARE: $outlineCapTypeSuccess")
810 // [kotlin_PolylineMapObject_setOutlineCapType]
812 // [kotlin_PolylineMapObject_setOutlineJoinType]
813 // Set polyline outline join type
814 val outlineJoinTypeSuccess = polylineMapObject!!.setOutlineJoinType(JoinType.MITER)
815 println("Set polyline outline join type to MITER: $outlineJoinTypeSuccess")
816 // [kotlin_PolylineMapObject_setOutlineJoinType]
818 // [kotlin_PolylineMapObject_setOutlineMiterLimit]
819 // Set polyline outline miter limit
820 val outlineMiterLimitSuccess = polylineMapObject!!.setOutlineMiterLimit(3.0)
821 println("Set polyline outline miter limit to 3.0: $outlineMiterLimitSuccess")
822 // [kotlin_PolylineMapObject_setOutlineMiterLimit]
824 // [kotlin_PolylineMapObject_setVisible]
826 val visibleSuccess = polylineMapObject!!.setVisible(true)
827 println("Set polyline visibility to true: $visibleSuccess")
828 // [kotlin_PolylineMapObject_setVisible]
830 // [kotlin_PolylineMapObject_getMapObjectType]
831 // Get map object type
832 val objectType = polylineMapObject!!.mapObjectType
833 println("Polyline map object type: $objectType")
834 // [kotlin_PolylineMapObject_getMapObjectType]
836 // [kotlin_MapObject_setAlpha_3]
837 // Set alpha transparency
838 val alphaSuccess = polylineMapObject!!.setAlpha(0.7)
839 println("Set polyline alpha to 0.7: $alphaSuccess")
840 // [kotlin_MapObject_setAlpha_3]
842 // [kotlin_MapObject_setInteractive_3]
843 // Set interactive mode
844 val interactiveSuccess = polylineMapObject!!.setInteractive(true)
845 println("Set polyline interactive to true: $interactiveSuccess")
846 // [kotlin_MapObject_setInteractive_3]
848 // [kotlin_MapObject_setTitle_3]
850 val titleSuccess = polylineMapObject!!.setTitle("Polyline Object")
851 println("Set polyline title to 'Polyline Object': $titleSuccess")
852 // [kotlin_MapObject_setTitle_3]
854 // [kotlin_MapObject_setData_3]
856 val customData = mapOf("key" to "value", "number" to "42")
857 val dataSuccess = polylineMapObject!!.setData(customData)
858 println("Set polyline custom data: $dataSuccess")
859 // [kotlin_MapObject_setData_3]
861 // [kotlin_MapObject_getId_3]
863 val objectId = polylineMapObject!!.id
864 println("Polyline object ID: $objectId")
865 // [kotlin_MapObject_getId_3]
867 // [kotlin_MapObject_getType_3]
869 val objectTypeString = polylineMapObject!!.type
870 println("Polyline object type: $objectTypeString")
871 // [kotlin_MapObject_getType_3]
873 // [kotlin_MapObject_getData_3]
875 val retrievedData = polylineMapObject!!.data
876 println("Polyline custom data: $retrievedData")
877 // [kotlin_MapObject_getData_3]
880 // [kotlin_LocationWindow_removePolylineMapObject]
881 // Remove polyline map object
882 if (polylineMapObject != null) {
883 val removed = locationWindow!!.removePolylineMapObject(polylineMapObject!!)
884 println("Removed polyline map object: $removed")
885 polylineMapObject = null
887 // [kotlin_LocationWindow_removePolylineMapObject]
889 // Test multiple polyline objects
890 val polylines = mutableListOf<PolylineMapObject>()
892 val polyline = locationWindow!!.addPolylineMapObject()
893 if (polyline != null) {
895 Point(120.0 + i * 30, 130.0 + i * 30),
896 Point(125.0 + i * 30, 135.0 + i * 30),
897 Point(130.0 + i * 30, 140.0 + i * 30)
899 val metricPl = Polyline(points)
900 val polylineGeometry = LocationPolyline(metricPl, 1, 0)
901 polyline.setPolyLine(polylineGeometry)
902 polyline.setColor(1.0, 0.0, 0.0, 0.6)
903 polyline.setWidth(2.0)
904 polylines.add(polyline)
905 println("Created polyline $i with ${points.size} points")
909 for (i in polylines.indices) {
910 locationWindow!!.removePolylineMapObject(polylines[i])
911 println("Removed polyline $i")
916 * Demonstrate dotted polyline map objects
918 private fun demonstrateDottedPolylineMapObjects() {
919 println("--- Dotted Polyline Map Objects ---")
921 if (locationWindow == null) {
922 println("LocationWindow not available yet")
926 // [kotlin_DottedPolylineMapObject_constructor]
927 // Create dotted polyline map object
934 val dottedMetric = Polyline(points)
935 val polyline = LocationPolyline(dottedMetric, 1, 0)
936 dottedPolylineMapObject = locationWindow!!.addDottedPolylineMapObject()
937 println("Created dotted polyline map object with ${points.size} points")
938 // [kotlin_DottedPolylineMapObject_constructor]
940 // [kotlin_DottedPolylineMapObject_getPolyline]
941 // Access dotted polyline
942 val dottedPolylineShape = dottedPolylineMapObject!!.getPolyLine()
943 println("Dotted polyline has ${dottedPolylineShape.getPolyline().getPoints().size} points")
944 // [kotlin_DottedPolylineMapObject_getPolyline]
946 // [kotlin_LocationWindow_addDottedPolylineMapObject]
947 // Add dotted polyline map object
948 dottedPolylineMapObject = locationWindow!!.addDottedPolylineMapObject()
949 println("Added dotted polyline map object")
950 // [kotlin_LocationWindow_addDottedPolylineMapObject]
952 if (dottedPolylineMapObject != null) {
953 // [kotlin_DottedPolylineMapObject_setPolyline]
954 // Set dotted polyline geometry
961 val dottedPl = Polyline(points)
962 val polyline = LocationPolyline(dottedPl, 1, 0)
963 val success = dottedPolylineMapObject!!.setPolyline(polyline)
964 println("Set dotted polyline with ${points.size} points: $success")
965 // [kotlin_DottedPolylineMapObject_setPolyline]
967 // [kotlin_DottedPolylineMapObject_setColor]
968 // Set dotted polyline color
969 val colorSuccess = dottedPolylineMapObject!!.setColor(0.5, 0.0, 1.0, 0.8)
970 println("Set dotted polyline color to purple with 80% opacity: $colorSuccess")
971 // [kotlin_DottedPolylineMapObject_setColor]
973 // [kotlin_DottedPolylineMapObject_setWidth]
974 // Set dotted polyline width
975 val widthSuccess = dottedPolylineMapObject!!.setWidth(3.0)
976 println("Set dotted polyline width to 3.0 pixels: $widthSuccess")
977 // [kotlin_DottedPolylineMapObject_setWidth]
979 // [kotlin_DottedPolylineMapObject_setOrder]
980 // Set dotted polyline rendering order
981 val orderSuccess = dottedPolylineMapObject!!.setOrder(2)
982 println("Set dotted polyline rendering order to 2: $orderSuccess")
983 // [kotlin_DottedPolylineMapObject_setOrder]
985 // [kotlin_DottedPolylineMapObject_setCollisionEnabled]
986 // Enable collision detection
987 val collisionSuccess = dottedPolylineMapObject!!.setCollisionEnabled(true)
988 println("Enabled collision detection for dotted polyline: $collisionSuccess")
989 // [kotlin_DottedPolylineMapObject_setCollisionEnabled]
991 // [kotlin_DottedPolylineMapObject_setPlacement]
992 // Set placement type
993 val placementSuccess = dottedPolylineMapObject!!.setPlacement(Placement.CENTER)
994 println("Set dotted polyline placement to CENTER: $placementSuccess")
995 // [kotlin_DottedPolylineMapObject_setPlacement]
997 // [kotlin_DottedPolylineMapObject_setPlacementMinRatio]
998 // Set placement min ratio
999 val minRatioSuccess = dottedPolylineMapObject!!.setPlacementMinRatio(0.5)
1000 println("Set dotted polyline placement min ratio to 0.5: $minRatioSuccess")
1001 // [kotlin_DottedPolylineMapObject_setPlacementMinRatio]
1003 // [kotlin_DottedPolylineMapObject_setPlacementSpacing]
1004 // Set placement spacing
1005 val spacingSuccess = dottedPolylineMapObject!!.setPlacementSpacing(10.0)
1006 println("Set dotted polyline placement spacing to 10.0: $spacingSuccess")
1007 // [kotlin_DottedPolylineMapObject_setPlacementSpacing]
1009 // [kotlin_DottedPolylineMapObject_setPriority]
1010 // Set rendering priority
1011 val prioritySuccess = dottedPolylineMapObject!!.setPriority(1)
1012 println("Set dotted polyline rendering priority to 1: $prioritySuccess")
1013 // [kotlin_DottedPolylineMapObject_setPriority]
1015 // [kotlin_DottedPolylineMapObject_setRepeatDistance]
1016 // Set repeat distance
1017 val repeatDistanceSuccess = dottedPolylineMapObject!!.setRepeatDistance(20.0)
1018 println("Set dotted polyline repeat distance to 20.0: $repeatDistanceSuccess")
1019 // [kotlin_DottedPolylineMapObject_setRepeatDistance]
1021 // [kotlin_DottedPolylineMapObject_setRepeatGroup]
1023 val repeatGroupSuccess = dottedPolylineMapObject!!.setRepeatGroup(1)
1024 println("Set dotted polyline repeat group to 1: $repeatGroupSuccess")
1025 // [kotlin_DottedPolylineMapObject_setRepeatGroup]
1027 // [kotlin_DottedPolylineMapObject_setSize]
1029 val size = Size(16.0, 16.0)
1030 val sizeSuccess = dottedPolylineMapObject!!.setSize(size)
1031 println("Set dotted polyline size to (${size.width}, ${size.height}): $sizeSuccess")
1032 // [kotlin_DottedPolylineMapObject_setSize]
1034 // [kotlin_DottedPolylineMapObject_setVisible]
1036 val visibleSuccess = dottedPolylineMapObject!!.setVisible(true)
1037 println("Set dotted polyline visibility to true: $visibleSuccess")
1038 // [kotlin_DottedPolylineMapObject_setVisible]
1040 // [kotlin_DottedPolylineMapObject_getMapObjectType]
1041 // Get map object type
1042 val objectType = dottedPolylineMapObject!!.mapObjectType
1043 println("Dotted polyline map object type: $objectType")
1044 // [kotlin_DottedPolylineMapObject_getMapObjectType]
1046 // [kotlin_MapObject_setAlpha_4]
1047 // Set alpha transparency
1048 val alphaSuccess = dottedPolylineMapObject!!.setAlpha(0.8)
1049 println("Set dotted polyline alpha to 0.8: $alphaSuccess")
1050 // [kotlin_MapObject_setAlpha_4]
1052 // [kotlin_MapObject_setInteractive_4]
1053 // Set interactive mode
1054 val interactiveSuccess = dottedPolylineMapObject!!.setInteractive(true)
1055 println("Set dotted polyline interactive to true: $interactiveSuccess")
1056 // [kotlin_MapObject_setInteractive_4]
1058 // [kotlin_MapObject_setTitle_4]
1060 val titleSuccess = dottedPolylineMapObject!!.setTitle("Dotted Polyline Object")
1061 println("Set dotted polyline title to 'Dotted Polyline Object': $titleSuccess")
1062 // [kotlin_MapObject_setTitle_4]
1064 // [kotlin_MapObject_setData_4]
1066 val customData = mapOf("key" to "value", "number" to "42")
1067 val dataSuccess = dottedPolylineMapObject!!.setData(customData)
1068 println("Set dotted polyline custom data: $dataSuccess")
1069 // [kotlin_MapObject_setData_4]
1071 // [kotlin_MapObject_getId_4]
1073 val objectId = dottedPolylineMapObject!!.id
1074 println("Dotted polyline object ID: $objectId")
1075 // [kotlin_MapObject_getId_4]
1077 // [kotlin_MapObject_getType_4]
1079 val objectTypeString = dottedPolylineMapObject!!.type
1080 println("Dotted polyline object type: $objectTypeString")
1081 // [kotlin_MapObject_getType_4]
1083 // [kotlin_MapObject_getData_4]
1085 val retrievedData = dottedPolylineMapObject!!.data
1086 println("Dotted polyline custom data: $retrievedData")
1087 // [kotlin_MapObject_getData_4]
1090 // [kotlin_LocationWindow_removeDottedPolylineMapObject]
1091 // Remove dotted polyline map object
1092 if (dottedPolylineMapObject != null) {
1093 val removed = locationWindow!!.removeDottedPolylineMapObject(dottedPolylineMapObject!!)
1094 println("Removed dotted polyline map object: $removed")
1095 dottedPolylineMapObject = null
1097 // [kotlin_LocationWindow_removeDottedPolylineMapObject]
1099 // Test multiple dotted polyline objects
1100 val dottedPolylines = mutableListOf<DottedPolylineMapObject>()
1102 val dottedPolyline = locationWindow!!.addDottedPolylineMapObject()
1103 if (dottedPolyline != null) {
1104 val points = listOf(
1105 Point(180.0 + i * 30, 190.0 + i * 30),
1106 Point(185.0 + i * 30, 195.0 + i * 30),
1107 Point(190.0 + i * 30, 200.0 + i * 30)
1109 val pl = Polyline(points)
1110 val polylineGeometry = LocationPolyline(pl, 1, 0)
1111 dottedPolyline.setPolyline(polylineGeometry)
1112 dottedPolylines.add(dottedPolyline)
1113 println("Created dotted polyline $i with ${points.size} points")
1117 for (i in dottedPolylines.indices) {
1118 locationWindow!!.removeDottedPolylineMapObject(dottedPolylines[i])
1119 println("Removed dotted polyline $i")
1124 * Demonstrate icon clustering via ClusterMapObjectController.
1126 private fun demonstrateClusterMapObjects() {
1127 println("--- Cluster map objects ---")
1129 if (locationWindow == null) {
1130 println("LocationWindow not available")
1134 // [kotlin_LocationWindow_addClusterMapObjectController]
1135 clusterMapObjectController = locationWindow!!.addClusterMapObjectController()
1136 println("Added cluster map object controller")
1137 // [kotlin_LocationWindow_addClusterMapObjectController]
1139 val controller = clusterMapObjectController ?: return
1141 val clusterIcon1 = locationWindow!!.addIconMapObject()
1142 val clusterIcon2 = locationWindow!!.addIconMapObject()
1143 clusterIcon1?.setPosition(LocationPoint(100.0, 100.0))
1144 clusterIcon2?.setPosition(LocationPoint(105.0, 102.0))
1146 // [kotlin_ClusterMapObjectController_addIconMapObject]
1147 val added1 = controller.addIconMapObject(clusterIcon1)
1148 val added2 = controller.addIconMapObject(clusterIcon2)
1149 println("Registered icons for clustering: $added1, $added2")
1150 // [kotlin_ClusterMapObjectController_addIconMapObject]
1152 // [kotlin_ClusterMapObjectController_setEnabled]
1153 controller.setEnabled(true)
1154 println("Clustering enabled")
1155 // [kotlin_ClusterMapObjectController_setEnabled]
1157 // [kotlin_ClusterMapObjectController_isEnabled]
1158 val clusteringEnabled = controller.isEnabled
1159 println("Clustering is enabled: $clusteringEnabled")
1160 // [kotlin_ClusterMapObjectController_isEnabled]
1162 // [kotlin_ClusterMapObjectController_setRadius]
1163 controller.setRadius(40.0f)
1164 println("Set cluster radius to 40 px")
1165 // [kotlin_ClusterMapObjectController_setRadius]
1167 // [kotlin_ClusterMapObjectController_getRadius]
1168 val clusterRadius = controller.getRadius()
1169 println("Cluster radius: $clusterRadius")
1170 // [kotlin_ClusterMapObjectController_getRadius]
1172 // [kotlin_ClusterMapObjectController_setInteractive]
1173 val interactiveSuccess = controller.setInteractive(true)
1174 println("Set cluster markers interactive: $interactiveSuccess")
1175 // [kotlin_ClusterMapObjectController_setInteractive]
1177 // [kotlin_ClusterMapObjectController_setClusterSize]
1178 val sizeSuccess = controller.setClusterSize(32.0f, 32.0f)
1179 println("Set default cluster icon size: $sizeSuccess")
1180 // [kotlin_ClusterMapObjectController_setClusterSize]
1182 clusterMapObjectControllerListener = DemoClusterMapObjectControllerListener()
1184 // [kotlin_ClusterMapObjectController_addListener]
1185 controller.addListener(clusterMapObjectControllerListener!!)
1186 println("Added cluster map object listener")
1187 // [kotlin_ClusterMapObjectController_addListener]
1189 // [kotlin_ClusterMapObjectController_getClusters]
1190 val clusters = controller.getClusters()
1191 println("Visible clusters: ${clusters.size}")
1192 // [kotlin_ClusterMapObjectController_getClusters]
1194 if (clusters.isNotEmpty()) {
1195 val cluster = clusters[0]
1196 // [kotlin_ClusterMapObject_setBitmap]
1197 val clusterBitmap = ImageProvider.fromFile("/path/to/cluster.png", true)
1198 val bitmapSuccess = cluster.setBitmap(clusterBitmap)
1199 println("Set cluster bitmap from ImageProvider: $bitmapSuccess")
1200 // [kotlin_ClusterMapObject_setBitmap]
1203 // [kotlin_ClusterMapObjectController_removeListener]
1204 controller.removeListener(clusterMapObjectControllerListener!!)
1205 println("Removed cluster map object listener")
1206 // [kotlin_ClusterMapObjectController_removeListener]
1209 // [kotlin_ClusterMapObjectController_removeIconMapObject]
1210 val removed = controller.removeIconMapObject(it)
1211 println("Removed icon from cluster controller: $removed")
1212 // [kotlin_ClusterMapObjectController_removeIconMapObject]
1213 locationWindow!!.removeIconMapObject(it)
1215 clusterIcon2?.let { locationWindow!!.removeIconMapObject(it) }
1217 // [kotlin_ClusterMapObjectController_clear]
1219 println("Cleared cluster controller")
1220 // [kotlin_ClusterMapObjectController_clear]
1222 // [kotlin_LocationWindow_removeClusterMapObjectController]
1223 val controllerRemoved =
1224 locationWindow!!.removeClusterMapObjectController(controller)
1225 println("Removed cluster map object controller: $controllerRemoved")
1226 // [kotlin_LocationWindow_removeClusterMapObjectController]
1228 clusterMapObjectController = null
1229 clusterMapObjectControllerListener = null
1233 * Demonstrate remove all map objects
1235 private fun demonstrateRemoveAllMapObjects() {
1236 println("--- Remove All Map Objects ---")
1238 if (locationWindow == null) {
1239 println("LocationWindow not available yet")
1243 println("Current map objects count: ${getMapObjectsCount()}")
1245 // [kotlin_LocationWindow_removeAllMapObjects]
1246 // Remove all map objects
1247 locationWindow!!.removeAllMapObjects()
1248 println("Removed all map objects")
1249 // [kotlin_LocationWindow_removeAllMapObjects]
1251 println("Map objects count after removal: ${getMapObjectsCount()}")
1255 * Get current map objects count
1257 private fun getMapObjectsCount(): Int {
1259 if (circleMapObject != null) count++
1260 if (iconMapObject != null) count++
1261 if (polygonMapObject != null) count++
1262 if (polylineMapObject != null) count++
1263 if (dottedPolylineMapObject != null) count++
1270 private fun cleanup() {
1271 println("--- Cleanup ---")
1273 if (locationWindow != null) {
1274 locationWindow!!.removeAllMapObjects()
1275 println("Cleaned up all map objects")
1278 circleMapObject = null
1279 iconMapObject = null
1280 modelMapObject = null
1281 polygonMapObject = null
1282 polylineMapObject = null
1283 dottedPolylineMapObject = null
1284 println("Cleared map objects references")
1288class DemoClusterMapObjectControllerListener : ClusterMapObjectControllerListener {
1289 private val clusterChangeListener = DemoClusterMapObjectListener()
1290 private var activeCluster: ClusterMapObject? = null
1292 // [kotlin_ClusterMapObjectControllerListener_onClusterCreated]
1293 override fun onClusterCreated(controller: ClusterMapObjectController, cluster: ClusterMapObject) {
1294 // [kotlin_ClusterMapObject_addListener]
1295 cluster.addListener(clusterChangeListener)
1296 println("Added cluster change listener, initial count: ${cluster.count}")
1297 // [kotlin_ClusterMapObject_addListener]
1298 activeCluster = cluster
1300 // [kotlin_ClusterMapObjectControllerListener_onClusterCreated]
1302 // [kotlin_ClusterMapObjectControllerListener_onClusterDestroyed]
1303 override fun onClusterDestroyed(controller: ClusterMapObjectController, clusterId: Int) {
1304 val cluster = activeCluster
1305 if (cluster != null && cluster.id == clusterId) {
1306 // [kotlin_ClusterMapObject_removeListener]
1307 cluster.removeListener(clusterChangeListener)
1308 println("Removed cluster change listener")
1309 // [kotlin_ClusterMapObject_removeListener]
1310 activeCluster = null
1312 println("Cluster destroyed, id: $clusterId")
1314 // [kotlin_ClusterMapObjectControllerListener_onClusterDestroyed]
1317class DemoClusterMapObjectListener : ClusterMapObjectListener {
1319 // [kotlin_ClusterMapObjectListener_onClusterChanged]
1320 override fun onClusterChanged(cluster: ClusterMapObject) {
1321 val memberCount = cluster.getCount()
1322 println("Cluster changed, member count: $memberCount")
1324 // [kotlin_ClusterMapObjectListener_onClusterChanged]
1327// Main function to run the example
1329 LocationWindowMapObjectsExample()