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.GeoJsonImport
21import com.navigine.idl.kotlin.LocationPolygon
22import com.navigine.idl.kotlin.PointBatch
23import com.navigine.idl.kotlin.PointSprite
24import com.navigine.idl.kotlin.LocationPolyline
25import com.navigine.idl.kotlin.MapObjectType
26import com.navigine.idl.kotlin.Placement
27import com.navigine.idl.kotlin.Color
28import com.navigine.idl.kotlin.Size
29import com.navigine.idl.kotlin.GlobalPoint
30import com.navigine.idl.kotlin.Polygon
31import com.navigine.idl.kotlin.Polyline
32import com.navigine.idl.kotlin.TitleStyle
35 * LocationWindowMapObjects usage example for Kotlin
36 * Demonstrates specific methods: addCircleMapObject, removeCircleMapObject, addIconMapObject,
37 * removeIconMapObject, addPolygonMapObject, addPolylineMapObject, removePolylineMapObject,
38 * addDottedPolylineMapObject, removeDottedPolylineMapObject, removeAllMapObjects
40class LocationWindowMapObjectsExample {
41 private var locationWindow: LocationWindow? = null
42 private var circleMapObject: CircleMapObject? = null
43 private var iconMapObject: IconMapObject? = null
44 private var modelMapObject: ModelMapObject? = null
45 private var polygonMapObject: PolygonMapObject? = null
46 private var polylineMapObject: PolylineMapObject? = null
47 private var dottedPolylineMapObject: DottedPolylineMapObject? = null
48 private var clusterMapObjectController: ClusterMapObjectController? = null
49 private var clusterMapObjectControllerListener: ClusterMapObjectControllerListener? = null
52 demonstrateLocationWindowMapObjectsMethods()
56 * Demonstrate LocationWindowMapObjects methods
58 private fun demonstrateLocationWindowMapObjectsMethods() {
59 println("=== LocationWindowMapObjects Example ===")
61 // Initialize LocationWindow (in real app, this would be provided by the framework)
62 // locationWindow = getLocationWindow()
64 demonstrateLocationScopedGeometryRecords()
66 demonstrateCircleMapObjects()
67 demonstrateIconMapObjects()
68 demonstrateClusterMapObjects()
69 demonstrateModelMapObjects()
70 demonstratePolygonMapObjects()
71 demonstratePolylineMapObjects()
72 demonstrateDottedPolylineMapObjects()
73 demonstrateRemoveAllMapObjects()
79 * Metrics geometry scoped to a location / sublocation (@see LocationPolygon, LocationPolyline).
81 private fun demonstrateLocationScopedGeometryRecords() {
82 println("--- LocationPolygon / LocationPolyline records ---")
84 // [kotlin_LocationPolygon_record]
86 GlobalPoint(55.751, 37.617),
87 GlobalPoint(55.752, 37.618),
88 GlobalPoint(55.751, 37.619)
90 val holes = listOf(listOf(
91 GlobalPoint(55.7512, 37.6174),
92 GlobalPoint(55.7514, 37.6176),
93 GlobalPoint(55.7512, 37.6178),
95 val locationPolygon = LocationPolygon(ring, 7, holes)
96 val polygonSublocationId = locationPolygon.sublocationId
97 println("LocationPolygon: sublocation $polygonSublocationId, vertices ${locationPolygon.points.size}, holes ${locationPolygon.innerRings.size}")
98 // [kotlin_LocationPolygon_record]
100 // [kotlin_LocationWindow_addPointBatch]
101 val batch: PointBatch = locationWindow.addPointBatch()
102 batch.setPoints(listOf(
103 PointSprite(GlobalPoint(55.751, 37.617), 0f, 0xCCFF8000.toInt(), 5f),
104 PointSprite(GlobalPoint(55.752, 37.618), 90f, 0xCC0080FF.toInt(), 5f),
106 val hit = batch.hitTest(android.graphics.PointF(12f, 8f), 8f)
107 println("PointBatch hit $hit")
108 // [kotlin_LocationWindow_addPointBatch]
110 // [kotlin_LocationWindow_addGeoJson]
111 val geoJson = """{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[37.617,55.751],[37.619,55.751],[37.619,55.752],[37.617,55.751]],[[37.6174,55.7512],[37.6176,55.7512],[37.6176,55.7514],[37.6174,55.7512]]]}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[37.617,55.751],[37.620,55.753]]}}]}"""
112 val imported: GeoJsonImport = locationWindow.addGeoJson(geoJson, 7)
113 println("GeoJSON polygons ${imported.polygons.size}, lines ${imported.polylines.size}")
114 // [kotlin_LocationWindow_addGeoJson]
116 // [kotlin_LocationPolyline_record]
117 val linePoints = listOf(
118 GlobalPoint(55.751, 37.617),
119 GlobalPoint(55.753, 37.620)
121 val locationPolyline = LocationPolyline(linePoints, 7)
122 println("LocationPolyline: points ${locationPolyline.points.size}")
123 // [kotlin_LocationPolyline_record]
127 * Demonstrate circle map objects
129 private fun demonstrateCircleMapObjects() {
130 println("--- Circle Map Objects ---")
132 if (locationWindow == null) {
133 println("LocationWindow not available yet")
137 // [kotlin_CircleMapObject_constructor]
138 // Create circle map object
139 val center = GlobalPoint(10.0, 20.0)
140 circleMapObject = locationWindow!!.addCircleMapObject()
141 println("Created circle map object with center (${center.latitude}, ${center.longitude}) and radius 5.0")
142 // [kotlin_CircleMapObject_constructor]
144 // [kotlin_CircleMapObject_getRadius]
145 // Access circle radius
146 val radius = circleMapObject!!.getRadius()
147 println("Circle radius: $radius")
148 // [kotlin_CircleMapObject_getRadius]
150 // [kotlin_LocationWindow_addCircleMapObject]
151 // Add circle map object
152 circleMapObject = locationWindow!!.addCircleMapObject()
153 println("Added circle map object")
154 // [kotlin_LocationWindow_addCircleMapObject]
156 if (circleMapObject != null) {
157 // [kotlin_CircleMapObject_setPosition]
158 // Set circle position
159 val centerPoint = GlobalPoint(100.0, 200.0)
160 val success = circleMapObject!!.setPosition(centerPoint, 7)
161 println("Set circle position to (${centerPoint.latitude}, ${centerPoint.longitude}): $success")
162 // [kotlin_CircleMapObject_setPosition]
164 // [kotlin_CircleMapObject_setPositionAnimated]
165 // Set circle position with animation
166 val animatedPoint = GlobalPoint(150.0, 250.0)
167 val animatedSuccess = circleMapObject!!.setPositionAnimated(animatedPoint, 7, 2.0, AnimationType.LINEAR)
168 println("Set circle position with animation to (${animatedPoint.latitude}, ${animatedPoint.longitude}): $animatedSuccess")
169 // [kotlin_CircleMapObject_setPositionAnimated]
171 // [kotlin_CircleMapObject_setRadius]
173 val radiusSuccess = circleMapObject!!.setRadius(10.0)
174 println("Set circle radius to 10.0 meters: $radiusSuccess")
175 // [kotlin_CircleMapObject_setRadius]
177 // [kotlin_CircleMapObject_setCollisionEnabled]
178 // Enable collision detection
179 val collisionSuccess = circleMapObject!!.setCollisionEnabled(true)
180 println("Enabled collision detection for circle: $collisionSuccess")
181 // [kotlin_CircleMapObject_setCollisionEnabled]
183 // [kotlin_CircleMapObject_setBuffer]
184 // Set collision buffer
185 val bufferSuccess = circleMapObject!!.setBuffer(5.0, 5.0)
186 println("Set collision buffer to 5x5 pixels: $bufferSuccess")
187 // [kotlin_CircleMapObject_setBuffer]
189 // [kotlin_CircleMapObject_setOffset]
190 // Set position offset
191 val offsetSuccess = circleMapObject!!.setOffset(2.0, 3.0)
192 println("Set position offset to (2.0, 3.0) pixels: $offsetSuccess")
193 // [kotlin_CircleMapObject_setOffset]
195 // [kotlin_CircleMapObject_setOutlineColor]
197 val outlineColorSuccess = circleMapObject!!.setOutlineColor(0xFF0000FF.toInt())
198 println("Set circle outline color to blue: $outlineColorSuccess")
199 // [kotlin_CircleMapObject_setOutlineColor]
201 // [kotlin_CircleMapObject_setOutlineAlpha]
203 val outlineAlphaSuccess = circleMapObject!!.setOutlineAlpha(0.5)
204 println("Set circle outline alpha to 0.5: $outlineAlphaSuccess")
205 // [kotlin_CircleMapObject_setOutlineAlpha]
207 // [kotlin_CircleMapObject_setOutlineRadius]
208 // Set outline radius
209 val outlineRadiusSuccess = circleMapObject!!.setOutlineRadius(2.0)
210 println("Set circle outline radius to 2.0: $outlineRadiusSuccess")
211 // [kotlin_CircleMapObject_setOutlineRadius]
213 // [kotlin_CircleMapObject_setColor]
215 val colorSuccess = circleMapObject!!.setColor(0xCCFF0000.toInt())
216 println("Set circle color to red with 80% opacity: $colorSuccess")
217 // [kotlin_CircleMapObject_setColor]
219 // [kotlin_CircleMapObject_setPriority]
220 // Set rendering priority
221 val prioritySuccess = circleMapObject!!.setPriority(1)
222 println("Set rendering priority to 1: $prioritySuccess")
223 // [kotlin_CircleMapObject_setPriority]
225 // [kotlin_MapObject_setVisible]
227 val visibleSuccess = circleMapObject!!.setVisible(true)
228 println("Set circle visibility to true: $visibleSuccess")
229 // [kotlin_MapObject_setVisible]
231 // [kotlin_CircleMapObject_getMapObjectType]
232 // Get map object type
233 val objectType = circleMapObject!!.mapObjectType
234 println("Circle map object type: $objectType")
235 // [kotlin_CircleMapObject_getMapObjectType]
237 // [kotlin_MapObject_setAlpha]
238 // Set alpha transparency
239 val alphaSuccess = circleMapObject!!.setAlpha(0.7)
240 println("Set circle alpha to 0.7: $alphaSuccess")
241 // [kotlin_MapObject_setAlpha]
243 // [kotlin_MapObject_setInteractive]
244 // Set interactive mode
245 val interactiveSuccess = circleMapObject!!.setInteractive(true)
246 println("Set circle interactive to true: $interactiveSuccess")
247 // [kotlin_MapObject_setInteractive]
249 // [kotlin_MapObject_setTitle]
251 val titleSuccess = circleMapObject!!.setTitle("Circle Object")
252 println("Set circle title to 'Circle Object': $titleSuccess")
253 // [kotlin_MapObject_setTitle]
255 // [kotlin_TitleStyle_record]
256 val titleStyle = TitleStyle()
257 titleStyle.fontSize = 14f
258 titleStyle.color = "#3366CC"
259 titleStyle.outlineColor = "#FFFFFF"
260 titleStyle.anchor = TitleAnchor.TOP
261 titleStyle.visible = true
262 // [kotlin_TitleStyle_record]
264 // [kotlin_MapObject_setTitleWithStyle]
265 // Set title with style
266 val titleStyleSuccess = circleMapObject!!.setTitleWithStyle("Styled Circle", titleStyle)
267 println("Set circle title with style: $titleStyleSuccess")
268 // [kotlin_MapObject_setTitleWithStyle]
270 // [kotlin_MapObject_setData]
272 val customData = mapOf("key" to "value", "number" to "42")
273 val dataSuccess = circleMapObject!!.setData(customData)
274 println("Set circle custom data: $dataSuccess")
275 // [kotlin_MapObject_setData]
277 // [kotlin_MapObject_getId]
279 val objectId = circleMapObject!!.id
280 println("Circle object ID: $objectId")
281 // [kotlin_MapObject_getId]
283 // [kotlin_MapObject_getType]
285 val objectTypeString = circleMapObject!!.type
286 println("Circle object type: $objectTypeString")
287 // [kotlin_MapObject_getType]
289 // [kotlin_MapObject_getData]
291 val retrievedData = circleMapObject!!.data
292 println("Circle custom data: $retrievedData")
293 // [kotlin_MapObject_getData]
296 // [kotlin_LocationWindow_removeCircleMapObject]
297 // Remove circle map object
298 if (circleMapObject != null) {
299 val removed = locationWindow!!.removeCircleMapObject(circleMapObject!!)
300 println("Removed circle map object: $removed")
301 circleMapObject = null
303 // [kotlin_LocationWindow_removeCircleMapObject]
305 // Test multiple circle objects
306 val circles = mutableListOf<CircleMapObject>()
308 val circle = locationWindow!!.addCircleMapObject()
309 if (circle != null) {
310 circle.setPosition(GlobalPoint(50.0 * i, 100.0 * i))
311 circle.setColor(0x9900FF00.toInt())
312 circle.setRadius(5.0 + i * 2.0)
314 println("Created circle $i at (${50.0 * i}, ${100.0 * i}) with radius ${5.0 + i * 2.0}")
318 for (i in circles.indices) {
319 locationWindow!!.removeCircleMapObject(circles[i])
320 println("Removed circle $i")
325 * Demonstrate icon map objects
327 private fun demonstrateIconMapObjects() {
328 println("--- Icon Map Objects ---")
330 if (locationWindow == null) {
331 println("LocationWindow not available yet")
335 // [kotlin_IconMapObject_constructor]
336 // Create icon map object
337 val position = GlobalPoint(30.0, 40.0)
338 iconMapObject = locationWindow!!.addIconMapObject()
339 println("Created icon map object at (${position.latitude}, ${position.longitude})")
340 // [kotlin_IconMapObject_constructor]
342 // [kotlin_LocationWindow_addIconMapObject]
343 // Add icon map object
344 iconMapObject = locationWindow!!.addIconMapObject()
345 println("Added icon map object")
346 // [kotlin_LocationWindow_addIconMapObject]
348 if (iconMapObject != null) {
349 // [kotlin_IconMapObject_setPosition]
351 val position = GlobalPoint(30.0, 40.0)
352 val success = iconMapObject!!.setPosition(position, 7)
353 println("Set icon position to (${position.latitude}, ${position.longitude}): $success")
354 // [kotlin_IconMapObject_setPosition]
356 // [kotlin_IconMapObject_setPositionAnimated]
357 // Set icon position with animation
358 val animatedPosition = GlobalPoint(35.0, 45.0)
359 val animatedSuccess = iconMapObject!!.setPositionAnimated(animatedPosition, 7, 1.5, AnimationType.CUBIC)
360 println("Set icon position with animation to (${animatedPosition.latitude}, ${animatedPosition.longitude}): $animatedSuccess")
361 // [kotlin_IconMapObject_setPositionAnimated]
363 // [kotlin_IconMapObject_setBitmap]
364 val iconBitmap = ImageProvider.fromFile("/path/to/icon.png", true)
365 val bitmapSuccess = iconMapObject!!.setBitmap(iconBitmap)
366 println("Set icon from ImageProvider: $bitmapSuccess")
367 // [kotlin_IconMapObject_setBitmap]
369 // [kotlin_IconMapObject_setFlat]
370 // Set icon flat mode
371 val flatSuccess = iconMapObject!!.setFlat(true)
372 println("Set icon flat mode to true: $flatSuccess")
373 // [kotlin_IconMapObject_setFlat]
375 // [kotlin_IconMapObject_setSize]
377 val size = Size(32.0, 32.0)
378 val sizeSuccess = iconMapObject!!.setSize(size)
379 println("Set icon size to (${size.width}, ${size.height}): $sizeSuccess")
380 // [kotlin_IconMapObject_setSize]
382 // [kotlin_IconMapObject_setAngle]
383 // Set icon rotation angle (radians)
384 val angleSuccess = iconMapObject!!.setAngle(Math.toRadians(45.0).toFloat())
385 println("Set icon rotation angle to π/4: $angleSuccess")
386 // [kotlin_IconMapObject_setAngle]
388 // [kotlin_IconMapObject_setAngleAnimated]
389 // Set icon rotation with animation (radians)
390 val angleAnimatedSuccess = iconMapObject!!.setAngleAnimated(Math.toRadians(90.0).toFloat(), 2.0, AnimationType.SINE)
391 println("Set icon rotation with animation to π/2: $angleAnimatedSuccess")
392 // [kotlin_IconMapObject_setAngleAnimated]
394 // [kotlin_IconMapObject_setCollisionEnabled]
395 // Enable collision detection
396 val collisionSuccess = iconMapObject!!.setCollisionEnabled(true)
397 println("Enabled collision detection for icon: $collisionSuccess")
398 // [kotlin_IconMapObject_setCollisionEnabled]
400 // [kotlin_IconMapObject_setBuffer]
401 // Set collision buffer
402 val bufferSuccess = iconMapObject!!.setBuffer(10.0, 10.0)
403 println("Set collision buffer to 10x10 pixels: $bufferSuccess")
404 // [kotlin_IconMapObject_setBuffer]
406 // [kotlin_IconMapObject_setBuffer]
407 // Set position offset
408 val offsetSuccess = iconMapObject!!.setOffset(0.0, -16.0)
409 println("Set position offset to (0.0, -16.0) pixels: $offsetSuccess")
410 // [kotlin_IconMapObject_setOffset]
412 // [kotlin_IconMapObject_setPriority]
413 // Set rendering priority
414 val prioritySuccess = iconMapObject!!.setPriority(2)
415 println("Set rendering priority to 2: $prioritySuccess")
416 // [kotlin_IconMapObject_setPriority]
418 // [kotlin_IconMapObject_setVisible]
420 val visibleSuccess = iconMapObject!!.setVisible(true)
421 println("Set icon visibility to true: $visibleSuccess")
422 // [kotlin_IconMapObject_setVisible]
424 // [kotlin_IconMapObject_getMapObjectType]
425 // Get map object type
426 val objectType = iconMapObject!!.mapObjectType
427 println("Icon map object type: $objectType")
428 // [kotlin_IconMapObject_getMapObjectType]
430 // [kotlin_MapObject_setAlpha_1]
431 // Set alpha transparency
432 val alphaSuccess = iconMapObject!!.setAlpha(0.8)
433 println("Set icon alpha to 0.8: $alphaSuccess")
434 // [kotlin_MapObject_setAlpha_1]
436 // [kotlin_MapObject_setInteractive_1]
437 // Set interactive mode
438 val interactiveSuccess = iconMapObject!!.setInteractive(true)
439 println("Set icon interactive to true: $interactiveSuccess")
440 // [kotlin_MapObject_setInteractive_1]
442 // [kotlin_MapObject_setTitle_1]
444 val titleSuccess = iconMapObject!!.setTitle("Icon Object")
445 println("Set icon title to 'Icon Object': $titleSuccess")
446 // [kotlin_MapObject_setTitle_1]
448 // [kotlin_MapObject_setData_1]
450 val customData = mapOf("key" to "value", "number" to "42")
451 val dataSuccess = iconMapObject!!.setData(customData)
452 println("Set icon custom data: $dataSuccess")
453 // [kotlin_MapObject_setData_1]
455 // [kotlin_MapObject_getId_1]
457 val objectId = iconMapObject!!.id
458 println("Icon object ID: $objectId")
459 // [kotlin_MapObject_getId_1]
461 // [kotlin_MapObject_getType_1]
463 val objectTypeString = iconMapObject!!.type
464 println("Icon object type: $objectTypeString")
465 // [kotlin_MapObject_getType_1]
467 // [kotlin_MapObject_getData_1]
469 val retrievedData = iconMapObject!!.data
470 println("Icon custom data: $retrievedData")
471 // [kotlin_MapObject_getData_1]
474 // [kotlin_LocationWindow_removeIconMapObject]
475 // Remove icon map object
476 if (iconMapObject != null) {
477 val removed = locationWindow!!.removeIconMapObject(iconMapObject!!)
478 println("Removed icon map object: $removed")
481 // [kotlin_LocationWindow_removeIconMapObject]
483 // Test multiple icon objects
484 val icons = mutableListOf<IconMapObject>()
486 val icon = locationWindow!!.addIconMapObject()
488 icon.setPosition(GlobalPoint(60.0 * i, 120.0 * i))
489 icon.setBitmap(ImageProvider.fromFile("/path/to/icon.png", true))
490 icon.setSize(Size(24.0, 24.0))
492 println("Created icon $i at (${60.0 * i}, ${120.0 * i})")
496 for (i in icons.indices) {
497 locationWindow!!.removeIconMapObject(icons[i])
498 println("Removed icon $i")
502 private fun demonstrateModelMapObjects() {
503 println("--- Model Map Objects ---")
504 if (locationWindow == null) {
505 println("LocationWindow not available yet")
509 // [kotlin_LocationWindow_addModelMapObject]
510 modelMapObject = locationWindow!!.addModelMapObject()
511 println("Added model map object: ${modelMapObject != null}")
512 // [kotlin_LocationWindow_addModelMapObject]
514 val m = modelMapObject ?: return
516 // [kotlin_ModelMapObject_setPosition]
517 val posOk = m.setPosition(GlobalPoint(12.0, 34.0))
518 println("Model setPosition: $posOk")
519 // [kotlin_ModelMapObject_setPosition]
521 // [kotlin_ModelMapObject_setPositionAnimated]
522 val posAnimOk = m.setPositionAnimated(GlobalPoint(15.0, 40.0), 0.5f, AnimationType.SINE)
523 println("Model setPositionAnimated: $posAnimOk")
524 // [kotlin_ModelMapObject_setPositionAnimated]
526 // [kotlin_ModelMapObject_setModel]
527 val texture = ImageProvider.fromFile("/path/to/model_texture.png", true)
528 val model = ModelProvider.fromFile("/path/to/model.obj", texture)
529 val modelOk = m.setModel(model)
530 println("Model setModel: $modelOk")
531 // [kotlin_ModelMapObject_setModel]
533 // [kotlin_ModelMapObject_setSize]
534 val sizeOk = m.setSize(64.0f, 64.0f)
535 println("Model setSize: $sizeOk")
536 // [kotlin_ModelMapObject_setSize]
538 // [kotlin_ModelMapObject_setCollisionEnabled]
539 println("Model setCollisionEnabled: ${m.setCollisionEnabled(true)}")
540 // [kotlin_ModelMapObject_setCollisionEnabled]
542 // [kotlin_ModelMapObject_setAngle]
543 println("Model setAngle: ${m.setAngle(Math.toRadians(45.0).toFloat())}")
544 // [kotlin_ModelMapObject_setAngle]
546 // [kotlin_ModelMapObject_setAngleAnimated]
547 println("Model setAngleAnimated: ${m.setAngleAnimated(Math.toRadians(90.0).toFloat(), 0.5f, AnimationType.QUINT)}")
548 // [kotlin_ModelMapObject_setAngleAnimated]
550 // [kotlin_ModelMapObject_setBuffer]
551 println("Model setBuffer: ${m.setBuffer(4.0f, 4.0f)}")
552 // [kotlin_ModelMapObject_setBuffer]
554 // [kotlin_ModelMapObject_setPriority]
555 println("Model setPriority: ${m.setPriority(10.0f)}")
556 // [kotlin_ModelMapObject_setPriority]
558 // [kotlin_LocationWindow_removeModelMapObject]
559 println("Removed model: ${locationWindow!!.removeModelMapObject(m)}")
560 modelMapObject = null
561 // [kotlin_LocationWindow_removeModelMapObject]
565 * Demonstrate polygon map objects
567 private fun demonstratePolygonMapObjects() {
568 println("--- Polygon Map Objects ---")
570 if (locationWindow == null) {
571 println("LocationWindow not available yet")
575 // [kotlin_LocationWindow_addPolygonMapObject]
576 // Add polygon map object
577 polygonMapObject = locationWindow!!.addPolygonMapObject()
578 println("Added polygon map object")
579 // [kotlin_LocationWindow_addPolygonMapObject]
581 if (polygonMapObject != null) {
582 // [kotlin_PolygonMapObject_setPolygon]
583 // Set polygon geometry
590 val polygon = LocationPolygon(points, 0, emptyList())
591 val success = polygonMapObject!!.setPolygon(polygon)
592 println("Set polygon with ${points.size} points: $success")
593 // [kotlin_PolygonMapObject_setPolygon]
595 // [kotlin_PolygonMapObject_setColor]
597 val colorSuccess = polygonMapObject!!.setColor(0xB300FF00.toInt())
598 println("Set polygon color to green with 70% opacity: $colorSuccess")
599 // [kotlin_PolygonMapObject_setColor]
601 // [kotlin_PolygonMapObject_setOrder]
602 // Set polygon rendering order
603 val orderSuccess = polygonMapObject!!.setOrder(2)
604 println("Set polygon rendering order to 2: $orderSuccess")
605 // [kotlin_PolygonMapObject_setOrder]
607 // [kotlin_PolygonMapObject_setOutlineColor]
608 // Set polygon outline color
609 val outlineColorSuccess = polygonMapObject!!.setOutlineColor(0xFF0000FF.toInt())
610 println("Set polygon outline color to blue: $outlineColorSuccess")
611 // [kotlin_PolygonMapObject_setOutlineColor]
613 // [kotlin_PolygonMapObject_setOutlineWidth]
614 // Set polygon outline width
615 val outlineWidthSuccess = polygonMapObject!!.setOutlineWidth(2.0)
616 println("Set polygon outline width to 2.0 pixels: $outlineWidthSuccess")
617 // [kotlin_PolygonMapObject_setOutlineWidth]
619 // [kotlin_PolygonMapObject_setOutlineAlpha]
620 // Set polygon outline alpha
621 val outlineAlphaSuccess = polygonMapObject!!.setOutlineAlpha(0.8)
622 println("Set polygon outline alpha to 0.8: $outlineAlphaSuccess")
623 // [kotlin_PolygonMapObject_setOutlineAlpha]
625 // [kotlin_PolygonMapObject_setOutlineOrder]
626 // Set polygon outline order
627 val outlineOrderSuccess = polygonMapObject!!.setOutlineOrder(1)
628 println("Set polygon outline order to 1: $outlineOrderSuccess")
629 // [kotlin_PolygonMapObject_setOutlineOrder]
631 // [kotlin_PolygonMapObject_setVisible]
633 val visibleSuccess = polygonMapObject!!.setVisible(true)
634 println("Set polygon visibility to true: $visibleSuccess")
635 // [kotlin_PolygonMapObject_setVisible]
637 // [kotlin_PolygonMapObject_getMapObjectType]
638 // Get map object type
639 val objectType = polygonMapObject!!.mapObjectType
640 println("Polygon map object type: $objectType")
641 // [kotlin_PolygonMapObject_getMapObjectType]
643 // [kotlin_MapObject_setAlpha_2]
644 // Set alpha transparency
645 val alphaSuccess = polygonMapObject!!.setAlpha(0.6)
646 println("Set polygon alpha to 0.6: $alphaSuccess")
647 // [kotlin_MapObject_setAlpha_2]
649 // [kotlin_MapObject_setInteractive_2]
650 // Set interactive mode
651 val interactiveSuccess = polygonMapObject!!.setInteractive(true)
652 println("Set polygon interactive to true: $interactiveSuccess")
653 // [kotlin_MapObject_setInteractive_2]
655 // [kotlin_MapObject_setTitle_2]
657 val titleSuccess = polygonMapObject!!.setTitle("Polygon Object")
658 println("Set polygon title to 'Polygon Object': $titleSuccess")
659 // [kotlin_MapObject_setTitle_2]
661 // [kotlin_MapObject_setData_2]
663 val customData = mapOf("key" to "value", "number" to "42")
664 val dataSuccess = polygonMapObject!!.setData(customData)
665 println("Set polygon custom data: $dataSuccess")
666 // [kotlin_MapObject_setData_2]
668 // [kotlin_MapObject_getId_2]
670 val objectId = polygonMapObject!!.id
671 println("Polygon object ID: $objectId")
672 // [kotlin_MapObject_getId_2]
674 // [kotlin_MapObject_getType_2]
676 val objectTypeString = polygonMapObject!!.type
677 println("Polygon object type: $objectTypeString")
678 // [kotlin_MapObject_getType_2]
680 // [kotlin_MapObject_getData_2]
682 val retrievedData = polygonMapObject!!.data
683 println("Polygon custom data: $retrievedData")
684 // [kotlin_MapObject_getData_2]
687 // [kotlin_LocationWindow_removePolygonMapObject]
688 // Remove polygon map object
689 if (polygonMapObject != null) {
690 val removed = locationWindow!!.removePolygonMapObject(polygonMapObject!!)
691 println("Removed polygon map object: $removed")
692 polygonMapObject = null
694 // [kotlin_LocationWindow_removePolygonMapObject]
696 // Test multiple polygon objects
697 val polygons = mutableListOf<PolygonMapObject>()
699 val polygon = locationWindow!!.addPolygonMapObject()
700 if (polygon != null) {
702 Point(300.0 + i * 50, 400.0 + i * 50),
703 Point(350.0 + i * 50, 450.0 + i * 50),
704 Point(400.0 + i * 50, 400.0 + i * 50),
705 Point(350.0 + i * 50, 350.0 + i * 50)
707 val polygonGeometry = LocationPolygon(points, 0, emptyList())
708 polygon.setPolygon(polygonGeometry)
709 polygon.setColor(0x800000FF.toInt())
710 polygons.add(polygon)
711 println("Created polygon $i with ${points.size} points")
715 for (i in polygons.indices) {
716 locationWindow!!.removePolygonMapObject(polygons[i])
717 println("Removed polygon $i")
722 * Demonstrate polyline map objects
724 private fun demonstratePolylineMapObjects() {
725 println("--- Polyline Map Objects ---")
727 if (locationWindow == null) {
728 println("LocationWindow not available yet")
732 // [kotlin_PolylineMapObject_constructor]
733 // Create polyline map object
740 val polyline = LocationPolyline(points, 0)
741 polylineMapObject = locationWindow!!.addPolylineMapObject()
742 println("Created polyline map object with ${points.size} points")
743 // [kotlin_PolylineMapObject_constructor]
745 // [kotlin_PolylineMapObject_getPolyline]
747 val polylineShape = polylineMapObject!!.getPolyLine()
748 println("Polyline has ${polylineShape.points.size} points")
749 // [kotlin_PolylineMapObject_getPolyline]
751 // [kotlin_LocationWindow_addPolylineMapObject]
752 // Add polyline map object
753 polylineMapObject = locationWindow!!.addPolylineMapObject()
754 println("Added polyline map object")
755 // [kotlin_LocationWindow_addPolylineMapObject]
757 if (polylineMapObject != null) {
758 // [kotlin_PolylineMapObject_setPolyLine]
759 // Set polyline geometry
766 val polyline = LocationPolyline(points, 0)
767 val success = polylineMapObject!!.setPolyLine(polyline)
768 println("Set polyline with ${points.size} points: $success")
769 // [kotlin_PolylineMapObject_setPolyLine]
771 // [kotlin_PolylineMapObject_setDrawnFraction]
772 polylineMapObject!!.setDrawnFraction(0f)
773 // [kotlin_PolylineMapObject_setDrawnFraction]
775 // [kotlin_PolylineMapObject_setDrawnFractionAnimated]
776 val grew = polylineMapObject!!.setDrawnFractionAnimated(1f, 1.0f, AnimationType.LINEAR)
777 println("Polyline grow started: $grew")
778 // [kotlin_PolylineMapObject_setDrawnFractionAnimated]
780 // [kotlin_PolylineMapObject_drawnFraction]
781 println("Drawn fraction: ${polylineMapObject!!.drawnFraction}")
782 // [kotlin_PolylineMapObject_drawnFraction]
784 // [kotlin_PolylineMapObject_setWidth]
785 // Set polyline width
786 val widthSuccess = polylineMapObject!!.setWidth(3.0)
787 println("Set polyline width to 3.0 pixels: $widthSuccess")
788 // [kotlin_PolylineMapObject_setWidth]
790 // [kotlin_PolylineMapObject_setColor]
791 // Set polyline color
792 val colorSuccess = polylineMapObject!!.setColor(0xCC00FF00.toInt())
793 println("Set polyline color to green with 80% opacity: $colorSuccess")
794 // [kotlin_PolylineMapObject_setColor]
796 // [kotlin_PolylineMapObject_setDashLength]
797 // Set dash segment length
798 val dashSuccess = polylineMapObject!!.setDashLength(3.0)
799 println("Set polyline dash length: $dashSuccess")
800 // [kotlin_PolylineMapObject_setDashLength]
802 // [kotlin_PolylineMapObject_dashLength]
803 // Get dash segment length
804 val dashLength = polylineMapObject!!.dashLength()
805 println("Polyline dash length: $dashLength")
806 // [kotlin_PolylineMapObject_dashLength]
808 // [kotlin_PolylineMapObject_setGapLength]
809 // Set gap length between dashes
810 val gapSuccess = polylineMapObject!!.setGapLength(1.0)
811 println("Set polyline gap length: $gapSuccess")
812 // [kotlin_PolylineMapObject_setGapLength]
814 // [kotlin_PolylineMapObject_gapLength]
815 // Get gap length between dashes
816 val gapLength = polylineMapObject!!.gapLength()
817 println("Polyline gap length: $gapLength")
818 // [kotlin_PolylineMapObject_gapLength]
820 // [kotlin_PolylineMapObject_setOrder]
821 // Set polyline rendering order
822 val orderSuccess = polylineMapObject!!.setOrder(1)
823 println("Set polyline rendering order to 1: $orderSuccess")
824 // [kotlin_PolylineMapObject_setOrder]
826 // [kotlin_PolylineMapObject_setCapType]
827 // Set polyline cap type
828 val capTypeSuccess = polylineMapObject!!.setCapType(CapType.ROUND)
829 println("Set polyline cap type to ROUND: $capTypeSuccess")
830 // [kotlin_PolylineMapObject_setCapType]
832 // [kotlin_PolylineMapObject_setJoinType]
833 // Set polyline join type
834 val joinTypeSuccess = polylineMapObject!!.setJoinType(JoinType.ROUND)
835 println("Set polyline join type to ROUND: $joinTypeSuccess")
836 // [kotlin_PolylineMapObject_setJoinType]
838 // [kotlin_PolylineMapObject_setMiterLimit]
839 // Set polyline miter limit
840 val miterLimitSuccess = polylineMapObject!!.setMiterLimit(2.0)
841 println("Set polyline miter limit to 2.0: $miterLimitSuccess")
842 // [kotlin_PolylineMapObject_setMiterLimit]
844 // [kotlin_PolylineMapObject_setOutlineWidth]
845 // Set polyline outline width
846 val outlineWidthSuccess = polylineMapObject!!.setOutlineWidth(1.0)
847 println("Set polyline outline width to 1.0 pixels: $outlineWidthSuccess")
848 // [kotlin_PolylineMapObject_setOutlineWidth]
850 // [kotlin_PolylineMapObject_setOutlineColor]
851 // Set polyline outline color
852 val outlineColorSuccess = polylineMapObject!!.setOutlineColor(0xFF000000.toInt())
853 println("Set polyline outline color to black: $outlineColorSuccess")
854 // [kotlin_PolylineMapObject_setOutlineColor]
856 // [kotlin_PolylineMapObject_setOutlineAlpha]
857 // Set polyline outline alpha
858 val outlineAlphaSuccess = polylineMapObject!!.setOutlineAlpha(0.5)
859 println("Set polyline outline alpha to 0.5: $outlineAlphaSuccess")
860 // [kotlin_PolylineMapObject_setOutlineAlpha]
862 // [kotlin_PolylineMapObject_setOutlineOrder]
863 // Set polyline outline rendering order
864 val outlineOrderSuccess = polylineMapObject!!.setOutlineOrder(0)
865 println("Set polyline outline rendering order to 0: $outlineOrderSuccess")
866 // [kotlin_PolylineMapObject_setOutlineOrder]
868 // [kotlin_PolylineMapObject_setOutlineCapType]
869 // Set polyline outline cap type
870 val outlineCapTypeSuccess = polylineMapObject!!.setOutlineCapType(CapType.SQUARE)
871 println("Set polyline outline cap type to SQUARE: $outlineCapTypeSuccess")
872 // [kotlin_PolylineMapObject_setOutlineCapType]
874 // [kotlin_PolylineMapObject_setOutlineJoinType]
875 // Set polyline outline join type
876 val outlineJoinTypeSuccess = polylineMapObject!!.setOutlineJoinType(JoinType.MITER)
877 println("Set polyline outline join type to MITER: $outlineJoinTypeSuccess")
878 // [kotlin_PolylineMapObject_setOutlineJoinType]
880 // [kotlin_PolylineMapObject_setOutlineMiterLimit]
881 // Set polyline outline miter limit
882 val outlineMiterLimitSuccess = polylineMapObject!!.setOutlineMiterLimit(3.0)
883 println("Set polyline outline miter limit to 3.0: $outlineMiterLimitSuccess")
884 // [kotlin_PolylineMapObject_setOutlineMiterLimit]
886 // [kotlin_PolylineMapObject_setVisible]
888 val visibleSuccess = polylineMapObject!!.setVisible(true)
889 println("Set polyline visibility to true: $visibleSuccess")
890 // [kotlin_PolylineMapObject_setVisible]
892 // [kotlin_PolylineMapObject_getMapObjectType]
893 // Get map object type
894 val objectType = polylineMapObject!!.mapObjectType
895 println("Polyline map object type: $objectType")
896 // [kotlin_PolylineMapObject_getMapObjectType]
898 // [kotlin_MapObject_setAlpha_3]
899 // Set alpha transparency
900 val alphaSuccess = polylineMapObject!!.setAlpha(0.7)
901 println("Set polyline alpha to 0.7: $alphaSuccess")
902 // [kotlin_MapObject_setAlpha_3]
904 // [kotlin_MapObject_setInteractive_3]
905 // Set interactive mode
906 val interactiveSuccess = polylineMapObject!!.setInteractive(true)
907 println("Set polyline interactive to true: $interactiveSuccess")
908 // [kotlin_MapObject_setInteractive_3]
910 // [kotlin_MapObject_setTitle_3]
912 val titleSuccess = polylineMapObject!!.setTitle("Polyline Object")
913 println("Set polyline title to 'Polyline Object': $titleSuccess")
914 // [kotlin_MapObject_setTitle_3]
916 // [kotlin_MapObject_setData_3]
918 val customData = mapOf("key" to "value", "number" to "42")
919 val dataSuccess = polylineMapObject!!.setData(customData)
920 println("Set polyline custom data: $dataSuccess")
921 // [kotlin_MapObject_setData_3]
923 // [kotlin_MapObject_getId_3]
925 val objectId = polylineMapObject!!.id
926 println("Polyline object ID: $objectId")
927 // [kotlin_MapObject_getId_3]
929 // [kotlin_MapObject_getType_3]
931 val objectTypeString = polylineMapObject!!.type
932 println("Polyline object type: $objectTypeString")
933 // [kotlin_MapObject_getType_3]
935 // [kotlin_MapObject_getData_3]
937 val retrievedData = polylineMapObject!!.data
938 println("Polyline custom data: $retrievedData")
939 // [kotlin_MapObject_getData_3]
942 // [kotlin_LocationWindow_removePolylineMapObject]
943 // Remove polyline map object
944 if (polylineMapObject != null) {
945 val removed = locationWindow!!.removePolylineMapObject(polylineMapObject!!)
946 println("Removed polyline map object: $removed")
947 polylineMapObject = null
949 // [kotlin_LocationWindow_removePolylineMapObject]
951 // Test multiple polyline objects
952 val polylines = mutableListOf<PolylineMapObject>()
954 val polyline = locationWindow!!.addPolylineMapObject()
955 if (polyline != null) {
957 Point(120.0 + i * 30, 130.0 + i * 30),
958 Point(125.0 + i * 30, 135.0 + i * 30),
959 Point(130.0 + i * 30, 140.0 + i * 30)
961 val polylineGeometry = LocationPolyline(points, 0)
962 polyline.setPolyLine(polylineGeometry)
963 polyline.setColor(0x99FF0000.toInt())
964 polyline.setWidth(2.0)
965 polylines.add(polyline)
966 println("Created polyline $i with ${points.size} points")
970 for (i in polylines.indices) {
971 locationWindow!!.removePolylineMapObject(polylines[i])
972 println("Removed polyline $i")
977 * Demonstrate dotted polyline map objects
979 private fun demonstrateDottedPolylineMapObjects() {
980 println("--- Dotted Polyline Map Objects ---")
982 if (locationWindow == null) {
983 println("LocationWindow not available yet")
987 // [kotlin_DottedPolylineMapObject_constructor]
988 // Create dotted polyline map object
995 val polyline = LocationPolyline(points, 0)
996 dottedPolylineMapObject = locationWindow!!.addDottedPolylineMapObject()
997 println("Created dotted polyline map object with ${points.size} points")
998 // [kotlin_DottedPolylineMapObject_constructor]
1000 // [kotlin_DottedPolylineMapObject_getPolyline]
1001 // Access dotted polyline
1002 val dottedPolylineShape = dottedPolylineMapObject!!.getPolyLine()
1003 println("Dotted polyline has ${dottedPolylineShape.points.size} points")
1004 // [kotlin_DottedPolylineMapObject_getPolyline]
1006 // [kotlin_LocationWindow_addDottedPolylineMapObject]
1007 // Add dotted polyline map object
1008 dottedPolylineMapObject = locationWindow!!.addDottedPolylineMapObject()
1009 println("Added dotted polyline map object")
1010 // [kotlin_LocationWindow_addDottedPolylineMapObject]
1012 if (dottedPolylineMapObject != null) {
1013 // [kotlin_DottedPolylineMapObject_setPolyline]
1014 // Set dotted polyline geometry
1015 val points = listOf(
1016 Point(160.0, 170.0),
1017 Point(165.0, 175.0),
1018 Point(170.0, 180.0),
1021 val polyline = LocationPolyline(points, 0)
1022 val success = dottedPolylineMapObject!!.setPolyline(polyline)
1023 println("Set dotted polyline with ${points.size} points: $success")
1024 // [kotlin_DottedPolylineMapObject_setPolyline]
1026 // [kotlin_DottedPolylineMapObject_setColor]
1027 // Set dotted polyline color
1028 val colorSuccess = dottedPolylineMapObject!!.setColor(0xCC8000FF.toInt())
1029 println("Set dotted polyline color to purple with 80% opacity: $colorSuccess")
1030 // [kotlin_DottedPolylineMapObject_setColor]
1032 // [kotlin_DottedPolylineMapObject_setWidth]
1033 // Set dotted polyline width
1034 val widthSuccess = dottedPolylineMapObject!!.setWidth(3.0)
1035 println("Set dotted polyline width to 3.0 pixels: $widthSuccess")
1036 // [kotlin_DottedPolylineMapObject_setWidth]
1038 // [kotlin_DottedPolylineMapObject_setOrder]
1039 // Set dotted polyline rendering order
1040 val orderSuccess = dottedPolylineMapObject!!.setOrder(2)
1041 println("Set dotted polyline rendering order to 2: $orderSuccess")
1042 // [kotlin_DottedPolylineMapObject_setOrder]
1044 // [kotlin_DottedPolylineMapObject_setCollisionEnabled]
1045 // Enable collision detection
1046 val collisionSuccess = dottedPolylineMapObject!!.setCollisionEnabled(true)
1047 println("Enabled collision detection for dotted polyline: $collisionSuccess")
1048 // [kotlin_DottedPolylineMapObject_setCollisionEnabled]
1050 // [kotlin_DottedPolylineMapObject_setPlacement]
1051 // Set placement type
1052 val placementSuccess = dottedPolylineMapObject!!.setPlacement(Placement.CENTER)
1053 println("Set dotted polyline placement to CENTER: $placementSuccess")
1054 // [kotlin_DottedPolylineMapObject_setPlacement]
1056 // [kotlin_DottedPolylineMapObject_setPlacementMinRatio]
1057 // Set placement min ratio
1058 val minRatioSuccess = dottedPolylineMapObject!!.setPlacementMinRatio(0.5)
1059 println("Set dotted polyline placement min ratio to 0.5: $minRatioSuccess")
1060 // [kotlin_DottedPolylineMapObject_setPlacementMinRatio]
1062 // [kotlin_DottedPolylineMapObject_setPlacementSpacing]
1063 // Set placement spacing
1064 val spacingSuccess = dottedPolylineMapObject!!.setPlacementSpacing(10.0)
1065 println("Set dotted polyline placement spacing to 10.0: $spacingSuccess")
1066 // [kotlin_DottedPolylineMapObject_setPlacementSpacing]
1068 // [kotlin_DottedPolylineMapObject_setPriority]
1069 // Set rendering priority
1070 val prioritySuccess = dottedPolylineMapObject!!.setPriority(1)
1071 println("Set dotted polyline rendering priority to 1: $prioritySuccess")
1072 // [kotlin_DottedPolylineMapObject_setPriority]
1074 // [kotlin_DottedPolylineMapObject_setRepeatDistance]
1075 // Set repeat distance
1076 val repeatDistanceSuccess = dottedPolylineMapObject!!.setRepeatDistance(20.0)
1077 println("Set dotted polyline repeat distance to 20.0: $repeatDistanceSuccess")
1078 // [kotlin_DottedPolylineMapObject_setRepeatDistance]
1080 // [kotlin_DottedPolylineMapObject_setRepeatGroup]
1082 val repeatGroupSuccess = dottedPolylineMapObject!!.setRepeatGroup(1)
1083 println("Set dotted polyline repeat group to 1: $repeatGroupSuccess")
1084 // [kotlin_DottedPolylineMapObject_setRepeatGroup]
1086 // [kotlin_DottedPolylineMapObject_setSize]
1088 val size = Size(16.0, 16.0)
1089 val sizeSuccess = dottedPolylineMapObject!!.setSize(size)
1090 println("Set dotted polyline size to (${size.width}, ${size.height}): $sizeSuccess")
1091 // [kotlin_DottedPolylineMapObject_setSize]
1093 // [kotlin_DottedPolylineMapObject_setVisible]
1095 val visibleSuccess = dottedPolylineMapObject!!.setVisible(true)
1096 println("Set dotted polyline visibility to true: $visibleSuccess")
1097 // [kotlin_DottedPolylineMapObject_setVisible]
1099 // [kotlin_DottedPolylineMapObject_getMapObjectType]
1100 // Get map object type
1101 val objectType = dottedPolylineMapObject!!.mapObjectType
1102 println("Dotted polyline map object type: $objectType")
1103 // [kotlin_DottedPolylineMapObject_getMapObjectType]
1105 // [kotlin_MapObject_setAlpha_4]
1106 // Set alpha transparency
1107 val alphaSuccess = dottedPolylineMapObject!!.setAlpha(0.8)
1108 println("Set dotted polyline alpha to 0.8: $alphaSuccess")
1109 // [kotlin_MapObject_setAlpha_4]
1111 // [kotlin_MapObject_setInteractive_4]
1112 // Set interactive mode
1113 val interactiveSuccess = dottedPolylineMapObject!!.setInteractive(true)
1114 println("Set dotted polyline interactive to true: $interactiveSuccess")
1115 // [kotlin_MapObject_setInteractive_4]
1117 // [kotlin_MapObject_setTitle_4]
1119 val titleSuccess = dottedPolylineMapObject!!.setTitle("Dotted Polyline Object")
1120 println("Set dotted polyline title to 'Dotted Polyline Object': $titleSuccess")
1121 // [kotlin_MapObject_setTitle_4]
1123 // [kotlin_MapObject_setData_4]
1125 val customData = mapOf("key" to "value", "number" to "42")
1126 val dataSuccess = dottedPolylineMapObject!!.setData(customData)
1127 println("Set dotted polyline custom data: $dataSuccess")
1128 // [kotlin_MapObject_setData_4]
1130 // [kotlin_MapObject_getId_4]
1132 val objectId = dottedPolylineMapObject!!.id
1133 println("Dotted polyline object ID: $objectId")
1134 // [kotlin_MapObject_getId_4]
1136 // [kotlin_MapObject_getType_4]
1138 val objectTypeString = dottedPolylineMapObject!!.type
1139 println("Dotted polyline object type: $objectTypeString")
1140 // [kotlin_MapObject_getType_4]
1142 // [kotlin_MapObject_getData_4]
1144 val retrievedData = dottedPolylineMapObject!!.data
1145 println("Dotted polyline custom data: $retrievedData")
1146 // [kotlin_MapObject_getData_4]
1149 // [kotlin_LocationWindow_removeDottedPolylineMapObject]
1150 // Remove dotted polyline map object
1151 if (dottedPolylineMapObject != null) {
1152 val removed = locationWindow!!.removeDottedPolylineMapObject(dottedPolylineMapObject!!)
1153 println("Removed dotted polyline map object: $removed")
1154 dottedPolylineMapObject = null
1156 // [kotlin_LocationWindow_removeDottedPolylineMapObject]
1158 // Test multiple dotted polyline objects
1159 val dottedPolylines = mutableListOf<DottedPolylineMapObject>()
1161 val dottedPolyline = locationWindow!!.addDottedPolylineMapObject()
1162 if (dottedPolyline != null) {
1163 val points = listOf(
1164 Point(180.0 + i * 30, 190.0 + i * 30),
1165 Point(185.0 + i * 30, 195.0 + i * 30),
1166 Point(190.0 + i * 30, 200.0 + i * 30)
1168 val polylineGeometry = LocationPolyline(points, 0)
1169 dottedPolyline.setPolyline(polylineGeometry)
1170 dottedPolylines.add(dottedPolyline)
1171 println("Created dotted polyline $i with ${points.size} points")
1175 for (i in dottedPolylines.indices) {
1176 locationWindow!!.removeDottedPolylineMapObject(dottedPolylines[i])
1177 println("Removed dotted polyline $i")
1182 * Demonstrate icon clustering via ClusterMapObjectController.
1184 private fun demonstrateClusterMapObjects() {
1185 println("--- Cluster map objects ---")
1187 if (locationWindow == null) {
1188 println("LocationWindow not available")
1192 // [kotlin_LocationWindow_addClusterMapObjectController]
1193 clusterMapObjectController = locationWindow!!.addClusterMapObjectController()
1194 println("Added cluster map object controller")
1195 // [kotlin_LocationWindow_addClusterMapObjectController]
1197 val controller = clusterMapObjectController ?: return
1199 val clusterIcon1 = locationWindow!!.addIconMapObject()
1200 val clusterIcon2 = locationWindow!!.addIconMapObject()
1201 clusterIcon1?.setPosition(GlobalPoint(100.0, 100.0))
1202 clusterIcon2?.setPosition(GlobalPoint(105.0, 102.0))
1204 // [kotlin_ClusterMapObjectController_addIconMapObject]
1205 val added1 = controller.addIconMapObject(clusterIcon1)
1206 val added2 = controller.addIconMapObject(clusterIcon2)
1207 println("Registered icons for clustering: $added1, $added2")
1208 // [kotlin_ClusterMapObjectController_addIconMapObject]
1210 // [kotlin_ClusterMapObjectController_setEnabled]
1211 controller.setEnabled(true)
1212 println("Clustering enabled")
1213 // [kotlin_ClusterMapObjectController_setEnabled]
1215 // [kotlin_ClusterMapObjectController_isEnabled]
1216 val clusteringEnabled = controller.isEnabled
1217 println("Clustering is enabled: $clusteringEnabled")
1218 // [kotlin_ClusterMapObjectController_isEnabled]
1220 // [kotlin_ClusterMapObjectController_setRadius]
1221 controller.setRadius(40.0f)
1222 println("Set cluster radius to 40 px")
1223 // [kotlin_ClusterMapObjectController_setRadius]
1225 // [kotlin_ClusterMapObjectController_getRadius]
1226 val clusterRadius = controller.getRadius()
1227 println("Cluster radius: $clusterRadius")
1228 // [kotlin_ClusterMapObjectController_getRadius]
1230 // [kotlin_ClusterMapObjectController_setInteractive]
1231 val interactiveSuccess = controller.setInteractive(true)
1232 println("Set cluster markers interactive: $interactiveSuccess")
1233 // [kotlin_ClusterMapObjectController_setInteractive]
1235 // [kotlin_ClusterMapObjectController_setClusterSize]
1236 val sizeSuccess = controller.setClusterSize(32.0f, 32.0f)
1237 println("Set default cluster icon size: $sizeSuccess")
1238 // [kotlin_ClusterMapObjectController_setClusterSize]
1240 clusterMapObjectControllerListener = DemoClusterMapObjectControllerListener()
1242 // [kotlin_ClusterMapObjectController_addListener]
1243 controller.addListener(clusterMapObjectControllerListener!!)
1244 println("Added cluster map object listener")
1245 // [kotlin_ClusterMapObjectController_addListener]
1247 // [kotlin_ClusterMapObjectController_getClusters]
1248 val clusters = controller.getClusters()
1249 println("Visible clusters: ${clusters.size}")
1250 // [kotlin_ClusterMapObjectController_getClusters]
1252 if (clusters.isNotEmpty()) {
1253 val cluster = clusters[0]
1254 // [kotlin_ClusterMapObject_setBitmap]
1255 val clusterBitmap = ImageProvider.fromFile("/path/to/cluster.png", true)
1256 val bitmapSuccess = cluster.setBitmap(clusterBitmap)
1257 println("Set cluster bitmap from ImageProvider: $bitmapSuccess")
1258 // [kotlin_ClusterMapObject_setBitmap]
1261 // [kotlin_ClusterMapObjectController_removeListener]
1262 controller.removeListener(clusterMapObjectControllerListener!!)
1263 println("Removed cluster map object listener")
1264 // [kotlin_ClusterMapObjectController_removeListener]
1267 // [kotlin_ClusterMapObjectController_removeIconMapObject]
1268 val removed = controller.removeIconMapObject(it)
1269 println("Removed icon from cluster controller: $removed")
1270 // [kotlin_ClusterMapObjectController_removeIconMapObject]
1271 locationWindow!!.removeIconMapObject(it)
1273 clusterIcon2?.let { locationWindow!!.removeIconMapObject(it) }
1275 // [kotlin_ClusterMapObjectController_clear]
1277 println("Cleared cluster controller")
1278 // [kotlin_ClusterMapObjectController_clear]
1280 // [kotlin_LocationWindow_removeClusterMapObjectController]
1281 val controllerRemoved =
1282 locationWindow!!.removeClusterMapObjectController(controller)
1283 println("Removed cluster map object controller: $controllerRemoved")
1284 // [kotlin_LocationWindow_removeClusterMapObjectController]
1286 clusterMapObjectController = null
1287 clusterMapObjectControllerListener = null
1291 * Demonstrate remove all map objects
1293 private fun demonstrateRemoveAllMapObjects() {
1294 println("--- Remove All Map Objects ---")
1296 if (locationWindow == null) {
1297 println("LocationWindow not available yet")
1301 println("Current map objects count: ${getMapObjectsCount()}")
1303 // [kotlin_LocationWindow_removeAllMapObjects]
1304 // Remove all map objects
1305 locationWindow!!.removeAllMapObjects()
1306 println("Removed all map objects")
1307 // [kotlin_LocationWindow_removeAllMapObjects]
1309 println("Map objects count after removal: ${getMapObjectsCount()}")
1313 * Get current map objects count
1315 private fun getMapObjectsCount(): Int {
1317 if (circleMapObject != null) count++
1318 if (iconMapObject != null) count++
1319 if (polygonMapObject != null) count++
1320 if (polylineMapObject != null) count++
1321 if (dottedPolylineMapObject != null) count++
1328 private fun cleanup() {
1329 println("--- Cleanup ---")
1331 if (locationWindow != null) {
1332 locationWindow!!.removeAllMapObjects()
1333 println("Cleaned up all map objects")
1336 circleMapObject = null
1337 iconMapObject = null
1338 modelMapObject = null
1339 polygonMapObject = null
1340 polylineMapObject = null
1341 dottedPolylineMapObject = null
1342 println("Cleared map objects references")
1346class DemoClusterMapObjectControllerListener : ClusterMapObjectControllerListener {
1347 private val clusterChangeListener = DemoClusterMapObjectListener()
1348 private var activeCluster: ClusterMapObject? = null
1350 // [kotlin_ClusterMapObjectControllerListener_onClusterCreated]
1351 override fun onClusterCreated(controller: ClusterMapObjectController, cluster: ClusterMapObject) {
1352 // [kotlin_ClusterMapObject_addListener]
1353 cluster.addListener(clusterChangeListener)
1354 println("Added cluster change listener, initial count: ${cluster.count}")
1355 // [kotlin_ClusterMapObject_addListener]
1356 activeCluster = cluster
1358 // [kotlin_ClusterMapObjectControllerListener_onClusterCreated]
1360 // [kotlin_ClusterMapObjectControllerListener_onClusterDestroyed]
1361 override fun onClusterDestroyed(controller: ClusterMapObjectController, clusterId: Int) {
1362 val cluster = activeCluster
1363 if (cluster != null && cluster.id == clusterId) {
1364 // [kotlin_ClusterMapObject_removeListener]
1365 cluster.removeListener(clusterChangeListener)
1366 println("Removed cluster change listener")
1367 // [kotlin_ClusterMapObject_removeListener]
1368 activeCluster = null
1370 println("Cluster destroyed, id: $clusterId")
1372 // [kotlin_ClusterMapObjectControllerListener_onClusterDestroyed]
1375class DemoClusterMapObjectListener : ClusterMapObjectListener {
1377 // [kotlin_ClusterMapObjectListener_onClusterChanged]
1378 override fun onClusterChanged(cluster: ClusterMapObject) {
1379 val memberCount = cluster.getCount()
1380 println("Cluster changed, member count: $memberCount")
1382 // [kotlin_ClusterMapObjectListener_onClusterChanged]
1385// Main function to run the example
1387 LocationWindowMapObjectsExample()