1package com.navigine.examples
3import com.navigine.idl.kotlin.LocationWindow
4import com.navigine.idl.kotlin.CircleMapObject
5import com.navigine.idl.kotlin.IconMapObject
6import com.navigine.idl.kotlin.PolygonMapObject
7import com.navigine.idl.kotlin.PolylineMapObject
8import com.navigine.idl.kotlin.DottedPolylineMapObject
9import com.navigine.idl.kotlin.AnimationType
10import com.navigine.idl.kotlin.CapType
11import com.navigine.idl.kotlin.JoinType
12import com.navigine.idl.kotlin.LocationPoint
13import com.navigine.idl.kotlin.LocationPolygon
14import com.navigine.idl.kotlin.LocationPolyline
15import com.navigine.idl.kotlin.MapObjectType
16import com.navigine.idl.kotlin.Placement
17import com.navigine.idl.kotlin.Color
18import com.navigine.idl.kotlin.Size
19import com.navigine.idl.kotlin.Point
22 * LocationWindowMapObjects usage example for Kotlin
23 * Demonstrates specific methods: addCircleMapObject, removeCircleMapObject, addIconMapObject,
24 * removeIconMapObject, addPolygonMapObject, addPolylineMapObject, removePolylineMapObject,
25 * addDottedPolylineMapObject, removeDottedPolylineMapObject, removeAllMapObjects
27class LocationWindowMapObjectsExample {
28 private var locationWindow: LocationWindow? = null
29 private var circleMapObject: CircleMapObject? = null
30 private var iconMapObject: IconMapObject? = null
31 private var polygonMapObject: PolygonMapObject? = null
32 private var polylineMapObject: PolylineMapObject? = null
33 private var dottedPolylineMapObject: DottedPolylineMapObject? = null
36 demonstrateLocationWindowMapObjectsMethods()
40 * Demonstrate LocationWindowMapObjects methods
42 private fun demonstrateLocationWindowMapObjectsMethods() {
43 println("=== LocationWindowMapObjects Example ===")
45 // Initialize LocationWindow (in real app, this would be provided by the framework)
46 // locationWindow = getLocationWindow()
48 demonstrateCircleMapObjects()
49 demonstrateIconMapObjects()
50 demonstratePolygonMapObjects()
51 demonstratePolylineMapObjects()
52 demonstrateDottedPolylineMapObjects()
53 demonstrateRemoveAllMapObjects()
59 * Demonstrate circle map objects
61 private fun demonstrateCircleMapObjects() {
62 println("--- Circle Map Objects ---")
64 if (locationWindow == null) {
65 println("LocationWindow not available yet")
69 // [kotlin_CircleMapObject_constructor]
70 // Create circle map object
71 val center = LocationPoint(10.0, 20.0)
72 circleMapObject = locationWindow!!.addCircleMapObject()
73 println("Created circle map object with center (${center.x}, ${center.y}) and radius 5.0")
74 // [kotlin_CircleMapObject_constructor]
76 // [kotlin_CircleMapObject_getCenter]
77 // Access circle center
78 val circleCenter = circleMapObject!!.getPosition()
79 println("Circle center: (${circleCenter.x}, ${circleCenter.y})")
80 // [kotlin_CircleMapObject_getCenter]
82 // [kotlin_CircleMapObject_getRadius]
83 // Access circle radius
84 val radius = circleMapObject!!.getRadius()
85 println("Circle radius: $radius")
86 // [kotlin_CircleMapObject_getRadius]
88 // [kotlin_LocationWindow_addCircleMapObject]
89 // Add circle map object
90 circleMapObject = locationWindow!!.addCircleMapObject()
91 println("Added circle map object")
92 // [kotlin_LocationWindow_addCircleMapObject]
94 if (circleMapObject != null) {
95 // [kotlin_CircleMapObject_setPosition]
96 // Set circle position
97 val centerPoint = LocationPoint(100.0, 200.0)
98 val success = circleMapObject!!.setPosition(centerPoint)
99 println("Set circle position to (${centerPoint.x}, ${centerPoint.y}): $success")
100 // [kotlin_CircleMapObject_setPosition]
102 // [kotlin_CircleMapObject_setPositionAnimated]
103 // Set circle position with animation
104 val animatedPoint = LocationPoint(150.0, 250.0)
105 val animatedSuccess = circleMapObject!!.setPositionAnimated(animatedPoint, 2.0, AnimationType.LINEAR)
106 println("Set circle position with animation to (${animatedPoint.x}, ${animatedPoint.y}): $animatedSuccess")
107 // [kotlin_CircleMapObject_setPositionAnimated]
109 // [kotlin_CircleMapObject_setRadius]
111 val radiusSuccess = circleMapObject!!.setRadius(10.0)
112 println("Set circle radius to 10.0 meters: $radiusSuccess")
113 // [kotlin_CircleMapObject_setRadius]
115 // [kotlin_CircleMapObject_setCollisionEnabled]
116 // Enable collision detection
117 val collisionSuccess = circleMapObject!!.setCollisionEnabled(true)
118 println("Enabled collision detection for circle: $collisionSuccess")
119 // [kotlin_CircleMapObject_setCollisionEnabled]
121 // [kotlin_CircleMapObject_setBuffer]
122 // Set collision buffer
123 val bufferSuccess = circleMapObject!!.setBuffer(5.0, 5.0)
124 println("Set collision buffer to 5x5 pixels: $bufferSuccess")
125 // [kotlin_CircleMapObject_setBuffer]
127 // [kotlin_CircleMapObject_setOffset]
128 // Set position offset
129 val offsetSuccess = circleMapObject!!.setOffset(2.0, 3.0)
130 println("Set position offset to (2.0, 3.0) pixels: $offsetSuccess")
131 // [kotlin_CircleMapObject_setOffset]
133 // [kotlin_CircleMapObject_setOutlineColor]
135 val outlineColorSuccess = circleMapObject!!.setOutlineColor(0.0, 0.0, 1.0, 1.0)
136 println("Set circle outline color to blue: $outlineColorSuccess")
137 // [kotlin_CircleMapObject_setOutlineColor]
139 // [kotlin_CircleMapObject_setOutlineAlpha]
141 val outlineAlphaSuccess = circleMapObject!!.setOutlineAlpha(0.5)
142 println("Set circle outline alpha to 0.5: $outlineAlphaSuccess")
143 // [kotlin_CircleMapObject_setOutlineAlpha]
145 // [kotlin_CircleMapObject_setOutlineRadius]
146 // Set outline radius
147 val outlineRadiusSuccess = circleMapObject!!.setOutlineRadius(2.0)
148 println("Set circle outline radius to 2.0: $outlineRadiusSuccess")
149 // [kotlin_CircleMapObject_setOutlineRadius]
151 // [kotlin_CircleMapObject_setColor]
153 val colorSuccess = circleMapObject!!.setColor(1.0, 0.0, 0.0, 0.8)
154 println("Set circle color to red with 80% opacity: $colorSuccess")
155 // [kotlin_CircleMapObject_setColor]
157 // [kotlin_CircleMapObject_setPriority]
158 // Set rendering priority
159 val prioritySuccess = circleMapObject!!.setPriority(1)
160 println("Set rendering priority to 1: $prioritySuccess")
161 // [kotlin_CircleMapObject_setPriority]
163 // [kotlin_MapObject_setVisible]
165 val visibleSuccess = circleMapObject!!.setVisible(true)
166 println("Set circle visibility to true: $visibleSuccess")
167 // [kotlin_MapObject_setVisible]
169 // [kotlin_CircleMapObject_getMapObjectType]
170 // Get map object type
171 val objectType = circleMapObject!!.mapObjectType
172 println("Circle map object type: $objectType")
173 // [kotlin_CircleMapObject_getMapObjectType]
175 // [kotlin_MapObject_setAlpha]
176 // Set alpha transparency
177 val alphaSuccess = circleMapObject!!.setAlpha(0.7)
178 println("Set circle alpha to 0.7: $alphaSuccess")
179 // [kotlin_MapObject_setAlpha]
181 // [kotlin_MapObject_setInteractive]
182 // Set interactive mode
183 val interactiveSuccess = circleMapObject!!.setInteractive(true)
184 println("Set circle interactive to true: $interactiveSuccess")
185 // [kotlin_MapObject_setInteractive]
187 // [kotlin_MapObject_setTitle]
189 val titleSuccess = circleMapObject!!.setTitle("Circle Object")
190 println("Set circle title to 'Circle Object': $titleSuccess")
191 // [kotlin_MapObject_setTitle]
193 // [kotlin_MapObject_setData]
195 val customData = mapOf("key" to "value", "number" to "42")
196 val dataSuccess = circleMapObject!!.setData(customData)
197 println("Set circle custom data: $dataSuccess")
198 // [kotlin_MapObject_setData]
200 // [kotlin_MapObject_getId]
202 val objectId = circleMapObject!!.id
203 println("Circle object ID: $objectId")
204 // [kotlin_MapObject_getId]
206 // [kotlin_MapObject_getType]
208 val objectTypeString = circleMapObject!!.type
209 println("Circle object type: $objectTypeString")
210 // [kotlin_MapObject_getType]
212 // [kotlin_MapObject_getData]
214 val retrievedData = circleMapObject!!.data
215 println("Circle custom data: $retrievedData")
216 // [kotlin_MapObject_getData]
219 // [kotlin_LocationWindow_removeCircleMapObject]
220 // Remove circle map object
221 if (circleMapObject != null) {
222 val removed = locationWindow!!.removeCircleMapObject(circleMapObject!!)
223 println("Removed circle map object: $removed")
224 circleMapObject = null
226 // [kotlin_LocationWindow_removeCircleMapObject]
228 // Test multiple circle objects
229 val circles = mutableListOf<CircleMapObject>()
231 val circle = locationWindow!!.addCircleMapObject()
232 if (circle != null) {
233 circle.setPosition(LocationPoint(50.0 * i, 100.0 * i))
234 circle.setColor(0.0, 1.0, 0.0, 0.6)
235 circle.setRadius(5.0 + i * 2.0)
237 println("Created circle $i at (${50.0 * i}, ${100.0 * i}) with radius ${5.0 + i * 2.0}")
241 for (i in circles.indices) {
242 locationWindow!!.removeCircleMapObject(circles[i])
243 println("Removed circle $i")
248 * Demonstrate icon map objects
250 private fun demonstrateIconMapObjects() {
251 println("--- Icon Map Objects ---")
253 if (locationWindow == null) {
254 println("LocationWindow not available yet")
258 // [kotlin_IconMapObject_constructor]
259 // Create icon map object
260 val position = LocationPoint(30.0, 40.0)
261 iconMapObject = locationWindow!!.addIconMapObject()
262 println("Created icon map object at (${position.x}, ${position.y})")
263 // [kotlin_IconMapObject_constructor]
265 // [kotlin_IconMapObject_getPosition]
266 // Access icon position
267 val iconPosition = iconMapObject!!.getPosition()
268 println("Icon position: (${iconPosition.x}, ${iconPosition.y})")
269 // [kotlin_IconMapObject_getPosition]
271 // [kotlin_LocationWindow_addIconMapObject]
272 // Add icon map object
273 iconMapObject = locationWindow!!.addIconMapObject()
274 println("Added icon map object")
275 // [kotlin_LocationWindow_addIconMapObject]
277 if (iconMapObject != null) {
278 // [kotlin_IconMapObject_setPosition]
280 val position = LocationPoint(30.0, 40.0)
281 val success = iconMapObject!!.setPosition(position)
282 println("Set icon position to (${position.x}, ${position.y}): $success")
283 // [kotlin_IconMapObject_setPosition]
285 // [kotlin_IconMapObject_setPositionAnimated]
286 // Set icon position with animation
287 val animatedPosition = LocationPoint(35.0, 45.0)
288 val animatedSuccess = iconMapObject!!.setPositionAnimated(animatedPosition, 1.5, AnimationType.CUBIC)
289 println("Set icon position with animation to (${animatedPosition.x}, ${animatedPosition.y}): $animatedSuccess")
290 // [kotlin_IconMapObject_setPositionAnimated]
292 // [kotlin_IconMapObject_setIcon]
294 val iconSuccess = iconMapObject!!.setIcon("path/to/icon.png")
295 println("Set icon image: $iconSuccess")
296 // [kotlin_IconMapObject_setIcon]
298 // [kotlin_IconMapObject_setBitmap]
300 val bitmapSuccess = iconMapObject!!.setBitmap("path/to/bitmap.png")
301 println("Set icon bitmap: $bitmapSuccess")
302 // [kotlin_IconMapObject_setBitmap]
304 // [kotlin_IconMapObject_setFlat]
305 // Set icon flat mode
306 val flatSuccess = iconMapObject!!.setFlat(true)
307 println("Set icon flat mode to true: $flatSuccess")
308 // [kotlin_IconMapObject_setFlat]
310 // [kotlin_IconMapObject_setSize]
312 val size = Size(32.0, 32.0)
313 val sizeSuccess = iconMapObject!!.setSize(size)
314 println("Set icon size to (${size.width}, ${size.height}): $sizeSuccess")
315 // [kotlin_IconMapObject_setSize]
317 // [kotlin_IconMapObject_setAngle]
318 // Set icon rotation angle
319 val angleSuccess = iconMapObject!!.setAngle(45.0)
320 println("Set icon rotation angle to 45 degrees: $angleSuccess")
321 // [kotlin_IconMapObject_setAngle]
323 // [kotlin_IconMapObject_setAngleAnimated]
324 // Set icon rotation with animation
325 val angleAnimatedSuccess = iconMapObject!!.setAngleAnimated(90.0, 2.0, AnimationType.SINE)
326 println("Set icon rotation with animation to 90 degrees: $angleAnimatedSuccess")
327 // [kotlin_IconMapObject_setAngleAnimated]
329 // [kotlin_IconMapObject_setCollisionEnabled]
330 // Enable collision detection
331 val collisionSuccess = iconMapObject!!.setCollisionEnabled(true)
332 println("Enabled collision detection for icon: $collisionSuccess")
333 // [kotlin_IconMapObject_setCollisionEnabled]
335 // [kotlin_IconMapObject_setBuffer]
336 // Set collision buffer
337 val bufferSuccess = iconMapObject!!.setBuffer(10.0, 10.0)
338 println("Set collision buffer to 10x10 pixels: $bufferSuccess")
339 // [kotlin_IconMapObject_setBuffer]
341 // [kotlin_IconMapObject_setPlacement]
342 // Set icon placement
343 val placementSuccess = iconMapObject!!.setPlacement(Placement.CENTER)
344 println("Set icon placement to CENTER: $placementSuccess")
345 // [kotlin_IconMapObject_setPlacement]
347 // [kotlin_IconMapObject_setOffset]
348 // Set position offset
349 val offsetSuccess = iconMapObject!!.setOffset(0.0, -16.0)
350 println("Set position offset to (0.0, -16.0) pixels: $offsetSuccess")
351 // [kotlin_IconMapObject_setOffset]
353 // [kotlin_IconMapObject_setPriority]
354 // Set rendering priority
355 val prioritySuccess = iconMapObject!!.setPriority(2)
356 println("Set rendering priority to 2: $prioritySuccess")
357 // [kotlin_IconMapObject_setPriority]
359 // [kotlin_IconMapObject_setVisible]
361 val visibleSuccess = iconMapObject!!.setVisible(true)
362 println("Set icon visibility to true: $visibleSuccess")
363 // [kotlin_IconMapObject_setVisible]
365 // [kotlin_IconMapObject_getMapObjectType]
366 // Get map object type
367 val objectType = iconMapObject!!.mapObjectType
368 println("Icon map object type: $objectType")
369 // [kotlin_IconMapObject_getMapObjectType]
371 // [kotlin_MapObject_setAlpha_1]
372 // Set alpha transparency
373 val alphaSuccess = iconMapObject!!.setAlpha(0.8)
374 println("Set icon alpha to 0.8: $alphaSuccess")
375 // [kotlin_MapObject_setAlpha_1]
377 // [kotlin_MapObject_setInteractive_1]
378 // Set interactive mode
379 val interactiveSuccess = iconMapObject!!.setInteractive(true)
380 println("Set icon interactive to true: $interactiveSuccess")
381 // [kotlin_MapObject_setInteractive_1]
383 // [kotlin_MapObject_setTitle_1]
385 val titleSuccess = iconMapObject!!.setTitle("Icon Object")
386 println("Set icon title to 'Icon Object': $titleSuccess")
387 // [kotlin_MapObject_setTitle_1]
389 // [kotlin_MapObject_setData_1]
391 val customData = mapOf("key" to "value", "number" to "42")
392 val dataSuccess = iconMapObject!!.setData(customData)
393 println("Set icon custom data: $dataSuccess")
394 // [kotlin_MapObject_setData_1]
396 // [kotlin_MapObject_getId_1]
398 val objectId = iconMapObject!!.id
399 println("Icon object ID: $objectId")
400 // [kotlin_MapObject_getId_1]
402 // [kotlin_MapObject_getType_1]
404 val objectTypeString = iconMapObject!!.type
405 println("Icon object type: $objectTypeString")
406 // [kotlin_MapObject_getType_1]
408 // [kotlin_MapObject_getData_1]
410 val retrievedData = iconMapObject!!.data
411 println("Icon custom data: $retrievedData")
412 // [kotlin_MapObject_getData_1]
415 // [kotlin_LocationWindow_removeIconMapObject]
416 // Remove icon map object
417 if (iconMapObject != null) {
418 val removed = locationWindow!!.removeIconMapObject(iconMapObject!!)
419 println("Removed icon map object: $removed")
422 // [kotlin_LocationWindow_removeIconMapObject]
424 // Test multiple icon objects
425 val icons = mutableListOf<IconMapObject>()
427 val icon = locationWindow!!.addIconMapObject()
429 icon.setPosition(LocationPoint(60.0 * i, 120.0 * i))
430 icon.setIcon("path/to/icon$i.png")
431 icon.setSize(Size(24.0, 24.0))
433 println("Created icon $i at (${60.0 * i}, ${120.0 * i})")
437 for (i in icons.indices) {
438 locationWindow!!.removeIconMapObject(icons[i])
439 println("Removed icon $i")
444 * Demonstrate polygon map objects
446 private fun demonstratePolygonMapObjects() {
447 println("--- Polygon Map Objects ---")
449 if (locationWindow == null) {
450 println("LocationWindow not available yet")
454 // [kotlin_LocationWindow_addPolygonMapObject]
455 // Add polygon map object
456 polygonMapObject = locationWindow!!.addPolygonMapObject()
457 println("Added polygon map object")
458 // [kotlin_LocationWindow_addPolygonMapObject]
460 if (polygonMapObject != null) {
461 // [kotlin_PolygonMapObject_setPolygon]
462 // Set polygon geometry
464 LocationPoint(50.0, 60.0),
465 LocationPoint(55.0, 65.0),
466 LocationPoint(60.0, 60.0),
467 LocationPoint(55.0, 55.0)
469 val polygon = LocationPolygon(points)
470 val success = polygonMapObject!!.setPolygon(polygon)
471 println("Set polygon with ${points.size} points: $success")
472 // [kotlin_PolygonMapObject_setPolygon]
474 // [kotlin_PolygonMapObject_setColor]
476 val colorSuccess = polygonMapObject!!.setColor(0.0, 1.0, 0.0, 0.7)
477 println("Set polygon color to green with 70% opacity: $colorSuccess")
478 // [kotlin_PolygonMapObject_setColor]
480 // [kotlin_PolygonMapObject_setOrder]
481 // Set polygon rendering order
482 val orderSuccess = polygonMapObject!!.setOrder(2)
483 println("Set polygon rendering order to 2: $orderSuccess")
484 // [kotlin_PolygonMapObject_setOrder]
486 // [kotlin_PolygonMapObject_setOutlineColor]
487 // Set polygon outline color
488 val outlineColorSuccess = polygonMapObject!!.setOutlineColor(0.0, 0.0, 1.0, 1.0)
489 println("Set polygon outline color to blue: $outlineColorSuccess")
490 // [kotlin_PolygonMapObject_setOutlineColor]
492 // [kotlin_PolygonMapObject_setOutlineWidth]
493 // Set polygon outline width
494 val outlineWidthSuccess = polygonMapObject!!.setOutlineWidth(2.0)
495 println("Set polygon outline width to 2.0 pixels: $outlineWidthSuccess")
496 // [kotlin_PolygonMapObject_setOutlineWidth]
498 // [kotlin_PolygonMapObject_setOutlineAlpha]
499 // Set polygon outline alpha
500 val outlineAlphaSuccess = polygonMapObject!!.setOutlineAlpha(0.8)
501 println("Set polygon outline alpha to 0.8: $outlineAlphaSuccess")
502 // [kotlin_PolygonMapObject_setOutlineAlpha]
504 // [kotlin_PolygonMapObject_setOutlineOrder]
505 // Set polygon outline order
506 val outlineOrderSuccess = polygonMapObject!!.setOutlineOrder(1)
507 println("Set polygon outline order to 1: $outlineOrderSuccess")
508 // [kotlin_PolygonMapObject_setOutlineOrder]
510 // [kotlin_PolygonMapObject_setVisible]
512 val visibleSuccess = polygonMapObject!!.setVisible(true)
513 println("Set polygon visibility to true: $visibleSuccess")
514 // [kotlin_PolygonMapObject_setVisible]
516 // [kotlin_PolygonMapObject_getMapObjectType]
517 // Get map object type
518 val objectType = polygonMapObject!!.mapObjectType
519 println("Polygon map object type: $objectType")
520 // [kotlin_PolygonMapObject_getMapObjectType]
522 // [kotlin_MapObject_setAlpha_2]
523 // Set alpha transparency
524 val alphaSuccess = polygonMapObject!!.setAlpha(0.6)
525 println("Set polygon alpha to 0.6: $alphaSuccess")
526 // [kotlin_MapObject_setAlpha_2]
528 // [kotlin_MapObject_setInteractive_2]
529 // Set interactive mode
530 val interactiveSuccess = polygonMapObject!!.setInteractive(true)
531 println("Set polygon interactive to true: $interactiveSuccess")
532 // [kotlin_MapObject_setInteractive_2]
534 // [kotlin_MapObject_setTitle_2]
536 val titleSuccess = polygonMapObject!!.setTitle("Polygon Object")
537 println("Set polygon title to 'Polygon Object': $titleSuccess")
538 // [kotlin_MapObject_setTitle_2]
540 // [kotlin_MapObject_setData_2]
542 val customData = mapOf("key" to "value", "number" to "42")
543 val dataSuccess = polygonMapObject!!.setData(customData)
544 println("Set polygon custom data: $dataSuccess")
545 // [kotlin_MapObject_setData_2]
547 // [kotlin_MapObject_getId_2]
549 val objectId = polygonMapObject!!.id
550 println("Polygon object ID: $objectId")
551 // [kotlin_MapObject_getId_2]
553 // [kotlin_MapObject_getType_2]
555 val objectTypeString = polygonMapObject!!.type
556 println("Polygon object type: $objectTypeString")
557 // [kotlin_MapObject_getType_2]
559 // [kotlin_MapObject_getData_2]
561 val retrievedData = polygonMapObject!!.data
562 println("Polygon custom data: $retrievedData")
563 // [kotlin_MapObject_getData_2]
566 // [kotlin_LocationWindow_removePolygonMapObject]
567 // Remove polygon map object
568 if (polygonMapObject != null) {
569 val removed = locationWindow!!.removePolygonMapObject(polygonMapObject!!)
570 println("Removed polygon map object: $removed")
571 polygonMapObject = null
573 // [kotlin_LocationWindow_removePolygonMapObject]
575 // Test multiple polygon objects
576 val polygons = mutableListOf<PolygonMapObject>()
578 val polygon = locationWindow!!.addPolygonMapObject()
579 if (polygon != null) {
581 LocationPoint(300.0 + i * 50, 400.0 + i * 50),
582 LocationPoint(350.0 + i * 50, 450.0 + i * 50),
583 LocationPoint(400.0 + i * 50, 400.0 + i * 50),
584 LocationPoint(350.0 + i * 50, 350.0 + i * 50)
586 val polygonGeometry = LocationPolygon(points)
587 polygon.setPolygon(polygonGeometry)
588 polygon.setColor(0.0, 0.0, 1.0, 0.5)
589 polygons.add(polygon)
590 println("Created polygon $i with ${points.size} points")
594 for (i in polygons.indices) {
595 locationWindow!!.removePolygonMapObject(polygons[i])
596 println("Removed polygon $i")
601 * Demonstrate polyline map objects
603 private fun demonstratePolylineMapObjects() {
604 println("--- Polyline Map Objects ---")
606 if (locationWindow == null) {
607 println("LocationWindow not available yet")
611 // [kotlin_PolylineMapObject_constructor]
612 // Create polyline map object
614 LocationPoint(100.0, 110.0),
615 LocationPoint(105.0, 115.0),
616 LocationPoint(110.0, 120.0),
617 LocationPoint(115.0, 125.0)
619 val polyline = LocationPolyline(points)
620 polylineMapObject = locationWindow!!.addPolylineMapObject()
621 println("Created polyline map object with ${points.size} points")
622 // [kotlin_PolylineMapObject_constructor]
624 // [kotlin_PolylineMapObject_getPolyline]
626 val polylineShape = polylineMapObject!!.getPolyLine()
627 println("Polyline has ${polylineShape.points.size} points")
628 // [kotlin_PolylineMapObject_getPolyline]
630 // [kotlin_LocationWindow_addPolylineMapObject]
631 // Add polyline map object
632 polylineMapObject = locationWindow!!.addPolylineMapObject()
633 println("Added polyline map object")
634 // [kotlin_LocationWindow_addPolylineMapObject]
636 if (polylineMapObject != null) {
637 // [kotlin_PolylineMapObject_setPolyLine]
638 // Set polyline geometry
640 LocationPoint(100.0, 110.0),
641 LocationPoint(105.0, 115.0),
642 LocationPoint(110.0, 120.0),
643 LocationPoint(115.0, 125.0)
645 val polyline = LocationPolyline(points)
646 val success = polylineMapObject!!.setPolyLine(polyline)
647 println("Set polyline with ${points.size} points: $success")
648 // [kotlin_PolylineMapObject_setPolyLine]
650 // [kotlin_PolylineMapObject_setWidth]
651 // Set polyline width
652 val widthSuccess = polylineMapObject!!.setWidth(3.0)
653 println("Set polyline width to 3.0 pixels: $widthSuccess")
654 // [kotlin_PolylineMapObject_setWidth]
656 // [kotlin_PolylineMapObject_setColor]
657 // Set polyline color
658 val colorSuccess = polylineMapObject!!.setColor(0.0, 1.0, 0.0, 0.8)
659 println("Set polyline color to green with 80% opacity: $colorSuccess")
660 // [kotlin_PolylineMapObject_setColor]
662 // [kotlin_PolylineMapObject_setOrder]
663 // Set polyline rendering order
664 val orderSuccess = polylineMapObject!!.setOrder(1)
665 println("Set polyline rendering order to 1: $orderSuccess")
666 // [kotlin_PolylineMapObject_setOrder]
668 // [kotlin_PolylineMapObject_setCapType]
669 // Set polyline cap type
670 val capTypeSuccess = polylineMapObject!!.setCapType(CapType.ROUND)
671 println("Set polyline cap type to ROUND: $capTypeSuccess")
672 // [kotlin_PolylineMapObject_setCapType]
674 // [kotlin_PolylineMapObject_setJoinType]
675 // Set polyline join type
676 val joinTypeSuccess = polylineMapObject!!.setJoinType(JoinType.ROUND)
677 println("Set polyline join type to ROUND: $joinTypeSuccess")
678 // [kotlin_PolylineMapObject_setJoinType]
680 // [kotlin_PolylineMapObject_setMiterLimit]
681 // Set polyline miter limit
682 val miterLimitSuccess = polylineMapObject!!.setMiterLimit(2.0)
683 println("Set polyline miter limit to 2.0: $miterLimitSuccess")
684 // [kotlin_PolylineMapObject_setMiterLimit]
686 // [kotlin_PolylineMapObject_setOutlineWidth]
687 // Set polyline outline width
688 val outlineWidthSuccess = polylineMapObject!!.setOutlineWidth(1.0)
689 println("Set polyline outline width to 1.0 pixels: $outlineWidthSuccess")
690 // [kotlin_PolylineMapObject_setOutlineWidth]
692 // [kotlin_PolylineMapObject_setOutlineColor]
693 // Set polyline outline color
694 val outlineColorSuccess = polylineMapObject!!.setOutlineColor(0.0, 0.0, 0.0, 1.0)
695 println("Set polyline outline color to black: $outlineColorSuccess")
696 // [kotlin_PolylineMapObject_setOutlineColor]
698 // [kotlin_PolylineMapObject_setOutlineAlpha]
699 // Set polyline outline alpha
700 val outlineAlphaSuccess = polylineMapObject!!.setOutlineAlpha(0.5)
701 println("Set polyline outline alpha to 0.5: $outlineAlphaSuccess")
702 // [kotlin_PolylineMapObject_setOutlineAlpha]
704 // [kotlin_PolylineMapObject_setOutlineOrder]
705 // Set polyline outline rendering order
706 val outlineOrderSuccess = polylineMapObject!!.setOutlineOrder(0)
707 println("Set polyline outline rendering order to 0: $outlineOrderSuccess")
708 // [kotlin_PolylineMapObject_setOutlineOrder]
710 // [kotlin_PolylineMapObject_setOutlineCapType]
711 // Set polyline outline cap type
712 val outlineCapTypeSuccess = polylineMapObject!!.setOutlineCapType(CapType.SQUARE)
713 println("Set polyline outline cap type to SQUARE: $outlineCapTypeSuccess")
714 // [kotlin_PolylineMapObject_setOutlineCapType]
716 // [kotlin_PolylineMapObject_setOutlineJoinType]
717 // Set polyline outline join type
718 val outlineJoinTypeSuccess = polylineMapObject!!.setOutlineJoinType(JoinType.MITER)
719 println("Set polyline outline join type to MITER: $outlineJoinTypeSuccess")
720 // [kotlin_PolylineMapObject_setOutlineJoinType]
722 // [kotlin_PolylineMapObject_setOutlineMiterLimit]
723 // Set polyline outline miter limit
724 val outlineMiterLimitSuccess = polylineMapObject!!.setOutlineMiterLimit(3.0)
725 println("Set polyline outline miter limit to 3.0: $outlineMiterLimitSuccess")
726 // [kotlin_PolylineMapObject_setOutlineMiterLimit]
728 // [kotlin_PolylineMapObject_setVisible]
730 val visibleSuccess = polylineMapObject!!.setVisible(true)
731 println("Set polyline visibility to true: $visibleSuccess")
732 // [kotlin_PolylineMapObject_setVisible]
734 // [kotlin_PolylineMapObject_getMapObjectType]
735 // Get map object type
736 val objectType = polylineMapObject!!.mapObjectType
737 println("Polyline map object type: $objectType")
738 // [kotlin_PolylineMapObject_getMapObjectType]
740 // [kotlin_MapObject_setAlpha_3]
741 // Set alpha transparency
742 val alphaSuccess = polylineMapObject!!.setAlpha(0.7)
743 println("Set polyline alpha to 0.7: $alphaSuccess")
744 // [kotlin_MapObject_setAlpha_3]
746 // [kotlin_MapObject_setInteractive_3]
747 // Set interactive mode
748 val interactiveSuccess = polylineMapObject!!.setInteractive(true)
749 println("Set polyline interactive to true: $interactiveSuccess")
750 // [kotlin_MapObject_setInteractive_3]
752 // [kotlin_MapObject_setTitle_3]
754 val titleSuccess = polylineMapObject!!.setTitle("Polyline Object")
755 println("Set polyline title to 'Polyline Object': $titleSuccess")
756 // [kotlin_MapObject_setTitle_3]
758 // [kotlin_MapObject_setData_3]
760 val customData = mapOf("key" to "value", "number" to "42")
761 val dataSuccess = polylineMapObject!!.setData(customData)
762 println("Set polyline custom data: $dataSuccess")
763 // [kotlin_MapObject_setData_3]
765 // [kotlin_MapObject_getId_3]
767 val objectId = polylineMapObject!!.id
768 println("Polyline object ID: $objectId")
769 // [kotlin_MapObject_getId_3]
771 // [kotlin_MapObject_getType_3]
773 val objectTypeString = polylineMapObject!!.type
774 println("Polyline object type: $objectTypeString")
775 // [kotlin_MapObject_getType_3]
777 // [kotlin_MapObject_getData_3]
779 val retrievedData = polylineMapObject!!.data
780 println("Polyline custom data: $retrievedData")
781 // [kotlin_MapObject_getData_3]
784 // [kotlin_LocationWindow_removePolylineMapObject]
785 // Remove polyline map object
786 if (polylineMapObject != null) {
787 val removed = locationWindow!!.removePolylineMapObject(polylineMapObject!!)
788 println("Removed polyline map object: $removed")
789 polylineMapObject = null
791 // [kotlin_LocationWindow_removePolylineMapObject]
793 // Test multiple polyline objects
794 val polylines = mutableListOf<PolylineMapObject>()
796 val polyline = locationWindow!!.addPolylineMapObject()
797 if (polyline != null) {
799 LocationPoint(120.0 + i * 30, 130.0 + i * 30),
800 LocationPoint(125.0 + i * 30, 135.0 + i * 30),
801 LocationPoint(130.0 + i * 30, 140.0 + i * 30)
803 val polylineGeometry = LocationPolyline(points)
804 polyline.setPolyLine(polylineGeometry)
805 polyline.setColor(1.0, 0.0, 0.0, 0.6)
806 polyline.setWidth(2.0)
807 polylines.add(polyline)
808 println("Created polyline $i with ${points.size} points")
812 for (i in polylines.indices) {
813 locationWindow!!.removePolylineMapObject(polylines[i])
814 println("Removed polyline $i")
819 * Demonstrate dotted polyline map objects
821 private fun demonstrateDottedPolylineMapObjects() {
822 println("--- Dotted Polyline Map Objects ---")
824 if (locationWindow == null) {
825 println("LocationWindow not available yet")
829 // [kotlin_DottedPolylineMapObject_constructor]
830 // Create dotted polyline map object
832 LocationPoint(160.0, 170.0),
833 LocationPoint(165.0, 175.0),
834 LocationPoint(170.0, 180.0),
835 LocationPoint(175.0, 185.0)
837 val polyline = LocationPolyline(points)
838 dottedPolylineMapObject = locationWindow!!.addDottedPolylineMapObject()
839 println("Created dotted polyline map object with ${points.size} points")
840 // [kotlin_DottedPolylineMapObject_constructor]
842 // [kotlin_DottedPolylineMapObject_getPolyline]
843 // Access dotted polyline
844 val dottedPolylineShape = dottedPolylineMapObject!!.getPolyLine()
845 println("Dotted polyline has ${dottedPolylineShape.points.size} points")
846 // [kotlin_DottedPolylineMapObject_getPolyline]
848 // [kotlin_LocationWindow_addDottedPolylineMapObject]
849 // Add dotted polyline map object
850 dottedPolylineMapObject = locationWindow!!.addDottedPolylineMapObject()
851 println("Added dotted polyline map object")
852 // [kotlin_LocationWindow_addDottedPolylineMapObject]
854 if (dottedPolylineMapObject != null) {
855 // [kotlin_DottedPolylineMapObject_setPolyline]
856 // Set dotted polyline geometry
858 LocationPoint(160.0, 170.0),
859 LocationPoint(165.0, 175.0),
860 LocationPoint(170.0, 180.0),
861 LocationPoint(175.0, 185.0)
863 val polyline = LocationPolyline(points)
864 val success = dottedPolylineMapObject!!.setPolyline(polyline)
865 println("Set dotted polyline with ${points.size} points: $success")
866 // [kotlin_DottedPolylineMapObject_setPolyline]
868 // [kotlin_DottedPolylineMapObject_setColor]
869 // Set dotted polyline color
870 val colorSuccess = dottedPolylineMapObject!!.setColor(0.5, 0.0, 1.0, 0.8)
871 println("Set dotted polyline color to purple with 80% opacity: $colorSuccess")
872 // [kotlin_DottedPolylineMapObject_setColor]
874 // [kotlin_DottedPolylineMapObject_setWidth]
875 // Set dotted polyline width
876 val widthSuccess = dottedPolylineMapObject!!.setWidth(3.0)
877 println("Set dotted polyline width to 3.0 pixels: $widthSuccess")
878 // [kotlin_DottedPolylineMapObject_setWidth]
880 // [kotlin_DottedPolylineMapObject_setOrder]
881 // Set dotted polyline rendering order
882 val orderSuccess = dottedPolylineMapObject!!.setOrder(2)
883 println("Set dotted polyline rendering order to 2: $orderSuccess")
884 // [kotlin_DottedPolylineMapObject_setOrder]
886 // [kotlin_DottedPolylineMapObject_setCollisionEnabled]
887 // Enable collision detection
888 val collisionSuccess = dottedPolylineMapObject!!.setCollisionEnabled(true)
889 println("Enabled collision detection for dotted polyline: $collisionSuccess")
890 // [kotlin_DottedPolylineMapObject_setCollisionEnabled]
892 // [kotlin_DottedPolylineMapObject_setPlacement]
893 // Set placement type
894 val placementSuccess = dottedPolylineMapObject!!.setPlacement(Placement.CENTER)
895 println("Set dotted polyline placement to CENTER: $placementSuccess")
896 // [kotlin_DottedPolylineMapObject_setPlacement]
898 // [kotlin_DottedPolylineMapObject_setPlacementMinRatio]
899 // Set placement min ratio
900 val minRatioSuccess = dottedPolylineMapObject!!.setPlacementMinRatio(0.5)
901 println("Set dotted polyline placement min ratio to 0.5: $minRatioSuccess")
902 // [kotlin_DottedPolylineMapObject_setPlacementMinRatio]
904 // [kotlin_DottedPolylineMapObject_setPlacementSpacing]
905 // Set placement spacing
906 val spacingSuccess = dottedPolylineMapObject!!.setPlacementSpacing(10.0)
907 println("Set dotted polyline placement spacing to 10.0: $spacingSuccess")
908 // [kotlin_DottedPolylineMapObject_setPlacementSpacing]
910 // [kotlin_DottedPolylineMapObject_setPriority]
911 // Set rendering priority
912 val prioritySuccess = dottedPolylineMapObject!!.setPriority(1)
913 println("Set dotted polyline rendering priority to 1: $prioritySuccess")
914 // [kotlin_DottedPolylineMapObject_setPriority]
916 // [kotlin_DottedPolylineMapObject_setRepeatDistance]
917 // Set repeat distance
918 val repeatDistanceSuccess = dottedPolylineMapObject!!.setRepeatDistance(20.0)
919 println("Set dotted polyline repeat distance to 20.0: $repeatDistanceSuccess")
920 // [kotlin_DottedPolylineMapObject_setRepeatDistance]
922 // [kotlin_DottedPolylineMapObject_setRepeatGroup]
924 val repeatGroupSuccess = dottedPolylineMapObject!!.setRepeatGroup(1)
925 println("Set dotted polyline repeat group to 1: $repeatGroupSuccess")
926 // [kotlin_DottedPolylineMapObject_setRepeatGroup]
928 // [kotlin_DottedPolylineMapObject_setSize]
930 val size = Size(16.0, 16.0)
931 val sizeSuccess = dottedPolylineMapObject!!.setSize(size)
932 println("Set dotted polyline size to (${size.width}, ${size.height}): $sizeSuccess")
933 // [kotlin_DottedPolylineMapObject_setSize]
935 // [kotlin_DottedPolylineMapObject_setVisible]
937 val visibleSuccess = dottedPolylineMapObject!!.setVisible(true)
938 println("Set dotted polyline visibility to true: $visibleSuccess")
939 // [kotlin_DottedPolylineMapObject_setVisible]
941 // [kotlin_DottedPolylineMapObject_getMapObjectType]
942 // Get map object type
943 val objectType = dottedPolylineMapObject!!.mapObjectType
944 println("Dotted polyline map object type: $objectType")
945 // [kotlin_DottedPolylineMapObject_getMapObjectType]
947 // [kotlin_MapObject_setAlpha_4]
948 // Set alpha transparency
949 val alphaSuccess = dottedPolylineMapObject!!.setAlpha(0.8)
950 println("Set dotted polyline alpha to 0.8: $alphaSuccess")
951 // [kotlin_MapObject_setAlpha_4]
953 // [kotlin_MapObject_setInteractive_4]
954 // Set interactive mode
955 val interactiveSuccess = dottedPolylineMapObject!!.setInteractive(true)
956 println("Set dotted polyline interactive to true: $interactiveSuccess")
957 // [kotlin_MapObject_setInteractive_4]
959 // [kotlin_MapObject_setTitle_4]
961 val titleSuccess = dottedPolylineMapObject!!.setTitle("Dotted Polyline Object")
962 println("Set dotted polyline title to 'Dotted Polyline Object': $titleSuccess")
963 // [kotlin_MapObject_setTitle_4]
965 // [kotlin_MapObject_setData_4]
967 val customData = mapOf("key" to "value", "number" to "42")
968 val dataSuccess = dottedPolylineMapObject!!.setData(customData)
969 println("Set dotted polyline custom data: $dataSuccess")
970 // [kotlin_MapObject_setData_4]
972 // [kotlin_MapObject_getId_4]
974 val objectId = dottedPolylineMapObject!!.id
975 println("Dotted polyline object ID: $objectId")
976 // [kotlin_MapObject_getId_4]
978 // [kotlin_MapObject_getType_4]
980 val objectTypeString = dottedPolylineMapObject!!.type
981 println("Dotted polyline object type: $objectTypeString")
982 // [kotlin_MapObject_getType_4]
984 // [kotlin_MapObject_getData_4]
986 val retrievedData = dottedPolylineMapObject!!.data
987 println("Dotted polyline custom data: $retrievedData")
988 // [kotlin_MapObject_getData_4]
991 // [kotlin_LocationWindow_removeDottedPolylineMapObject]
992 // Remove dotted polyline map object
993 if (dottedPolylineMapObject != null) {
994 val removed = locationWindow!!.removeDottedPolylineMapObject(dottedPolylineMapObject!!)
995 println("Removed dotted polyline map object: $removed")
996 dottedPolylineMapObject = null
998 // [kotlin_LocationWindow_removeDottedPolylineMapObject]
1000 // Test multiple dotted polyline objects
1001 val dottedPolylines = mutableListOf<DottedPolylineMapObject>()
1003 val dottedPolyline = locationWindow!!.addDottedPolylineMapObject()
1004 if (dottedPolyline != null) {
1005 val points = listOf(
1006 LocationPoint(180.0 + i * 30, 190.0 + i * 30),
1007 LocationPoint(185.0 + i * 30, 195.0 + i * 30),
1008 LocationPoint(190.0 + i * 30, 200.0 + i * 30)
1010 val polylineGeometry = LocationPolyline(points)
1011 dottedPolyline.setPolyline(polylineGeometry)
1012 dottedPolylines.add(dottedPolyline)
1013 println("Created dotted polyline $i with ${points.size} points")
1017 for (i in dottedPolylines.indices) {
1018 locationWindow!!.removeDottedPolylineMapObject(dottedPolylines[i])
1019 println("Removed dotted polyline $i")
1024 * Demonstrate remove all map objects
1026 private fun demonstrateRemoveAllMapObjects() {
1027 println("--- Remove All Map Objects ---")
1029 if (locationWindow == null) {
1030 println("LocationWindow not available yet")
1034 println("Current map objects count: ${getMapObjectsCount()}")
1036 // [kotlin_LocationWindow_removeAllMapObjects]
1037 // Remove all map objects
1038 locationWindow!!.removeAllMapObjects()
1039 println("Removed all map objects")
1040 // [kotlin_LocationWindow_removeAllMapObjects]
1042 println("Map objects count after removal: ${getMapObjectsCount()}")
1046 * Get current map objects count
1048 private fun getMapObjectsCount(): Int {
1050 if (circleMapObject != null) count++
1051 if (iconMapObject != null) count++
1052 if (polygonMapObject != null) count++
1053 if (polylineMapObject != null) count++
1054 if (dottedPolylineMapObject != null) count++
1061 private fun cleanup() {
1062 println("--- Cleanup ---")
1064 if (locationWindow != null) {
1065 locationWindow!!.removeAllMapObjects()
1066 println("Cleaned up all map objects")
1069 circleMapObject = null
1070 iconMapObject = null
1071 polygonMapObject = null
1072 polylineMapObject = null
1073 dottedPolylineMapObject = null
1074 println("Cleared map objects references")
1078// Main function to run the example
1080 LocationWindowMapObjectsExample()