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.LocationPolygon
21import com.navigine.idl.kotlin.LocationPolyline
22import com.navigine.idl.kotlin.MapObjectType
23import com.navigine.idl.kotlin.Placement
24import com.navigine.idl.kotlin.Color
25import com.navigine.idl.kotlin.Size
26import com.navigine.idl.kotlin.GlobalPoint
27import com.navigine.idl.kotlin.Polygon
28import com.navigine.idl.kotlin.Polyline
29import com.navigine.idl.kotlin.TitleStyle
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]
83 GlobalPoint(55.751, 37.617),
84 GlobalPoint(55.752, 37.618),
85 GlobalPoint(55.751, 37.619)
87 val locationPolygon = LocationPolygon(ring, 7)
88 val polygonSublocationId = locationPolygon.sublocationId
89 println("LocationPolygon: sublocation $polygonSublocationId, vertices ${locationPolygon.points.size}")
90 // [kotlin_LocationPolygon_record]
92 // [kotlin_LocationPolyline_record]
93 val linePoints = listOf(
94 GlobalPoint(55.751, 37.617),
95 GlobalPoint(55.753, 37.620)
97 val locationPolyline = LocationPolyline(linePoints, 7)
98 println("LocationPolyline: points ${locationPolyline.points.size}")
99 // [kotlin_LocationPolyline_record]
103 * Demonstrate circle map objects
105 private fun demonstrateCircleMapObjects() {
106 println("--- Circle Map Objects ---")
108 if (locationWindow == null) {
109 println("LocationWindow not available yet")
113 // [kotlin_CircleMapObject_constructor]
114 // Create circle map object
115 val center = GlobalPoint(10.0, 20.0)
116 circleMapObject = locationWindow!!.addCircleMapObject()
117 println("Created circle map object with center (${center.latitude}, ${center.longitude}) and radius 5.0")
118 // [kotlin_CircleMapObject_constructor]
120 // [kotlin_CircleMapObject_getRadius]
121 // Access circle radius
122 val radius = circleMapObject!!.getRadius()
123 println("Circle radius: $radius")
124 // [kotlin_CircleMapObject_getRadius]
126 // [kotlin_LocationWindow_addCircleMapObject]
127 // Add circle map object
128 circleMapObject = locationWindow!!.addCircleMapObject()
129 println("Added circle map object")
130 // [kotlin_LocationWindow_addCircleMapObject]
132 if (circleMapObject != null) {
133 // [kotlin_CircleMapObject_setPosition]
134 // Set circle position
135 val centerPoint = GlobalPoint(100.0, 200.0)
136 val success = circleMapObject!!.setPosition(centerPoint, 7)
137 println("Set circle position to (${centerPoint.latitude}, ${centerPoint.longitude}): $success")
138 // [kotlin_CircleMapObject_setPosition]
140 // [kotlin_CircleMapObject_setPositionAnimated]
141 // Set circle position with animation
142 val animatedPoint = GlobalPoint(150.0, 250.0)
143 val animatedSuccess = circleMapObject!!.setPositionAnimated(animatedPoint, 7, 2.0, AnimationType.LINEAR)
144 println("Set circle position with animation to (${animatedPoint.latitude}, ${animatedPoint.longitude}): $animatedSuccess")
145 // [kotlin_CircleMapObject_setPositionAnimated]
147 // [kotlin_CircleMapObject_setRadius]
149 val radiusSuccess = circleMapObject!!.setRadius(10.0)
150 println("Set circle radius to 10.0 meters: $radiusSuccess")
151 // [kotlin_CircleMapObject_setRadius]
153 // [kotlin_CircleMapObject_setCollisionEnabled]
154 // Enable collision detection
155 val collisionSuccess = circleMapObject!!.setCollisionEnabled(true)
156 println("Enabled collision detection for circle: $collisionSuccess")
157 // [kotlin_CircleMapObject_setCollisionEnabled]
159 // [kotlin_CircleMapObject_setBuffer]
160 // Set collision buffer
161 val bufferSuccess = circleMapObject!!.setBuffer(5.0, 5.0)
162 println("Set collision buffer to 5x5 pixels: $bufferSuccess")
163 // [kotlin_CircleMapObject_setBuffer]
165 // [kotlin_CircleMapObject_setOffset]
166 // Set position offset
167 val offsetSuccess = circleMapObject!!.setOffset(2.0, 3.0)
168 println("Set position offset to (2.0, 3.0) pixels: $offsetSuccess")
169 // [kotlin_CircleMapObject_setOffset]
171 // [kotlin_CircleMapObject_setOutlineColor]
173 val outlineColorSuccess = circleMapObject!!.setOutlineColor(0xFF0000FF.toInt())
174 println("Set circle outline color to blue: $outlineColorSuccess")
175 // [kotlin_CircleMapObject_setOutlineColor]
177 // [kotlin_CircleMapObject_setOutlineAlpha]
179 val outlineAlphaSuccess = circleMapObject!!.setOutlineAlpha(0.5)
180 println("Set circle outline alpha to 0.5: $outlineAlphaSuccess")
181 // [kotlin_CircleMapObject_setOutlineAlpha]
183 // [kotlin_CircleMapObject_setOutlineRadius]
184 // Set outline radius
185 val outlineRadiusSuccess = circleMapObject!!.setOutlineRadius(2.0)
186 println("Set circle outline radius to 2.0: $outlineRadiusSuccess")
187 // [kotlin_CircleMapObject_setOutlineRadius]
189 // [kotlin_CircleMapObject_setColor]
191 val colorSuccess = circleMapObject!!.setColor(0xCCFF0000.toInt())
192 println("Set circle color to red with 80% opacity: $colorSuccess")
193 // [kotlin_CircleMapObject_setColor]
195 // [kotlin_CircleMapObject_setPriority]
196 // Set rendering priority
197 val prioritySuccess = circleMapObject!!.setPriority(1)
198 println("Set rendering priority to 1: $prioritySuccess")
199 // [kotlin_CircleMapObject_setPriority]
201 // [kotlin_MapObject_setVisible]
203 val visibleSuccess = circleMapObject!!.setVisible(true)
204 println("Set circle visibility to true: $visibleSuccess")
205 // [kotlin_MapObject_setVisible]
207 // [kotlin_CircleMapObject_getMapObjectType]
208 // Get map object type
209 val objectType = circleMapObject!!.mapObjectType
210 println("Circle map object type: $objectType")
211 // [kotlin_CircleMapObject_getMapObjectType]
213 // [kotlin_MapObject_setAlpha]
214 // Set alpha transparency
215 val alphaSuccess = circleMapObject!!.setAlpha(0.7)
216 println("Set circle alpha to 0.7: $alphaSuccess")
217 // [kotlin_MapObject_setAlpha]
219 // [kotlin_MapObject_setInteractive]
220 // Set interactive mode
221 val interactiveSuccess = circleMapObject!!.setInteractive(true)
222 println("Set circle interactive to true: $interactiveSuccess")
223 // [kotlin_MapObject_setInteractive]
225 // [kotlin_MapObject_setTitle]
227 val titleSuccess = circleMapObject!!.setTitle("Circle Object")
228 println("Set circle title to 'Circle Object': $titleSuccess")
229 // [kotlin_MapObject_setTitle]
231 // [kotlin_TitleStyle_record]
232 val titleStyle = TitleStyle()
233 titleStyle.fontSize = 14f
234 titleStyle.color = "#3366CC"
235 titleStyle.outlineColor = "#FFFFFF"
236 titleStyle.anchor = TitleAnchor.TOP
237 titleStyle.visible = true
238 // [kotlin_TitleStyle_record]
240 // [kotlin_MapObject_setTitleWithStyle]
241 // Set title with style
242 val titleStyleSuccess = circleMapObject!!.setTitleWithStyle("Styled Circle", titleStyle)
243 println("Set circle title with style: $titleStyleSuccess")
244 // [kotlin_MapObject_setTitleWithStyle]
246 // [kotlin_MapObject_setData]
248 val customData = mapOf("key" to "value", "number" to "42")
249 val dataSuccess = circleMapObject!!.setData(customData)
250 println("Set circle custom data: $dataSuccess")
251 // [kotlin_MapObject_setData]
253 // [kotlin_MapObject_getId]
255 val objectId = circleMapObject!!.id
256 println("Circle object ID: $objectId")
257 // [kotlin_MapObject_getId]
259 // [kotlin_MapObject_getType]
261 val objectTypeString = circleMapObject!!.type
262 println("Circle object type: $objectTypeString")
263 // [kotlin_MapObject_getType]
265 // [kotlin_MapObject_getData]
267 val retrievedData = circleMapObject!!.data
268 println("Circle custom data: $retrievedData")
269 // [kotlin_MapObject_getData]
272 // [kotlin_LocationWindow_removeCircleMapObject]
273 // Remove circle map object
274 if (circleMapObject != null) {
275 val removed = locationWindow!!.removeCircleMapObject(circleMapObject!!)
276 println("Removed circle map object: $removed")
277 circleMapObject = null
279 // [kotlin_LocationWindow_removeCircleMapObject]
281 // Test multiple circle objects
282 val circles = mutableListOf<CircleMapObject>()
284 val circle = locationWindow!!.addCircleMapObject()
285 if (circle != null) {
286 circle.setPosition(GlobalPoint(50.0 * i, 100.0 * i))
287 circle.setColor(0x9900FF00.toInt())
288 circle.setRadius(5.0 + i * 2.0)
290 println("Created circle $i at (${50.0 * i}, ${100.0 * i}) with radius ${5.0 + i * 2.0}")
294 for (i in circles.indices) {
295 locationWindow!!.removeCircleMapObject(circles[i])
296 println("Removed circle $i")
301 * Demonstrate icon map objects
303 private fun demonstrateIconMapObjects() {
304 println("--- Icon Map Objects ---")
306 if (locationWindow == null) {
307 println("LocationWindow not available yet")
311 // [kotlin_IconMapObject_constructor]
312 // Create icon map object
313 val position = GlobalPoint(30.0, 40.0)
314 iconMapObject = locationWindow!!.addIconMapObject()
315 println("Created icon map object at (${position.latitude}, ${position.longitude})")
316 // [kotlin_IconMapObject_constructor]
318 // [kotlin_LocationWindow_addIconMapObject]
319 // Add icon map object
320 iconMapObject = locationWindow!!.addIconMapObject()
321 println("Added icon map object")
322 // [kotlin_LocationWindow_addIconMapObject]
324 if (iconMapObject != null) {
325 // [kotlin_IconMapObject_setPosition]
327 val position = GlobalPoint(30.0, 40.0)
328 val success = iconMapObject!!.setPosition(position, 7)
329 println("Set icon position to (${position.latitude}, ${position.longitude}): $success")
330 // [kotlin_IconMapObject_setPosition]
332 // [kotlin_IconMapObject_setPositionAnimated]
333 // Set icon position with animation
334 val animatedPosition = GlobalPoint(35.0, 45.0)
335 val animatedSuccess = iconMapObject!!.setPositionAnimated(animatedPosition, 7, 1.5, AnimationType.CUBIC)
336 println("Set icon position with animation to (${animatedPosition.latitude}, ${animatedPosition.longitude}): $animatedSuccess")
337 // [kotlin_IconMapObject_setPositionAnimated]
339 // [kotlin_IconMapObject_setBitmap]
340 val iconBitmap = ImageProvider.fromFile("/path/to/icon.png", true)
341 val bitmapSuccess = iconMapObject!!.setBitmap(iconBitmap)
342 println("Set icon from ImageProvider: $bitmapSuccess")
343 // [kotlin_IconMapObject_setBitmap]
345 // [kotlin_IconMapObject_setFlat]
346 // Set icon flat mode
347 val flatSuccess = iconMapObject!!.setFlat(true)
348 println("Set icon flat mode to true: $flatSuccess")
349 // [kotlin_IconMapObject_setFlat]
351 // [kotlin_IconMapObject_setSize]
353 val size = Size(32.0, 32.0)
354 val sizeSuccess = iconMapObject!!.setSize(size)
355 println("Set icon size to (${size.width}, ${size.height}): $sizeSuccess")
356 // [kotlin_IconMapObject_setSize]
358 // [kotlin_IconMapObject_setAngle]
359 // Set icon rotation angle (radians)
360 val angleSuccess = iconMapObject!!.setAngle(Math.toRadians(45.0).toFloat())
361 println("Set icon rotation angle to π/4: $angleSuccess")
362 // [kotlin_IconMapObject_setAngle]
364 // [kotlin_IconMapObject_setAngleAnimated]
365 // Set icon rotation with animation (radians)
366 val angleAnimatedSuccess = iconMapObject!!.setAngleAnimated(Math.toRadians(90.0).toFloat(), 2.0, AnimationType.SINE)
367 println("Set icon rotation with animation to π/2: $angleAnimatedSuccess")
368 // [kotlin_IconMapObject_setAngleAnimated]
370 // [kotlin_IconMapObject_setCollisionEnabled]
371 // Enable collision detection
372 val collisionSuccess = iconMapObject!!.setCollisionEnabled(true)
373 println("Enabled collision detection for icon: $collisionSuccess")
374 // [kotlin_IconMapObject_setCollisionEnabled]
376 // [kotlin_IconMapObject_setBuffer]
377 // Set collision buffer
378 val bufferSuccess = iconMapObject!!.setBuffer(10.0, 10.0)
379 println("Set collision buffer to 10x10 pixels: $bufferSuccess")
380 // [kotlin_IconMapObject_setBuffer]
382 // [kotlin_IconMapObject_setBuffer]
383 // Set position offset
384 val offsetSuccess = iconMapObject!!.setOffset(0.0, -16.0)
385 println("Set position offset to (0.0, -16.0) pixels: $offsetSuccess")
386 // [kotlin_IconMapObject_setOffset]
388 // [kotlin_IconMapObject_setPriority]
389 // Set rendering priority
390 val prioritySuccess = iconMapObject!!.setPriority(2)
391 println("Set rendering priority to 2: $prioritySuccess")
392 // [kotlin_IconMapObject_setPriority]
394 // [kotlin_IconMapObject_setVisible]
396 val visibleSuccess = iconMapObject!!.setVisible(true)
397 println("Set icon visibility to true: $visibleSuccess")
398 // [kotlin_IconMapObject_setVisible]
400 // [kotlin_IconMapObject_getMapObjectType]
401 // Get map object type
402 val objectType = iconMapObject!!.mapObjectType
403 println("Icon map object type: $objectType")
404 // [kotlin_IconMapObject_getMapObjectType]
406 // [kotlin_MapObject_setAlpha_1]
407 // Set alpha transparency
408 val alphaSuccess = iconMapObject!!.setAlpha(0.8)
409 println("Set icon alpha to 0.8: $alphaSuccess")
410 // [kotlin_MapObject_setAlpha_1]
412 // [kotlin_MapObject_setInteractive_1]
413 // Set interactive mode
414 val interactiveSuccess = iconMapObject!!.setInteractive(true)
415 println("Set icon interactive to true: $interactiveSuccess")
416 // [kotlin_MapObject_setInteractive_1]
418 // [kotlin_MapObject_setTitle_1]
420 val titleSuccess = iconMapObject!!.setTitle("Icon Object")
421 println("Set icon title to 'Icon Object': $titleSuccess")
422 // [kotlin_MapObject_setTitle_1]
424 // [kotlin_MapObject_setData_1]
426 val customData = mapOf("key" to "value", "number" to "42")
427 val dataSuccess = iconMapObject!!.setData(customData)
428 println("Set icon custom data: $dataSuccess")
429 // [kotlin_MapObject_setData_1]
431 // [kotlin_MapObject_getId_1]
433 val objectId = iconMapObject!!.id
434 println("Icon object ID: $objectId")
435 // [kotlin_MapObject_getId_1]
437 // [kotlin_MapObject_getType_1]
439 val objectTypeString = iconMapObject!!.type
440 println("Icon object type: $objectTypeString")
441 // [kotlin_MapObject_getType_1]
443 // [kotlin_MapObject_getData_1]
445 val retrievedData = iconMapObject!!.data
446 println("Icon custom data: $retrievedData")
447 // [kotlin_MapObject_getData_1]
450 // [kotlin_LocationWindow_removeIconMapObject]
451 // Remove icon map object
452 if (iconMapObject != null) {
453 val removed = locationWindow!!.removeIconMapObject(iconMapObject!!)
454 println("Removed icon map object: $removed")
457 // [kotlin_LocationWindow_removeIconMapObject]
459 // Test multiple icon objects
460 val icons = mutableListOf<IconMapObject>()
462 val icon = locationWindow!!.addIconMapObject()
464 icon.setPosition(GlobalPoint(60.0 * i, 120.0 * i))
465 icon.setBitmap(ImageProvider.fromFile("/path/to/icon.png", true))
466 icon.setSize(Size(24.0, 24.0))
468 println("Created icon $i at (${60.0 * i}, ${120.0 * i})")
472 for (i in icons.indices) {
473 locationWindow!!.removeIconMapObject(icons[i])
474 println("Removed icon $i")
478 private fun demonstrateModelMapObjects() {
479 println("--- Model Map Objects ---")
480 if (locationWindow == null) {
481 println("LocationWindow not available yet")
485 // [kotlin_LocationWindow_addModelMapObject]
486 modelMapObject = locationWindow!!.addModelMapObject()
487 println("Added model map object: ${modelMapObject != null}")
488 // [kotlin_LocationWindow_addModelMapObject]
490 val m = modelMapObject ?: return
492 // [kotlin_ModelMapObject_setPosition]
493 val posOk = m.setPosition(GlobalPoint(12.0, 34.0))
494 println("Model setPosition: $posOk")
495 // [kotlin_ModelMapObject_setPosition]
497 // [kotlin_ModelMapObject_setPositionAnimated]
498 val posAnimOk = m.setPositionAnimated(GlobalPoint(15.0, 40.0), 0.5f, AnimationType.SINE)
499 println("Model setPositionAnimated: $posAnimOk")
500 // [kotlin_ModelMapObject_setPositionAnimated]
502 // [kotlin_ModelMapObject_setModel]
503 val texture = ImageProvider.fromFile("/path/to/model_texture.png", true)
504 val model = ModelProvider.fromFile("/path/to/model.obj", texture)
505 val modelOk = m.setModel(model)
506 println("Model setModel: $modelOk")
507 // [kotlin_ModelMapObject_setModel]
509 // [kotlin_ModelMapObject_setSize]
510 val sizeOk = m.setSize(64.0f, 64.0f)
511 println("Model setSize: $sizeOk")
512 // [kotlin_ModelMapObject_setSize]
514 // [kotlin_ModelMapObject_setCollisionEnabled]
515 println("Model setCollisionEnabled: ${m.setCollisionEnabled(true)}")
516 // [kotlin_ModelMapObject_setCollisionEnabled]
518 // [kotlin_ModelMapObject_setAngle]
519 println("Model setAngle: ${m.setAngle(Math.toRadians(45.0).toFloat())}")
520 // [kotlin_ModelMapObject_setAngle]
522 // [kotlin_ModelMapObject_setAngleAnimated]
523 println("Model setAngleAnimated: ${m.setAngleAnimated(Math.toRadians(90.0).toFloat(), 0.5f, AnimationType.QUINT)}")
524 // [kotlin_ModelMapObject_setAngleAnimated]
526 // [kotlin_ModelMapObject_setBuffer]
527 println("Model setBuffer: ${m.setBuffer(4.0f, 4.0f)}")
528 // [kotlin_ModelMapObject_setBuffer]
530 // [kotlin_ModelMapObject_setPriority]
531 println("Model setPriority: ${m.setPriority(10.0f)}")
532 // [kotlin_ModelMapObject_setPriority]
534 // [kotlin_LocationWindow_removeModelMapObject]
535 println("Removed model: ${locationWindow!!.removeModelMapObject(m)}")
536 modelMapObject = null
537 // [kotlin_LocationWindow_removeModelMapObject]
541 * Demonstrate polygon map objects
543 private fun demonstratePolygonMapObjects() {
544 println("--- Polygon Map Objects ---")
546 if (locationWindow == null) {
547 println("LocationWindow not available yet")
551 // [kotlin_LocationWindow_addPolygonMapObject]
552 // Add polygon map object
553 polygonMapObject = locationWindow!!.addPolygonMapObject()
554 println("Added polygon map object")
555 // [kotlin_LocationWindow_addPolygonMapObject]
557 if (polygonMapObject != null) {
558 // [kotlin_PolygonMapObject_setPolygon]
559 // Set polygon geometry
566 val polygon = LocationPolygon(points, 0)
567 val success = polygonMapObject!!.setPolygon(polygon)
568 println("Set polygon with ${points.size} points: $success")
569 // [kotlin_PolygonMapObject_setPolygon]
571 // [kotlin_PolygonMapObject_setColor]
573 val colorSuccess = polygonMapObject!!.setColor(0xB300FF00.toInt())
574 println("Set polygon color to green with 70% opacity: $colorSuccess")
575 // [kotlin_PolygonMapObject_setColor]
577 // [kotlin_PolygonMapObject_setOrder]
578 // Set polygon rendering order
579 val orderSuccess = polygonMapObject!!.setOrder(2)
580 println("Set polygon rendering order to 2: $orderSuccess")
581 // [kotlin_PolygonMapObject_setOrder]
583 // [kotlin_PolygonMapObject_setOutlineColor]
584 // Set polygon outline color
585 val outlineColorSuccess = polygonMapObject!!.setOutlineColor(0xFF0000FF.toInt())
586 println("Set polygon outline color to blue: $outlineColorSuccess")
587 // [kotlin_PolygonMapObject_setOutlineColor]
589 // [kotlin_PolygonMapObject_setOutlineWidth]
590 // Set polygon outline width
591 val outlineWidthSuccess = polygonMapObject!!.setOutlineWidth(2.0)
592 println("Set polygon outline width to 2.0 pixels: $outlineWidthSuccess")
593 // [kotlin_PolygonMapObject_setOutlineWidth]
595 // [kotlin_PolygonMapObject_setOutlineAlpha]
596 // Set polygon outline alpha
597 val outlineAlphaSuccess = polygonMapObject!!.setOutlineAlpha(0.8)
598 println("Set polygon outline alpha to 0.8: $outlineAlphaSuccess")
599 // [kotlin_PolygonMapObject_setOutlineAlpha]
601 // [kotlin_PolygonMapObject_setOutlineOrder]
602 // Set polygon outline order
603 val outlineOrderSuccess = polygonMapObject!!.setOutlineOrder(1)
604 println("Set polygon outline order to 1: $outlineOrderSuccess")
605 // [kotlin_PolygonMapObject_setOutlineOrder]
607 // [kotlin_PolygonMapObject_setVisible]
609 val visibleSuccess = polygonMapObject!!.setVisible(true)
610 println("Set polygon visibility to true: $visibleSuccess")
611 // [kotlin_PolygonMapObject_setVisible]
613 // [kotlin_PolygonMapObject_getMapObjectType]
614 // Get map object type
615 val objectType = polygonMapObject!!.mapObjectType
616 println("Polygon map object type: $objectType")
617 // [kotlin_PolygonMapObject_getMapObjectType]
619 // [kotlin_MapObject_setAlpha_2]
620 // Set alpha transparency
621 val alphaSuccess = polygonMapObject!!.setAlpha(0.6)
622 println("Set polygon alpha to 0.6: $alphaSuccess")
623 // [kotlin_MapObject_setAlpha_2]
625 // [kotlin_MapObject_setInteractive_2]
626 // Set interactive mode
627 val interactiveSuccess = polygonMapObject!!.setInteractive(true)
628 println("Set polygon interactive to true: $interactiveSuccess")
629 // [kotlin_MapObject_setInteractive_2]
631 // [kotlin_MapObject_setTitle_2]
633 val titleSuccess = polygonMapObject!!.setTitle("Polygon Object")
634 println("Set polygon title to 'Polygon Object': $titleSuccess")
635 // [kotlin_MapObject_setTitle_2]
637 // [kotlin_MapObject_setData_2]
639 val customData = mapOf("key" to "value", "number" to "42")
640 val dataSuccess = polygonMapObject!!.setData(customData)
641 println("Set polygon custom data: $dataSuccess")
642 // [kotlin_MapObject_setData_2]
644 // [kotlin_MapObject_getId_2]
646 val objectId = polygonMapObject!!.id
647 println("Polygon object ID: $objectId")
648 // [kotlin_MapObject_getId_2]
650 // [kotlin_MapObject_getType_2]
652 val objectTypeString = polygonMapObject!!.type
653 println("Polygon object type: $objectTypeString")
654 // [kotlin_MapObject_getType_2]
656 // [kotlin_MapObject_getData_2]
658 val retrievedData = polygonMapObject!!.data
659 println("Polygon custom data: $retrievedData")
660 // [kotlin_MapObject_getData_2]
663 // [kotlin_LocationWindow_removePolygonMapObject]
664 // Remove polygon map object
665 if (polygonMapObject != null) {
666 val removed = locationWindow!!.removePolygonMapObject(polygonMapObject!!)
667 println("Removed polygon map object: $removed")
668 polygonMapObject = null
670 // [kotlin_LocationWindow_removePolygonMapObject]
672 // Test multiple polygon objects
673 val polygons = mutableListOf<PolygonMapObject>()
675 val polygon = locationWindow!!.addPolygonMapObject()
676 if (polygon != null) {
678 Point(300.0 + i * 50, 400.0 + i * 50),
679 Point(350.0 + i * 50, 450.0 + i * 50),
680 Point(400.0 + i * 50, 400.0 + i * 50),
681 Point(350.0 + i * 50, 350.0 + i * 50)
683 val polygonGeometry = LocationPolygon(points, 0)
684 polygon.setPolygon(polygonGeometry)
685 polygon.setColor(0x800000FF.toInt())
686 polygons.add(polygon)
687 println("Created polygon $i with ${points.size} points")
691 for (i in polygons.indices) {
692 locationWindow!!.removePolygonMapObject(polygons[i])
693 println("Removed polygon $i")
698 * Demonstrate polyline map objects
700 private fun demonstratePolylineMapObjects() {
701 println("--- Polyline Map Objects ---")
703 if (locationWindow == null) {
704 println("LocationWindow not available yet")
708 // [kotlin_PolylineMapObject_constructor]
709 // Create polyline map object
716 val polyline = LocationPolyline(points, 0)
717 polylineMapObject = locationWindow!!.addPolylineMapObject()
718 println("Created polyline map object with ${points.size} points")
719 // [kotlin_PolylineMapObject_constructor]
721 // [kotlin_PolylineMapObject_getPolyline]
723 val polylineShape = polylineMapObject!!.getPolyLine()
724 println("Polyline has ${polylineShape.points.size} points")
725 // [kotlin_PolylineMapObject_getPolyline]
727 // [kotlin_LocationWindow_addPolylineMapObject]
728 // Add polyline map object
729 polylineMapObject = locationWindow!!.addPolylineMapObject()
730 println("Added polyline map object")
731 // [kotlin_LocationWindow_addPolylineMapObject]
733 if (polylineMapObject != null) {
734 // [kotlin_PolylineMapObject_setPolyLine]
735 // Set polyline geometry
742 val polyline = LocationPolyline(points, 0)
743 val success = polylineMapObject!!.setPolyLine(polyline)
744 println("Set polyline with ${points.size} points: $success")
745 // [kotlin_PolylineMapObject_setPolyLine]
747 // [kotlin_PolylineMapObject_setWidth]
748 // Set polyline width
749 val widthSuccess = polylineMapObject!!.setWidth(3.0)
750 println("Set polyline width to 3.0 pixels: $widthSuccess")
751 // [kotlin_PolylineMapObject_setWidth]
753 // [kotlin_PolylineMapObject_setColor]
754 // Set polyline color
755 val colorSuccess = polylineMapObject!!.setColor(0xCC00FF00.toInt())
756 println("Set polyline color to green with 80% opacity: $colorSuccess")
757 // [kotlin_PolylineMapObject_setColor]
759 // [kotlin_PolylineMapObject_setOrder]
760 // Set polyline rendering order
761 val orderSuccess = polylineMapObject!!.setOrder(1)
762 println("Set polyline rendering order to 1: $orderSuccess")
763 // [kotlin_PolylineMapObject_setOrder]
765 // [kotlin_PolylineMapObject_setCapType]
766 // Set polyline cap type
767 val capTypeSuccess = polylineMapObject!!.setCapType(CapType.ROUND)
768 println("Set polyline cap type to ROUND: $capTypeSuccess")
769 // [kotlin_PolylineMapObject_setCapType]
771 // [kotlin_PolylineMapObject_setJoinType]
772 // Set polyline join type
773 val joinTypeSuccess = polylineMapObject!!.setJoinType(JoinType.ROUND)
774 println("Set polyline join type to ROUND: $joinTypeSuccess")
775 // [kotlin_PolylineMapObject_setJoinType]
777 // [kotlin_PolylineMapObject_setMiterLimit]
778 // Set polyline miter limit
779 val miterLimitSuccess = polylineMapObject!!.setMiterLimit(2.0)
780 println("Set polyline miter limit to 2.0: $miterLimitSuccess")
781 // [kotlin_PolylineMapObject_setMiterLimit]
783 // [kotlin_PolylineMapObject_setOutlineWidth]
784 // Set polyline outline width
785 val outlineWidthSuccess = polylineMapObject!!.setOutlineWidth(1.0)
786 println("Set polyline outline width to 1.0 pixels: $outlineWidthSuccess")
787 // [kotlin_PolylineMapObject_setOutlineWidth]
789 // [kotlin_PolylineMapObject_setOutlineColor]
790 // Set polyline outline color
791 val outlineColorSuccess = polylineMapObject!!.setOutlineColor(0xFF000000.toInt())
792 println("Set polyline outline color to black: $outlineColorSuccess")
793 // [kotlin_PolylineMapObject_setOutlineColor]
795 // [kotlin_PolylineMapObject_setOutlineAlpha]
796 // Set polyline outline alpha
797 val outlineAlphaSuccess = polylineMapObject!!.setOutlineAlpha(0.5)
798 println("Set polyline outline alpha to 0.5: $outlineAlphaSuccess")
799 // [kotlin_PolylineMapObject_setOutlineAlpha]
801 // [kotlin_PolylineMapObject_setOutlineOrder]
802 // Set polyline outline rendering order
803 val outlineOrderSuccess = polylineMapObject!!.setOutlineOrder(0)
804 println("Set polyline outline rendering order to 0: $outlineOrderSuccess")
805 // [kotlin_PolylineMapObject_setOutlineOrder]
807 // [kotlin_PolylineMapObject_setOutlineCapType]
808 // Set polyline outline cap type
809 val outlineCapTypeSuccess = polylineMapObject!!.setOutlineCapType(CapType.SQUARE)
810 println("Set polyline outline cap type to SQUARE: $outlineCapTypeSuccess")
811 // [kotlin_PolylineMapObject_setOutlineCapType]
813 // [kotlin_PolylineMapObject_setOutlineJoinType]
814 // Set polyline outline join type
815 val outlineJoinTypeSuccess = polylineMapObject!!.setOutlineJoinType(JoinType.MITER)
816 println("Set polyline outline join type to MITER: $outlineJoinTypeSuccess")
817 // [kotlin_PolylineMapObject_setOutlineJoinType]
819 // [kotlin_PolylineMapObject_setOutlineMiterLimit]
820 // Set polyline outline miter limit
821 val outlineMiterLimitSuccess = polylineMapObject!!.setOutlineMiterLimit(3.0)
822 println("Set polyline outline miter limit to 3.0: $outlineMiterLimitSuccess")
823 // [kotlin_PolylineMapObject_setOutlineMiterLimit]
825 // [kotlin_PolylineMapObject_setVisible]
827 val visibleSuccess = polylineMapObject!!.setVisible(true)
828 println("Set polyline visibility to true: $visibleSuccess")
829 // [kotlin_PolylineMapObject_setVisible]
831 // [kotlin_PolylineMapObject_getMapObjectType]
832 // Get map object type
833 val objectType = polylineMapObject!!.mapObjectType
834 println("Polyline map object type: $objectType")
835 // [kotlin_PolylineMapObject_getMapObjectType]
837 // [kotlin_MapObject_setAlpha_3]
838 // Set alpha transparency
839 val alphaSuccess = polylineMapObject!!.setAlpha(0.7)
840 println("Set polyline alpha to 0.7: $alphaSuccess")
841 // [kotlin_MapObject_setAlpha_3]
843 // [kotlin_MapObject_setInteractive_3]
844 // Set interactive mode
845 val interactiveSuccess = polylineMapObject!!.setInteractive(true)
846 println("Set polyline interactive to true: $interactiveSuccess")
847 // [kotlin_MapObject_setInteractive_3]
849 // [kotlin_MapObject_setTitle_3]
851 val titleSuccess = polylineMapObject!!.setTitle("Polyline Object")
852 println("Set polyline title to 'Polyline Object': $titleSuccess")
853 // [kotlin_MapObject_setTitle_3]
855 // [kotlin_MapObject_setData_3]
857 val customData = mapOf("key" to "value", "number" to "42")
858 val dataSuccess = polylineMapObject!!.setData(customData)
859 println("Set polyline custom data: $dataSuccess")
860 // [kotlin_MapObject_setData_3]
862 // [kotlin_MapObject_getId_3]
864 val objectId = polylineMapObject!!.id
865 println("Polyline object ID: $objectId")
866 // [kotlin_MapObject_getId_3]
868 // [kotlin_MapObject_getType_3]
870 val objectTypeString = polylineMapObject!!.type
871 println("Polyline object type: $objectTypeString")
872 // [kotlin_MapObject_getType_3]
874 // [kotlin_MapObject_getData_3]
876 val retrievedData = polylineMapObject!!.data
877 println("Polyline custom data: $retrievedData")
878 // [kotlin_MapObject_getData_3]
881 // [kotlin_LocationWindow_removePolylineMapObject]
882 // Remove polyline map object
883 if (polylineMapObject != null) {
884 val removed = locationWindow!!.removePolylineMapObject(polylineMapObject!!)
885 println("Removed polyline map object: $removed")
886 polylineMapObject = null
888 // [kotlin_LocationWindow_removePolylineMapObject]
890 // Test multiple polyline objects
891 val polylines = mutableListOf<PolylineMapObject>()
893 val polyline = locationWindow!!.addPolylineMapObject()
894 if (polyline != null) {
896 Point(120.0 + i * 30, 130.0 + i * 30),
897 Point(125.0 + i * 30, 135.0 + i * 30),
898 Point(130.0 + i * 30, 140.0 + i * 30)
900 val polylineGeometry = LocationPolyline(points, 0)
901 polyline.setPolyLine(polylineGeometry)
902 polyline.setColor(0x99FF0000.toInt())
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 polyline = LocationPolyline(points, 0)
935 dottedPolylineMapObject = locationWindow!!.addDottedPolylineMapObject()
936 println("Created dotted polyline map object with ${points.size} points")
937 // [kotlin_DottedPolylineMapObject_constructor]
939 // [kotlin_DottedPolylineMapObject_getPolyline]
940 // Access dotted polyline
941 val dottedPolylineShape = dottedPolylineMapObject!!.getPolyLine()
942 println("Dotted polyline has ${dottedPolylineShape.points.size} points")
943 // [kotlin_DottedPolylineMapObject_getPolyline]
945 // [kotlin_LocationWindow_addDottedPolylineMapObject]
946 // Add dotted polyline map object
947 dottedPolylineMapObject = locationWindow!!.addDottedPolylineMapObject()
948 println("Added dotted polyline map object")
949 // [kotlin_LocationWindow_addDottedPolylineMapObject]
951 if (dottedPolylineMapObject != null) {
952 // [kotlin_DottedPolylineMapObject_setPolyline]
953 // Set dotted polyline geometry
960 val polyline = LocationPolyline(points, 0)
961 val success = dottedPolylineMapObject!!.setPolyline(polyline)
962 println("Set dotted polyline with ${points.size} points: $success")
963 // [kotlin_DottedPolylineMapObject_setPolyline]
965 // [kotlin_DottedPolylineMapObject_setColor]
966 // Set dotted polyline color
967 val colorSuccess = dottedPolylineMapObject!!.setColor(0xCC8000FF.toInt())
968 println("Set dotted polyline color to purple with 80% opacity: $colorSuccess")
969 // [kotlin_DottedPolylineMapObject_setColor]
971 // [kotlin_DottedPolylineMapObject_setWidth]
972 // Set dotted polyline width
973 val widthSuccess = dottedPolylineMapObject!!.setWidth(3.0)
974 println("Set dotted polyline width to 3.0 pixels: $widthSuccess")
975 // [kotlin_DottedPolylineMapObject_setWidth]
977 // [kotlin_DottedPolylineMapObject_setOrder]
978 // Set dotted polyline rendering order
979 val orderSuccess = dottedPolylineMapObject!!.setOrder(2)
980 println("Set dotted polyline rendering order to 2: $orderSuccess")
981 // [kotlin_DottedPolylineMapObject_setOrder]
983 // [kotlin_DottedPolylineMapObject_setCollisionEnabled]
984 // Enable collision detection
985 val collisionSuccess = dottedPolylineMapObject!!.setCollisionEnabled(true)
986 println("Enabled collision detection for dotted polyline: $collisionSuccess")
987 // [kotlin_DottedPolylineMapObject_setCollisionEnabled]
989 // [kotlin_DottedPolylineMapObject_setPlacement]
990 // Set placement type
991 val placementSuccess = dottedPolylineMapObject!!.setPlacement(Placement.CENTER)
992 println("Set dotted polyline placement to CENTER: $placementSuccess")
993 // [kotlin_DottedPolylineMapObject_setPlacement]
995 // [kotlin_DottedPolylineMapObject_setPlacementMinRatio]
996 // Set placement min ratio
997 val minRatioSuccess = dottedPolylineMapObject!!.setPlacementMinRatio(0.5)
998 println("Set dotted polyline placement min ratio to 0.5: $minRatioSuccess")
999 // [kotlin_DottedPolylineMapObject_setPlacementMinRatio]
1001 // [kotlin_DottedPolylineMapObject_setPlacementSpacing]
1002 // Set placement spacing
1003 val spacingSuccess = dottedPolylineMapObject!!.setPlacementSpacing(10.0)
1004 println("Set dotted polyline placement spacing to 10.0: $spacingSuccess")
1005 // [kotlin_DottedPolylineMapObject_setPlacementSpacing]
1007 // [kotlin_DottedPolylineMapObject_setPriority]
1008 // Set rendering priority
1009 val prioritySuccess = dottedPolylineMapObject!!.setPriority(1)
1010 println("Set dotted polyline rendering priority to 1: $prioritySuccess")
1011 // [kotlin_DottedPolylineMapObject_setPriority]
1013 // [kotlin_DottedPolylineMapObject_setRepeatDistance]
1014 // Set repeat distance
1015 val repeatDistanceSuccess = dottedPolylineMapObject!!.setRepeatDistance(20.0)
1016 println("Set dotted polyline repeat distance to 20.0: $repeatDistanceSuccess")
1017 // [kotlin_DottedPolylineMapObject_setRepeatDistance]
1019 // [kotlin_DottedPolylineMapObject_setRepeatGroup]
1021 val repeatGroupSuccess = dottedPolylineMapObject!!.setRepeatGroup(1)
1022 println("Set dotted polyline repeat group to 1: $repeatGroupSuccess")
1023 // [kotlin_DottedPolylineMapObject_setRepeatGroup]
1025 // [kotlin_DottedPolylineMapObject_setSize]
1027 val size = Size(16.0, 16.0)
1028 val sizeSuccess = dottedPolylineMapObject!!.setSize(size)
1029 println("Set dotted polyline size to (${size.width}, ${size.height}): $sizeSuccess")
1030 // [kotlin_DottedPolylineMapObject_setSize]
1032 // [kotlin_DottedPolylineMapObject_setVisible]
1034 val visibleSuccess = dottedPolylineMapObject!!.setVisible(true)
1035 println("Set dotted polyline visibility to true: $visibleSuccess")
1036 // [kotlin_DottedPolylineMapObject_setVisible]
1038 // [kotlin_DottedPolylineMapObject_getMapObjectType]
1039 // Get map object type
1040 val objectType = dottedPolylineMapObject!!.mapObjectType
1041 println("Dotted polyline map object type: $objectType")
1042 // [kotlin_DottedPolylineMapObject_getMapObjectType]
1044 // [kotlin_MapObject_setAlpha_4]
1045 // Set alpha transparency
1046 val alphaSuccess = dottedPolylineMapObject!!.setAlpha(0.8)
1047 println("Set dotted polyline alpha to 0.8: $alphaSuccess")
1048 // [kotlin_MapObject_setAlpha_4]
1050 // [kotlin_MapObject_setInteractive_4]
1051 // Set interactive mode
1052 val interactiveSuccess = dottedPolylineMapObject!!.setInteractive(true)
1053 println("Set dotted polyline interactive to true: $interactiveSuccess")
1054 // [kotlin_MapObject_setInteractive_4]
1056 // [kotlin_MapObject_setTitle_4]
1058 val titleSuccess = dottedPolylineMapObject!!.setTitle("Dotted Polyline Object")
1059 println("Set dotted polyline title to 'Dotted Polyline Object': $titleSuccess")
1060 // [kotlin_MapObject_setTitle_4]
1062 // [kotlin_MapObject_setData_4]
1064 val customData = mapOf("key" to "value", "number" to "42")
1065 val dataSuccess = dottedPolylineMapObject!!.setData(customData)
1066 println("Set dotted polyline custom data: $dataSuccess")
1067 // [kotlin_MapObject_setData_4]
1069 // [kotlin_MapObject_getId_4]
1071 val objectId = dottedPolylineMapObject!!.id
1072 println("Dotted polyline object ID: $objectId")
1073 // [kotlin_MapObject_getId_4]
1075 // [kotlin_MapObject_getType_4]
1077 val objectTypeString = dottedPolylineMapObject!!.type
1078 println("Dotted polyline object type: $objectTypeString")
1079 // [kotlin_MapObject_getType_4]
1081 // [kotlin_MapObject_getData_4]
1083 val retrievedData = dottedPolylineMapObject!!.data
1084 println("Dotted polyline custom data: $retrievedData")
1085 // [kotlin_MapObject_getData_4]
1088 // [kotlin_LocationWindow_removeDottedPolylineMapObject]
1089 // Remove dotted polyline map object
1090 if (dottedPolylineMapObject != null) {
1091 val removed = locationWindow!!.removeDottedPolylineMapObject(dottedPolylineMapObject!!)
1092 println("Removed dotted polyline map object: $removed")
1093 dottedPolylineMapObject = null
1095 // [kotlin_LocationWindow_removeDottedPolylineMapObject]
1097 // Test multiple dotted polyline objects
1098 val dottedPolylines = mutableListOf<DottedPolylineMapObject>()
1100 val dottedPolyline = locationWindow!!.addDottedPolylineMapObject()
1101 if (dottedPolyline != null) {
1102 val points = listOf(
1103 Point(180.0 + i * 30, 190.0 + i * 30),
1104 Point(185.0 + i * 30, 195.0 + i * 30),
1105 Point(190.0 + i * 30, 200.0 + i * 30)
1107 val polylineGeometry = LocationPolyline(points, 0)
1108 dottedPolyline.setPolyline(polylineGeometry)
1109 dottedPolylines.add(dottedPolyline)
1110 println("Created dotted polyline $i with ${points.size} points")
1114 for (i in dottedPolylines.indices) {
1115 locationWindow!!.removeDottedPolylineMapObject(dottedPolylines[i])
1116 println("Removed dotted polyline $i")
1121 * Demonstrate icon clustering via ClusterMapObjectController.
1123 private fun demonstrateClusterMapObjects() {
1124 println("--- Cluster map objects ---")
1126 if (locationWindow == null) {
1127 println("LocationWindow not available")
1131 // [kotlin_LocationWindow_addClusterMapObjectController]
1132 clusterMapObjectController = locationWindow!!.addClusterMapObjectController()
1133 println("Added cluster map object controller")
1134 // [kotlin_LocationWindow_addClusterMapObjectController]
1136 val controller = clusterMapObjectController ?: return
1138 val clusterIcon1 = locationWindow!!.addIconMapObject()
1139 val clusterIcon2 = locationWindow!!.addIconMapObject()
1140 clusterIcon1?.setPosition(GlobalPoint(100.0, 100.0))
1141 clusterIcon2?.setPosition(GlobalPoint(105.0, 102.0))
1143 // [kotlin_ClusterMapObjectController_addIconMapObject]
1144 val added1 = controller.addIconMapObject(clusterIcon1)
1145 val added2 = controller.addIconMapObject(clusterIcon2)
1146 println("Registered icons for clustering: $added1, $added2")
1147 // [kotlin_ClusterMapObjectController_addIconMapObject]
1149 // [kotlin_ClusterMapObjectController_setEnabled]
1150 controller.setEnabled(true)
1151 println("Clustering enabled")
1152 // [kotlin_ClusterMapObjectController_setEnabled]
1154 // [kotlin_ClusterMapObjectController_isEnabled]
1155 val clusteringEnabled = controller.isEnabled
1156 println("Clustering is enabled: $clusteringEnabled")
1157 // [kotlin_ClusterMapObjectController_isEnabled]
1159 // [kotlin_ClusterMapObjectController_setRadius]
1160 controller.setRadius(40.0f)
1161 println("Set cluster radius to 40 px")
1162 // [kotlin_ClusterMapObjectController_setRadius]
1164 // [kotlin_ClusterMapObjectController_getRadius]
1165 val clusterRadius = controller.getRadius()
1166 println("Cluster radius: $clusterRadius")
1167 // [kotlin_ClusterMapObjectController_getRadius]
1169 // [kotlin_ClusterMapObjectController_setInteractive]
1170 val interactiveSuccess = controller.setInteractive(true)
1171 println("Set cluster markers interactive: $interactiveSuccess")
1172 // [kotlin_ClusterMapObjectController_setInteractive]
1174 // [kotlin_ClusterMapObjectController_setClusterSize]
1175 val sizeSuccess = controller.setClusterSize(32.0f, 32.0f)
1176 println("Set default cluster icon size: $sizeSuccess")
1177 // [kotlin_ClusterMapObjectController_setClusterSize]
1179 clusterMapObjectControllerListener = DemoClusterMapObjectControllerListener()
1181 // [kotlin_ClusterMapObjectController_addListener]
1182 controller.addListener(clusterMapObjectControllerListener!!)
1183 println("Added cluster map object listener")
1184 // [kotlin_ClusterMapObjectController_addListener]
1186 // [kotlin_ClusterMapObjectController_getClusters]
1187 val clusters = controller.getClusters()
1188 println("Visible clusters: ${clusters.size}")
1189 // [kotlin_ClusterMapObjectController_getClusters]
1191 if (clusters.isNotEmpty()) {
1192 val cluster = clusters[0]
1193 // [kotlin_ClusterMapObject_setBitmap]
1194 val clusterBitmap = ImageProvider.fromFile("/path/to/cluster.png", true)
1195 val bitmapSuccess = cluster.setBitmap(clusterBitmap)
1196 println("Set cluster bitmap from ImageProvider: $bitmapSuccess")
1197 // [kotlin_ClusterMapObject_setBitmap]
1200 // [kotlin_ClusterMapObjectController_removeListener]
1201 controller.removeListener(clusterMapObjectControllerListener!!)
1202 println("Removed cluster map object listener")
1203 // [kotlin_ClusterMapObjectController_removeListener]
1206 // [kotlin_ClusterMapObjectController_removeIconMapObject]
1207 val removed = controller.removeIconMapObject(it)
1208 println("Removed icon from cluster controller: $removed")
1209 // [kotlin_ClusterMapObjectController_removeIconMapObject]
1210 locationWindow!!.removeIconMapObject(it)
1212 clusterIcon2?.let { locationWindow!!.removeIconMapObject(it) }
1214 // [kotlin_ClusterMapObjectController_clear]
1216 println("Cleared cluster controller")
1217 // [kotlin_ClusterMapObjectController_clear]
1219 // [kotlin_LocationWindow_removeClusterMapObjectController]
1220 val controllerRemoved =
1221 locationWindow!!.removeClusterMapObjectController(controller)
1222 println("Removed cluster map object controller: $controllerRemoved")
1223 // [kotlin_LocationWindow_removeClusterMapObjectController]
1225 clusterMapObjectController = null
1226 clusterMapObjectControllerListener = null
1230 * Demonstrate remove all map objects
1232 private fun demonstrateRemoveAllMapObjects() {
1233 println("--- Remove All Map Objects ---")
1235 if (locationWindow == null) {
1236 println("LocationWindow not available yet")
1240 println("Current map objects count: ${getMapObjectsCount()}")
1242 // [kotlin_LocationWindow_removeAllMapObjects]
1243 // Remove all map objects
1244 locationWindow!!.removeAllMapObjects()
1245 println("Removed all map objects")
1246 // [kotlin_LocationWindow_removeAllMapObjects]
1248 println("Map objects count after removal: ${getMapObjectsCount()}")
1252 * Get current map objects count
1254 private fun getMapObjectsCount(): Int {
1256 if (circleMapObject != null) count++
1257 if (iconMapObject != null) count++
1258 if (polygonMapObject != null) count++
1259 if (polylineMapObject != null) count++
1260 if (dottedPolylineMapObject != null) count++
1267 private fun cleanup() {
1268 println("--- Cleanup ---")
1270 if (locationWindow != null) {
1271 locationWindow!!.removeAllMapObjects()
1272 println("Cleaned up all map objects")
1275 circleMapObject = null
1276 iconMapObject = null
1277 modelMapObject = null
1278 polygonMapObject = null
1279 polylineMapObject = null
1280 dottedPolylineMapObject = null
1281 println("Cleared map objects references")
1285class DemoClusterMapObjectControllerListener : ClusterMapObjectControllerListener {
1286 private val clusterChangeListener = DemoClusterMapObjectListener()
1287 private var activeCluster: ClusterMapObject? = null
1289 // [kotlin_ClusterMapObjectControllerListener_onClusterCreated]
1290 override fun onClusterCreated(controller: ClusterMapObjectController, cluster: ClusterMapObject) {
1291 // [kotlin_ClusterMapObject_addListener]
1292 cluster.addListener(clusterChangeListener)
1293 println("Added cluster change listener, initial count: ${cluster.count}")
1294 // [kotlin_ClusterMapObject_addListener]
1295 activeCluster = cluster
1297 // [kotlin_ClusterMapObjectControllerListener_onClusterCreated]
1299 // [kotlin_ClusterMapObjectControllerListener_onClusterDestroyed]
1300 override fun onClusterDestroyed(controller: ClusterMapObjectController, clusterId: Int) {
1301 val cluster = activeCluster
1302 if (cluster != null && cluster.id == clusterId) {
1303 // [kotlin_ClusterMapObject_removeListener]
1304 cluster.removeListener(clusterChangeListener)
1305 println("Removed cluster change listener")
1306 // [kotlin_ClusterMapObject_removeListener]
1307 activeCluster = null
1309 println("Cluster destroyed, id: $clusterId")
1311 // [kotlin_ClusterMapObjectControllerListener_onClusterDestroyed]
1314class DemoClusterMapObjectListener : ClusterMapObjectListener {
1316 // [kotlin_ClusterMapObjectListener_onClusterChanged]
1317 override fun onClusterChanged(cluster: ClusterMapObject) {
1318 val memberCount = cluster.getCount()
1319 println("Cluster changed, member count: $memberCount")
1321 // [kotlin_ClusterMapObjectListener_onClusterChanged]
1324// Main function to run the example
1326 LocationWindowMapObjectsExample()