Loading...
Searching...
No Matches
LocationWindowMapObjectsExample.kt
Go to the documentation of this file.
1package com.navigine.examples
2
3import com.navigine.image.ImageProvider
4import com.navigine.idl.kotlin.ModelMapObject
5import com.navigine.model.ModelProvider
6
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
30
31/**
32 * LocationWindowMapObjects usage example for Kotlin
33 * Demonstrates specific methods: addCircleMapObject, removeCircleMapObject, addIconMapObject,
34 * removeIconMapObject, addPolygonMapObject, addPolylineMapObject, removePolylineMapObject,
35 * addDottedPolylineMapObject, removeDottedPolylineMapObject, removeAllMapObjects
36 */
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
47
48 init {
49 demonstrateLocationWindowMapObjectsMethods()
50 }
51
52 /**
53 * Demonstrate LocationWindowMapObjects methods
54 */
55 private fun demonstrateLocationWindowMapObjectsMethods() {
56 println("=== LocationWindowMapObjects Example ===")
57
58 // Initialize LocationWindow (in real app, this would be provided by the framework)
59 // locationWindow = getLocationWindow()
60
61 demonstrateLocationScopedGeometryRecords()
62
63 demonstrateCircleMapObjects()
64 demonstrateIconMapObjects()
65 demonstrateClusterMapObjects()
66 demonstrateModelMapObjects()
67 demonstratePolygonMapObjects()
68 demonstratePolylineMapObjects()
69 demonstrateDottedPolylineMapObjects()
70 demonstrateRemoveAllMapObjects()
71
72 cleanup()
73 }
74
75 /**
76 * Metrics geometry scoped to a location / sublocation (@see LocationPolygon, LocationPolyline).
77 */
78 private fun demonstrateLocationScopedGeometryRecords() {
79 println("--- LocationPolygon / LocationPolyline records ---")
80
81 // [kotlin_LocationPolygon_record]
82 val ring = listOf(
83 GlobalPoint(55.751, 37.617),
84 GlobalPoint(55.752, 37.618),
85 GlobalPoint(55.751, 37.619)
86 )
87 val locationPolygon = LocationPolygon(ring, 7)
88 val polygonSublocationId = locationPolygon.sublocationId
89 println("LocationPolygon: sublocation $polygonSublocationId, vertices ${locationPolygon.points.size}")
90 // [kotlin_LocationPolygon_record]
91
92 // [kotlin_LocationPolyline_record]
93 val linePoints = listOf(
94 GlobalPoint(55.751, 37.617),
95 GlobalPoint(55.753, 37.620)
96 )
97 val locationPolyline = LocationPolyline(linePoints, 7)
98 println("LocationPolyline: points ${locationPolyline.points.size}")
99 // [kotlin_LocationPolyline_record]
100 }
101
102 /**
103 * Demonstrate circle map objects
104 */
105 private fun demonstrateCircleMapObjects() {
106 println("--- Circle Map Objects ---")
107
108 if (locationWindow == null) {
109 println("LocationWindow not available yet")
110 return
111 }
112
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]
119
120 // [kotlin_CircleMapObject_getRadius]
121 // Access circle radius
122 val radius = circleMapObject!!.getRadius()
123 println("Circle radius: $radius")
124 // [kotlin_CircleMapObject_getRadius]
125
126 // [kotlin_LocationWindow_addCircleMapObject]
127 // Add circle map object
128 circleMapObject = locationWindow!!.addCircleMapObject()
129 println("Added circle map object")
130 // [kotlin_LocationWindow_addCircleMapObject]
131
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]
139
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]
146
147 // [kotlin_CircleMapObject_setRadius]
148 // Set circle radius
149 val radiusSuccess = circleMapObject!!.setRadius(10.0)
150 println("Set circle radius to 10.0 meters: $radiusSuccess")
151 // [kotlin_CircleMapObject_setRadius]
152
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]
158
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]
164
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]
170
171 // [kotlin_CircleMapObject_setOutlineColor]
172 // Set outline color
173 val outlineColorSuccess = circleMapObject!!.setOutlineColor(0xFF0000FF.toInt())
174 println("Set circle outline color to blue: $outlineColorSuccess")
175 // [kotlin_CircleMapObject_setOutlineColor]
176
177 // [kotlin_CircleMapObject_setOutlineAlpha]
178 // Set outline alpha
179 val outlineAlphaSuccess = circleMapObject!!.setOutlineAlpha(0.5)
180 println("Set circle outline alpha to 0.5: $outlineAlphaSuccess")
181 // [kotlin_CircleMapObject_setOutlineAlpha]
182
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]
188
189 // [kotlin_CircleMapObject_setColor]
190 // Set circle color
191 val colorSuccess = circleMapObject!!.setColor(0xCCFF0000.toInt())
192 println("Set circle color to red with 80% opacity: $colorSuccess")
193 // [kotlin_CircleMapObject_setColor]
194
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]
200
201 // [kotlin_MapObject_setVisible]
202 // Set visibility
203 val visibleSuccess = circleMapObject!!.setVisible(true)
204 println("Set circle visibility to true: $visibleSuccess")
205 // [kotlin_MapObject_setVisible]
206
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]
212
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]
218
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]
224
225 // [kotlin_MapObject_setTitle]
226 // Set title
227 val titleSuccess = circleMapObject!!.setTitle("Circle Object")
228 println("Set circle title to 'Circle Object': $titleSuccess")
229 // [kotlin_MapObject_setTitle]
230
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]
239
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]
245
246 // [kotlin_MapObject_setData]
247 // Set custom data
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]
252
253 // [kotlin_MapObject_getId]
254 // Get object ID
255 val objectId = circleMapObject!!.id
256 println("Circle object ID: $objectId")
257 // [kotlin_MapObject_getId]
258
259 // [kotlin_MapObject_getType]
260 // Get object type
261 val objectTypeString = circleMapObject!!.type
262 println("Circle object type: $objectTypeString")
263 // [kotlin_MapObject_getType]
264
265 // [kotlin_MapObject_getData]
266 // Get custom data
267 val retrievedData = circleMapObject!!.data
268 println("Circle custom data: $retrievedData")
269 // [kotlin_MapObject_getData]
270 }
271
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
278 }
279 // [kotlin_LocationWindow_removeCircleMapObject]
280
281 // Test multiple circle objects
282 val circles = mutableListOf<CircleMapObject>()
283 for (i in 0..2) {
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)
289 circles.add(circle)
290 println("Created circle $i at (${50.0 * i}, ${100.0 * i}) with radius ${5.0 + i * 2.0}")
291 }
292 }
293
294 for (i in circles.indices) {
295 locationWindow!!.removeCircleMapObject(circles[i])
296 println("Removed circle $i")
297 }
298 }
299
300 /**
301 * Demonstrate icon map objects
302 */
303 private fun demonstrateIconMapObjects() {
304 println("--- Icon Map Objects ---")
305
306 if (locationWindow == null) {
307 println("LocationWindow not available yet")
308 return
309 }
310
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]
317
318 // [kotlin_LocationWindow_addIconMapObject]
319 // Add icon map object
320 iconMapObject = locationWindow!!.addIconMapObject()
321 println("Added icon map object")
322 // [kotlin_LocationWindow_addIconMapObject]
323
324 if (iconMapObject != null) {
325 // [kotlin_IconMapObject_setPosition]
326 // Set icon position
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]
331
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]
338
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]
344
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]
350
351 // [kotlin_IconMapObject_setSize]
352 // Set icon size
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]
357
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]
363
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]
369
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]
375
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]
381
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]
387
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]
393
394 // [kotlin_IconMapObject_setVisible]
395 // Set visibility
396 val visibleSuccess = iconMapObject!!.setVisible(true)
397 println("Set icon visibility to true: $visibleSuccess")
398 // [kotlin_IconMapObject_setVisible]
399
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]
405
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]
411
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]
417
418 // [kotlin_MapObject_setTitle_1]
419 // Set title
420 val titleSuccess = iconMapObject!!.setTitle("Icon Object")
421 println("Set icon title to 'Icon Object': $titleSuccess")
422 // [kotlin_MapObject_setTitle_1]
423
424 // [kotlin_MapObject_setData_1]
425 // Set custom data
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]
430
431 // [kotlin_MapObject_getId_1]
432 // Get object ID
433 val objectId = iconMapObject!!.id
434 println("Icon object ID: $objectId")
435 // [kotlin_MapObject_getId_1]
436
437 // [kotlin_MapObject_getType_1]
438 // Get object type
439 val objectTypeString = iconMapObject!!.type
440 println("Icon object type: $objectTypeString")
441 // [kotlin_MapObject_getType_1]
442
443 // [kotlin_MapObject_getData_1]
444 // Get custom data
445 val retrievedData = iconMapObject!!.data
446 println("Icon custom data: $retrievedData")
447 // [kotlin_MapObject_getData_1]
448 }
449
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")
455 iconMapObject = null
456 }
457 // [kotlin_LocationWindow_removeIconMapObject]
458
459 // Test multiple icon objects
460 val icons = mutableListOf<IconMapObject>()
461 for (i in 0..2) {
462 val icon = locationWindow!!.addIconMapObject()
463 if (icon != null) {
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))
467 icons.add(icon)
468 println("Created icon $i at (${60.0 * i}, ${120.0 * i})")
469 }
470 }
471
472 for (i in icons.indices) {
473 locationWindow!!.removeIconMapObject(icons[i])
474 println("Removed icon $i")
475 }
476 }
477
478 private fun demonstrateModelMapObjects() {
479 println("--- Model Map Objects ---")
480 if (locationWindow == null) {
481 println("LocationWindow not available yet")
482 return
483 }
484
485 // [kotlin_LocationWindow_addModelMapObject]
486 modelMapObject = locationWindow!!.addModelMapObject()
487 println("Added model map object: ${modelMapObject != null}")
488 // [kotlin_LocationWindow_addModelMapObject]
489
490 val m = modelMapObject ?: return
491
492 // [kotlin_ModelMapObject_setPosition]
493 val posOk = m.setPosition(GlobalPoint(12.0, 34.0))
494 println("Model setPosition: $posOk")
495 // [kotlin_ModelMapObject_setPosition]
496
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]
501
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]
508
509 // [kotlin_ModelMapObject_setSize]
510 val sizeOk = m.setSize(64.0f, 64.0f)
511 println("Model setSize: $sizeOk")
512 // [kotlin_ModelMapObject_setSize]
513
514 // [kotlin_ModelMapObject_setCollisionEnabled]
515 println("Model setCollisionEnabled: ${m.setCollisionEnabled(true)}")
516 // [kotlin_ModelMapObject_setCollisionEnabled]
517
518 // [kotlin_ModelMapObject_setAngle]
519 println("Model setAngle: ${m.setAngle(Math.toRadians(45.0).toFloat())}")
520 // [kotlin_ModelMapObject_setAngle]
521
522 // [kotlin_ModelMapObject_setAngleAnimated]
523 println("Model setAngleAnimated: ${m.setAngleAnimated(Math.toRadians(90.0).toFloat(), 0.5f, AnimationType.QUINT)}")
524 // [kotlin_ModelMapObject_setAngleAnimated]
525
526 // [kotlin_ModelMapObject_setBuffer]
527 println("Model setBuffer: ${m.setBuffer(4.0f, 4.0f)}")
528 // [kotlin_ModelMapObject_setBuffer]
529
530 // [kotlin_ModelMapObject_setPriority]
531 println("Model setPriority: ${m.setPriority(10.0f)}")
532 // [kotlin_ModelMapObject_setPriority]
533
534 // [kotlin_LocationWindow_removeModelMapObject]
535 println("Removed model: ${locationWindow!!.removeModelMapObject(m)}")
536 modelMapObject = null
537 // [kotlin_LocationWindow_removeModelMapObject]
538 }
539
540 /**
541 * Demonstrate polygon map objects
542 */
543 private fun demonstratePolygonMapObjects() {
544 println("--- Polygon Map Objects ---")
545
546 if (locationWindow == null) {
547 println("LocationWindow not available yet")
548 return
549 }
550
551 // [kotlin_LocationWindow_addPolygonMapObject]
552 // Add polygon map object
553 polygonMapObject = locationWindow!!.addPolygonMapObject()
554 println("Added polygon map object")
555 // [kotlin_LocationWindow_addPolygonMapObject]
556
557 if (polygonMapObject != null) {
558 // [kotlin_PolygonMapObject_setPolygon]
559 // Set polygon geometry
560 val points = listOf(
561 Point(50.0, 60.0),
562 Point(55.0, 65.0),
563 Point(60.0, 60.0),
564 Point(55.0, 55.0)
565 )
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]
570
571 // [kotlin_PolygonMapObject_setColor]
572 // Set polygon color
573 val colorSuccess = polygonMapObject!!.setColor(0xB300FF00.toInt())
574 println("Set polygon color to green with 70% opacity: $colorSuccess")
575 // [kotlin_PolygonMapObject_setColor]
576
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]
582
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]
588
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]
594
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]
600
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]
606
607 // [kotlin_PolygonMapObject_setVisible]
608 // Set visibility
609 val visibleSuccess = polygonMapObject!!.setVisible(true)
610 println("Set polygon visibility to true: $visibleSuccess")
611 // [kotlin_PolygonMapObject_setVisible]
612
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]
618
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]
624
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]
630
631 // [kotlin_MapObject_setTitle_2]
632 // Set title
633 val titleSuccess = polygonMapObject!!.setTitle("Polygon Object")
634 println("Set polygon title to 'Polygon Object': $titleSuccess")
635 // [kotlin_MapObject_setTitle_2]
636
637 // [kotlin_MapObject_setData_2]
638 // Set custom data
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]
643
644 // [kotlin_MapObject_getId_2]
645 // Get object ID
646 val objectId = polygonMapObject!!.id
647 println("Polygon object ID: $objectId")
648 // [kotlin_MapObject_getId_2]
649
650 // [kotlin_MapObject_getType_2]
651 // Get object type
652 val objectTypeString = polygonMapObject!!.type
653 println("Polygon object type: $objectTypeString")
654 // [kotlin_MapObject_getType_2]
655
656 // [kotlin_MapObject_getData_2]
657 // Get custom data
658 val retrievedData = polygonMapObject!!.data
659 println("Polygon custom data: $retrievedData")
660 // [kotlin_MapObject_getData_2]
661 }
662
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
669 }
670 // [kotlin_LocationWindow_removePolygonMapObject]
671
672 // Test multiple polygon objects
673 val polygons = mutableListOf<PolygonMapObject>()
674 for (i in 0..2) {
675 val polygon = locationWindow!!.addPolygonMapObject()
676 if (polygon != null) {
677 val points = listOf(
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)
682 )
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")
688 }
689 }
690
691 for (i in polygons.indices) {
692 locationWindow!!.removePolygonMapObject(polygons[i])
693 println("Removed polygon $i")
694 }
695 }
696
697 /**
698 * Demonstrate polyline map objects
699 */
700 private fun demonstratePolylineMapObjects() {
701 println("--- Polyline Map Objects ---")
702
703 if (locationWindow == null) {
704 println("LocationWindow not available yet")
705 return
706 }
707
708 // [kotlin_PolylineMapObject_constructor]
709 // Create polyline map object
710 val points = listOf(
711 Point(100.0, 110.0),
712 Point(105.0, 115.0),
713 Point(110.0, 120.0),
714 Point(115.0, 125.0)
715 )
716 val polyline = LocationPolyline(points, 0)
717 polylineMapObject = locationWindow!!.addPolylineMapObject()
718 println("Created polyline map object with ${points.size} points")
719 // [kotlin_PolylineMapObject_constructor]
720
721 // [kotlin_PolylineMapObject_getPolyline]
722 // Access polyline
723 val polylineShape = polylineMapObject!!.getPolyLine()
724 println("Polyline has ${polylineShape.points.size} points")
725 // [kotlin_PolylineMapObject_getPolyline]
726
727 // [kotlin_LocationWindow_addPolylineMapObject]
728 // Add polyline map object
729 polylineMapObject = locationWindow!!.addPolylineMapObject()
730 println("Added polyline map object")
731 // [kotlin_LocationWindow_addPolylineMapObject]
732
733 if (polylineMapObject != null) {
734 // [kotlin_PolylineMapObject_setPolyLine]
735 // Set polyline geometry
736 val points = listOf(
737 Point(100.0, 110.0),
738 Point(105.0, 115.0),
739 Point(110.0, 120.0),
740 Point(115.0, 125.0)
741 )
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]
746
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]
752
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]
758
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]
764
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]
770
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]
776
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]
782
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]
788
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]
794
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]
800
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]
806
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]
812
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]
818
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]
824
825 // [kotlin_PolylineMapObject_setVisible]
826 // Set visibility
827 val visibleSuccess = polylineMapObject!!.setVisible(true)
828 println("Set polyline visibility to true: $visibleSuccess")
829 // [kotlin_PolylineMapObject_setVisible]
830
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]
836
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]
842
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]
848
849 // [kotlin_MapObject_setTitle_3]
850 // Set title
851 val titleSuccess = polylineMapObject!!.setTitle("Polyline Object")
852 println("Set polyline title to 'Polyline Object': $titleSuccess")
853 // [kotlin_MapObject_setTitle_3]
854
855 // [kotlin_MapObject_setData_3]
856 // Set custom data
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]
861
862 // [kotlin_MapObject_getId_3]
863 // Get object ID
864 val objectId = polylineMapObject!!.id
865 println("Polyline object ID: $objectId")
866 // [kotlin_MapObject_getId_3]
867
868 // [kotlin_MapObject_getType_3]
869 // Get object type
870 val objectTypeString = polylineMapObject!!.type
871 println("Polyline object type: $objectTypeString")
872 // [kotlin_MapObject_getType_3]
873
874 // [kotlin_MapObject_getData_3]
875 // Get custom data
876 val retrievedData = polylineMapObject!!.data
877 println("Polyline custom data: $retrievedData")
878 // [kotlin_MapObject_getData_3]
879 }
880
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
887 }
888 // [kotlin_LocationWindow_removePolylineMapObject]
889
890 // Test multiple polyline objects
891 val polylines = mutableListOf<PolylineMapObject>()
892 for (i in 0..2) {
893 val polyline = locationWindow!!.addPolylineMapObject()
894 if (polyline != null) {
895 val points = listOf(
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)
899 )
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")
906 }
907 }
908
909 for (i in polylines.indices) {
910 locationWindow!!.removePolylineMapObject(polylines[i])
911 println("Removed polyline $i")
912 }
913 }
914
915 /**
916 * Demonstrate dotted polyline map objects
917 */
918 private fun demonstrateDottedPolylineMapObjects() {
919 println("--- Dotted Polyline Map Objects ---")
920
921 if (locationWindow == null) {
922 println("LocationWindow not available yet")
923 return
924 }
925
926 // [kotlin_DottedPolylineMapObject_constructor]
927 // Create dotted polyline map object
928 val points = listOf(
929 Point(160.0, 170.0),
930 Point(165.0, 175.0),
931 Point(170.0, 180.0),
932 Point(175.0, 185.0)
933 )
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]
938
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]
944
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]
950
951 if (dottedPolylineMapObject != null) {
952 // [kotlin_DottedPolylineMapObject_setPolyline]
953 // Set dotted polyline geometry
954 val points = listOf(
955 Point(160.0, 170.0),
956 Point(165.0, 175.0),
957 Point(170.0, 180.0),
958 Point(175.0, 185.0)
959 )
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]
964
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]
970
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]
976
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]
982
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]
988
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]
994
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]
1000
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]
1006
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]
1012
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]
1018
1019 // [kotlin_DottedPolylineMapObject_setRepeatGroup]
1020 // Set repeat group
1021 val repeatGroupSuccess = dottedPolylineMapObject!!.setRepeatGroup(1)
1022 println("Set dotted polyline repeat group to 1: $repeatGroupSuccess")
1023 // [kotlin_DottedPolylineMapObject_setRepeatGroup]
1024
1025 // [kotlin_DottedPolylineMapObject_setSize]
1026 // Set size
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]
1031
1032 // [kotlin_DottedPolylineMapObject_setVisible]
1033 // Set visibility
1034 val visibleSuccess = dottedPolylineMapObject!!.setVisible(true)
1035 println("Set dotted polyline visibility to true: $visibleSuccess")
1036 // [kotlin_DottedPolylineMapObject_setVisible]
1037
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]
1043
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]
1049
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]
1055
1056 // [kotlin_MapObject_setTitle_4]
1057 // Set title
1058 val titleSuccess = dottedPolylineMapObject!!.setTitle("Dotted Polyline Object")
1059 println("Set dotted polyline title to 'Dotted Polyline Object': $titleSuccess")
1060 // [kotlin_MapObject_setTitle_4]
1061
1062 // [kotlin_MapObject_setData_4]
1063 // Set custom data
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]
1068
1069 // [kotlin_MapObject_getId_4]
1070 // Get object ID
1071 val objectId = dottedPolylineMapObject!!.id
1072 println("Dotted polyline object ID: $objectId")
1073 // [kotlin_MapObject_getId_4]
1074
1075 // [kotlin_MapObject_getType_4]
1076 // Get object type
1077 val objectTypeString = dottedPolylineMapObject!!.type
1078 println("Dotted polyline object type: $objectTypeString")
1079 // [kotlin_MapObject_getType_4]
1080
1081 // [kotlin_MapObject_getData_4]
1082 // Get custom data
1083 val retrievedData = dottedPolylineMapObject!!.data
1084 println("Dotted polyline custom data: $retrievedData")
1085 // [kotlin_MapObject_getData_4]
1086 }
1087
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
1094 }
1095 // [kotlin_LocationWindow_removeDottedPolylineMapObject]
1096
1097 // Test multiple dotted polyline objects
1098 val dottedPolylines = mutableListOf<DottedPolylineMapObject>()
1099 for (i in 0..2) {
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)
1106 )
1107 val polylineGeometry = LocationPolyline(points, 0)
1108 dottedPolyline.setPolyline(polylineGeometry)
1109 dottedPolylines.add(dottedPolyline)
1110 println("Created dotted polyline $i with ${points.size} points")
1111 }
1112 }
1113
1114 for (i in dottedPolylines.indices) {
1115 locationWindow!!.removeDottedPolylineMapObject(dottedPolylines[i])
1116 println("Removed dotted polyline $i")
1117 }
1118 }
1119
1120 /**
1121 * Demonstrate icon clustering via ClusterMapObjectController.
1122 */
1123 private fun demonstrateClusterMapObjects() {
1124 println("--- Cluster map objects ---")
1125
1126 if (locationWindow == null) {
1127 println("LocationWindow not available")
1128 return
1129 }
1130
1131 // [kotlin_LocationWindow_addClusterMapObjectController]
1132 clusterMapObjectController = locationWindow!!.addClusterMapObjectController()
1133 println("Added cluster map object controller")
1134 // [kotlin_LocationWindow_addClusterMapObjectController]
1135
1136 val controller = clusterMapObjectController ?: return
1137
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))
1142
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]
1148
1149 // [kotlin_ClusterMapObjectController_setEnabled]
1150 controller.setEnabled(true)
1151 println("Clustering enabled")
1152 // [kotlin_ClusterMapObjectController_setEnabled]
1153
1154 // [kotlin_ClusterMapObjectController_isEnabled]
1155 val clusteringEnabled = controller.isEnabled
1156 println("Clustering is enabled: $clusteringEnabled")
1157 // [kotlin_ClusterMapObjectController_isEnabled]
1158
1159 // [kotlin_ClusterMapObjectController_setRadius]
1160 controller.setRadius(40.0f)
1161 println("Set cluster radius to 40 px")
1162 // [kotlin_ClusterMapObjectController_setRadius]
1163
1164 // [kotlin_ClusterMapObjectController_getRadius]
1165 val clusterRadius = controller.getRadius()
1166 println("Cluster radius: $clusterRadius")
1167 // [kotlin_ClusterMapObjectController_getRadius]
1168
1169 // [kotlin_ClusterMapObjectController_setInteractive]
1170 val interactiveSuccess = controller.setInteractive(true)
1171 println("Set cluster markers interactive: $interactiveSuccess")
1172 // [kotlin_ClusterMapObjectController_setInteractive]
1173
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]
1178
1179 clusterMapObjectControllerListener = DemoClusterMapObjectControllerListener()
1180
1181 // [kotlin_ClusterMapObjectController_addListener]
1182 controller.addListener(clusterMapObjectControllerListener!!)
1183 println("Added cluster map object listener")
1184 // [kotlin_ClusterMapObjectController_addListener]
1185
1186 // [kotlin_ClusterMapObjectController_getClusters]
1187 val clusters = controller.getClusters()
1188 println("Visible clusters: ${clusters.size}")
1189 // [kotlin_ClusterMapObjectController_getClusters]
1190
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]
1198 }
1199
1200 // [kotlin_ClusterMapObjectController_removeListener]
1201 controller.removeListener(clusterMapObjectControllerListener!!)
1202 println("Removed cluster map object listener")
1203 // [kotlin_ClusterMapObjectController_removeListener]
1204
1205 clusterIcon1?.let {
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)
1211 }
1212 clusterIcon2?.let { locationWindow!!.removeIconMapObject(it) }
1213
1214 // [kotlin_ClusterMapObjectController_clear]
1215 controller.clear()
1216 println("Cleared cluster controller")
1217 // [kotlin_ClusterMapObjectController_clear]
1218
1219 // [kotlin_LocationWindow_removeClusterMapObjectController]
1220 val controllerRemoved =
1221 locationWindow!!.removeClusterMapObjectController(controller)
1222 println("Removed cluster map object controller: $controllerRemoved")
1223 // [kotlin_LocationWindow_removeClusterMapObjectController]
1224
1225 clusterMapObjectController = null
1226 clusterMapObjectControllerListener = null
1227 }
1228
1229 /**
1230 * Demonstrate remove all map objects
1231 */
1232 private fun demonstrateRemoveAllMapObjects() {
1233 println("--- Remove All Map Objects ---")
1234
1235 if (locationWindow == null) {
1236 println("LocationWindow not available yet")
1237 return
1238 }
1239
1240 println("Current map objects count: ${getMapObjectsCount()}")
1241
1242 // [kotlin_LocationWindow_removeAllMapObjects]
1243 // Remove all map objects
1244 locationWindow!!.removeAllMapObjects()
1245 println("Removed all map objects")
1246 // [kotlin_LocationWindow_removeAllMapObjects]
1247
1248 println("Map objects count after removal: ${getMapObjectsCount()}")
1249 }
1250
1251 /**
1252 * Get current map objects count
1253 */
1254 private fun getMapObjectsCount(): Int {
1255 var count = 0
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++
1261 return count
1262 }
1263
1264 /**
1265 * Cleanup resources
1266 */
1267 private fun cleanup() {
1268 println("--- Cleanup ---")
1269
1270 if (locationWindow != null) {
1271 locationWindow!!.removeAllMapObjects()
1272 println("Cleaned up all map objects")
1273 }
1274
1275 circleMapObject = null
1276 iconMapObject = null
1277 modelMapObject = null
1278 polygonMapObject = null
1279 polylineMapObject = null
1280 dottedPolylineMapObject = null
1281 println("Cleared map objects references")
1282 }
1283}
1284
1285class DemoClusterMapObjectControllerListener : ClusterMapObjectControllerListener {
1286 private val clusterChangeListener = DemoClusterMapObjectListener()
1287 private var activeCluster: ClusterMapObject? = null
1288
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
1296 }
1297 // [kotlin_ClusterMapObjectControllerListener_onClusterCreated]
1298
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
1308 }
1309 println("Cluster destroyed, id: $clusterId")
1310 }
1311 // [kotlin_ClusterMapObjectControllerListener_onClusterDestroyed]
1312}
1313
1314class DemoClusterMapObjectListener : ClusterMapObjectListener {
1315
1316 // [kotlin_ClusterMapObjectListener_onClusterChanged]
1317 override fun onClusterChanged(cluster: ClusterMapObject) {
1318 val memberCount = cluster.getCount()
1319 println("Cluster changed, member count: $memberCount")
1320 }
1321 // [kotlin_ClusterMapObjectListener_onClusterChanged]
1322}
1323
1324// Main function to run the example
1325fun main() {
1326 LocationWindowMapObjectsExample()
1327}