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
20import com.navigine.idl.kotlin.Polygon
21import com.navigine.idl.kotlin.Polyline
24 * LocationWindowMapObjects usage example for Kotlin
25 * Demonstrates specific methods: addCircleMapObject, removeCircleMapObject, addIconMapObject,
26 * removeIconMapObject, addPolygonMapObject, addPolylineMapObject, removePolylineMapObject,
27 * addDottedPolylineMapObject, removeDottedPolylineMapObject, removeAllMapObjects
29class LocationWindowMapObjectsExample {
30 private var locationWindow: LocationWindow? = null
31 private var circleMapObject: CircleMapObject? = null
32 private var iconMapObject: IconMapObject? = null
33 private var polygonMapObject: PolygonMapObject? = null
34 private var polylineMapObject: PolylineMapObject? = null
35 private var dottedPolylineMapObject: DottedPolylineMapObject? = null
38 demonstrateLocationWindowMapObjectsMethods()
42 * Demonstrate LocationWindowMapObjects methods
44 private fun demonstrateLocationWindowMapObjectsMethods() {
45 println("=== LocationWindowMapObjects Example ===")
47 // Initialize LocationWindow (in real app, this would be provided by the framework)
48 // locationWindow = getLocationWindow()
50 demonstrateLocationScopedGeometryRecords()
52 demonstrateCircleMapObjects()
53 demonstrateIconMapObjects()
54 demonstratePolygonMapObjects()
55 demonstratePolylineMapObjects()
56 demonstrateDottedPolylineMapObjects()
57 demonstrateRemoveAllMapObjects()
63 * Metrics geometry scoped to a location / sublocation (@see LocationPolygon, LocationPolyline).
65 private fun demonstrateLocationScopedGeometryRecords() {
66 println("--- LocationPolygon / LocationPolyline records ---")
68 // [kotlin_LocationPolygon_record]
69 val ring = listOf(Point(1.0, 2.0), Point(3.0, 4.0), Point(5.0, 2.0))
70 val metricPolygon = Polygon(ring)
71 val locationPolygon = LocationPolygon(metricPolygon, 42, 7)
72 val polygonBack = locationPolygon.getPolygon()
73 val polygonLocationId = locationPolygon.getLocationId()
74 val polygonSublocationId = locationPolygon.getSublocationId()
75 println("LocationPolygon: location $polygonLocationId, sublocation $polygonSublocationId, vertices ${polygonBack.getPoints().size}")
76 // [kotlin_LocationPolygon_record]
78 // [kotlin_LocationPolyline_record]
79 val linePoints = listOf(Point(0.0, 0.0), Point(10.0, 10.0))
80 val metricPolyline = Polyline(linePoints)
81 val locationPolyline = LocationPolyline(metricPolyline, 42, 7)
82 val polylineBack = locationPolyline.getPolyline()
83 println("LocationPolyline: points ${polylineBack.getPoints().size}")
84 // [kotlin_LocationPolyline_record]
88 * Demonstrate circle map objects
90 private fun demonstrateCircleMapObjects() {
91 println("--- Circle Map Objects ---")
93 if (locationWindow == null) {
94 println("LocationWindow not available yet")
98 // [kotlin_CircleMapObject_constructor]
99 // Create circle map object
100 val center = LocationPoint(10.0, 20.0)
101 circleMapObject = locationWindow!!.addCircleMapObject()
102 println("Created circle map object with center (${center.x}, ${center.y}) and radius 5.0")
103 // [kotlin_CircleMapObject_constructor]
105 // [kotlin_CircleMapObject_getCenter]
106 // Access circle center
107 val circleCenter = circleMapObject!!.getPosition()
108 println("Circle center: (${circleCenter.x}, ${circleCenter.y})")
109 // [kotlin_CircleMapObject_getCenter]
111 // [kotlin_CircleMapObject_getRadius]
112 // Access circle radius
113 val radius = circleMapObject!!.getRadius()
114 println("Circle radius: $radius")
115 // [kotlin_CircleMapObject_getRadius]
117 // [kotlin_LocationWindow_addCircleMapObject]
118 // Add circle map object
119 circleMapObject = locationWindow!!.addCircleMapObject()
120 println("Added circle map object")
121 // [kotlin_LocationWindow_addCircleMapObject]
123 if (circleMapObject != null) {
124 // [kotlin_CircleMapObject_setPosition]
125 // Set circle position
126 val centerPoint = LocationPoint(100.0, 200.0)
127 val success = circleMapObject!!.setPosition(centerPoint)
128 println("Set circle position to (${centerPoint.x}, ${centerPoint.y}): $success")
129 // [kotlin_CircleMapObject_setPosition]
131 // [kotlin_CircleMapObject_setPositionAnimated]
132 // Set circle position with animation
133 val animatedPoint = LocationPoint(150.0, 250.0)
134 val animatedSuccess = circleMapObject!!.setPositionAnimated(animatedPoint, 2.0, AnimationType.LINEAR)
135 println("Set circle position with animation to (${animatedPoint.x}, ${animatedPoint.y}): $animatedSuccess")
136 // [kotlin_CircleMapObject_setPositionAnimated]
138 // [kotlin_CircleMapObject_setRadius]
140 val radiusSuccess = circleMapObject!!.setRadius(10.0)
141 println("Set circle radius to 10.0 meters: $radiusSuccess")
142 // [kotlin_CircleMapObject_setRadius]
144 // [kotlin_CircleMapObject_setCollisionEnabled]
145 // Enable collision detection
146 val collisionSuccess = circleMapObject!!.setCollisionEnabled(true)
147 println("Enabled collision detection for circle: $collisionSuccess")
148 // [kotlin_CircleMapObject_setCollisionEnabled]
150 // [kotlin_CircleMapObject_setBuffer]
151 // Set collision buffer
152 val bufferSuccess = circleMapObject!!.setBuffer(5.0, 5.0)
153 println("Set collision buffer to 5x5 pixels: $bufferSuccess")
154 // [kotlin_CircleMapObject_setBuffer]
156 // [kotlin_CircleMapObject_setOffset]
157 // Set position offset
158 val offsetSuccess = circleMapObject!!.setOffset(2.0, 3.0)
159 println("Set position offset to (2.0, 3.0) pixels: $offsetSuccess")
160 // [kotlin_CircleMapObject_setOffset]
162 // [kotlin_CircleMapObject_setOutlineColor]
164 val outlineColorSuccess = circleMapObject!!.setOutlineColor(0.0, 0.0, 1.0, 1.0)
165 println("Set circle outline color to blue: $outlineColorSuccess")
166 // [kotlin_CircleMapObject_setOutlineColor]
168 // [kotlin_CircleMapObject_setOutlineAlpha]
170 val outlineAlphaSuccess = circleMapObject!!.setOutlineAlpha(0.5)
171 println("Set circle outline alpha to 0.5: $outlineAlphaSuccess")
172 // [kotlin_CircleMapObject_setOutlineAlpha]
174 // [kotlin_CircleMapObject_setOutlineRadius]
175 // Set outline radius
176 val outlineRadiusSuccess = circleMapObject!!.setOutlineRadius(2.0)
177 println("Set circle outline radius to 2.0: $outlineRadiusSuccess")
178 // [kotlin_CircleMapObject_setOutlineRadius]
180 // [kotlin_CircleMapObject_setColor]
182 val colorSuccess = circleMapObject!!.setColor(1.0, 0.0, 0.0, 0.8)
183 println("Set circle color to red with 80% opacity: $colorSuccess")
184 // [kotlin_CircleMapObject_setColor]
186 // [kotlin_CircleMapObject_setPriority]
187 // Set rendering priority
188 val prioritySuccess = circleMapObject!!.setPriority(1)
189 println("Set rendering priority to 1: $prioritySuccess")
190 // [kotlin_CircleMapObject_setPriority]
192 // [kotlin_MapObject_setVisible]
194 val visibleSuccess = circleMapObject!!.setVisible(true)
195 println("Set circle visibility to true: $visibleSuccess")
196 // [kotlin_MapObject_setVisible]
198 // [kotlin_CircleMapObject_getMapObjectType]
199 // Get map object type
200 val objectType = circleMapObject!!.mapObjectType
201 println("Circle map object type: $objectType")
202 // [kotlin_CircleMapObject_getMapObjectType]
204 // [kotlin_MapObject_setAlpha]
205 // Set alpha transparency
206 val alphaSuccess = circleMapObject!!.setAlpha(0.7)
207 println("Set circle alpha to 0.7: $alphaSuccess")
208 // [kotlin_MapObject_setAlpha]
210 // [kotlin_MapObject_setInteractive]
211 // Set interactive mode
212 val interactiveSuccess = circleMapObject!!.setInteractive(true)
213 println("Set circle interactive to true: $interactiveSuccess")
214 // [kotlin_MapObject_setInteractive]
216 // [kotlin_MapObject_setTitle]
218 val titleSuccess = circleMapObject!!.setTitle("Circle Object")
219 println("Set circle title to 'Circle Object': $titleSuccess")
220 // [kotlin_MapObject_setTitle]
222 // [kotlin_MapObject_setData]
224 val customData = mapOf("key" to "value", "number" to "42")
225 val dataSuccess = circleMapObject!!.setData(customData)
226 println("Set circle custom data: $dataSuccess")
227 // [kotlin_MapObject_setData]
229 // [kotlin_MapObject_getId]
231 val objectId = circleMapObject!!.id
232 println("Circle object ID: $objectId")
233 // [kotlin_MapObject_getId]
235 // [kotlin_MapObject_getType]
237 val objectTypeString = circleMapObject!!.type
238 println("Circle object type: $objectTypeString")
239 // [kotlin_MapObject_getType]
241 // [kotlin_MapObject_getData]
243 val retrievedData = circleMapObject!!.data
244 println("Circle custom data: $retrievedData")
245 // [kotlin_MapObject_getData]
248 // [kotlin_LocationWindow_removeCircleMapObject]
249 // Remove circle map object
250 if (circleMapObject != null) {
251 val removed = locationWindow!!.removeCircleMapObject(circleMapObject!!)
252 println("Removed circle map object: $removed")
253 circleMapObject = null
255 // [kotlin_LocationWindow_removeCircleMapObject]
257 // Test multiple circle objects
258 val circles = mutableListOf<CircleMapObject>()
260 val circle = locationWindow!!.addCircleMapObject()
261 if (circle != null) {
262 circle.setPosition(LocationPoint(50.0 * i, 100.0 * i))
263 circle.setColor(0.0, 1.0, 0.0, 0.6)
264 circle.setRadius(5.0 + i * 2.0)
266 println("Created circle $i at (${50.0 * i}, ${100.0 * i}) with radius ${5.0 + i * 2.0}")
270 for (i in circles.indices) {
271 locationWindow!!.removeCircleMapObject(circles[i])
272 println("Removed circle $i")
277 * Demonstrate icon map objects
279 private fun demonstrateIconMapObjects() {
280 println("--- Icon Map Objects ---")
282 if (locationWindow == null) {
283 println("LocationWindow not available yet")
287 // [kotlin_IconMapObject_constructor]
288 // Create icon map object
289 val position = LocationPoint(30.0, 40.0)
290 iconMapObject = locationWindow!!.addIconMapObject()
291 println("Created icon map object at (${position.x}, ${position.y})")
292 // [kotlin_IconMapObject_constructor]
294 // [kotlin_IconMapObject_getPosition]
295 // Access icon position
296 val iconPosition = iconMapObject!!.getPosition()
297 println("Icon position: (${iconPosition.x}, ${iconPosition.y})")
298 // [kotlin_IconMapObject_getPosition]
300 // [kotlin_LocationWindow_addIconMapObject]
301 // Add icon map object
302 iconMapObject = locationWindow!!.addIconMapObject()
303 println("Added icon map object")
304 // [kotlin_LocationWindow_addIconMapObject]
306 if (iconMapObject != null) {
307 // [kotlin_IconMapObject_setPosition]
309 val position = LocationPoint(30.0, 40.0)
310 val success = iconMapObject!!.setPosition(position)
311 println("Set icon position to (${position.x}, ${position.y}): $success")
312 // [kotlin_IconMapObject_setPosition]
314 // [kotlin_IconMapObject_setPositionAnimated]
315 // Set icon position with animation
316 val animatedPosition = LocationPoint(35.0, 45.0)
317 val animatedSuccess = iconMapObject!!.setPositionAnimated(animatedPosition, 1.5, AnimationType.CUBIC)
318 println("Set icon position with animation to (${animatedPosition.x}, ${animatedPosition.y}): $animatedSuccess")
319 // [kotlin_IconMapObject_setPositionAnimated]
321 // [kotlin_IconMapObject_setIcon]
323 val iconSuccess = iconMapObject!!.setIcon("path/to/icon.png")
324 println("Set icon image: $iconSuccess")
325 // [kotlin_IconMapObject_setIcon]
327 // [kotlin_IconMapObject_setBitmap]
329 val bitmapSuccess = iconMapObject!!.setBitmap("path/to/bitmap.png")
330 println("Set icon bitmap: $bitmapSuccess")
331 // [kotlin_IconMapObject_setBitmap]
333 // [kotlin_IconMapObject_setFlat]
334 // Set icon flat mode
335 val flatSuccess = iconMapObject!!.setFlat(true)
336 println("Set icon flat mode to true: $flatSuccess")
337 // [kotlin_IconMapObject_setFlat]
339 // [kotlin_IconMapObject_setSize]
341 val size = Size(32.0, 32.0)
342 val sizeSuccess = iconMapObject!!.setSize(size)
343 println("Set icon size to (${size.width}, ${size.height}): $sizeSuccess")
344 // [kotlin_IconMapObject_setSize]
346 // [kotlin_IconMapObject_setAngle]
347 // Set icon rotation angle
348 val angleSuccess = iconMapObject!!.setAngle(45.0)
349 println("Set icon rotation angle to 45 degrees: $angleSuccess")
350 // [kotlin_IconMapObject_setAngle]
352 // [kotlin_IconMapObject_setAngleAnimated]
353 // Set icon rotation with animation
354 val angleAnimatedSuccess = iconMapObject!!.setAngleAnimated(90.0, 2.0, AnimationType.SINE)
355 println("Set icon rotation with animation to 90 degrees: $angleAnimatedSuccess")
356 // [kotlin_IconMapObject_setAngleAnimated]
358 // [kotlin_IconMapObject_setCollisionEnabled]
359 // Enable collision detection
360 val collisionSuccess = iconMapObject!!.setCollisionEnabled(true)
361 println("Enabled collision detection for icon: $collisionSuccess")
362 // [kotlin_IconMapObject_setCollisionEnabled]
364 // [kotlin_IconMapObject_setBuffer]
365 // Set collision buffer
366 val bufferSuccess = iconMapObject!!.setBuffer(10.0, 10.0)
367 println("Set collision buffer to 10x10 pixels: $bufferSuccess")
368 // [kotlin_IconMapObject_setBuffer]
370 // [kotlin_IconMapObject_setPlacement]
371 // Set icon placement
372 val placementSuccess = iconMapObject!!.setPlacement(Placement.CENTER)
373 println("Set icon placement to CENTER: $placementSuccess")
374 // [kotlin_IconMapObject_setPlacement]
376 // [kotlin_IconMapObject_setOffset]
377 // Set position offset
378 val offsetSuccess = iconMapObject!!.setOffset(0.0, -16.0)
379 println("Set position offset to (0.0, -16.0) pixels: $offsetSuccess")
380 // [kotlin_IconMapObject_setOffset]
382 // [kotlin_IconMapObject_setPriority]
383 // Set rendering priority
384 val prioritySuccess = iconMapObject!!.setPriority(2)
385 println("Set rendering priority to 2: $prioritySuccess")
386 // [kotlin_IconMapObject_setPriority]
388 // [kotlin_IconMapObject_setVisible]
390 val visibleSuccess = iconMapObject!!.setVisible(true)
391 println("Set icon visibility to true: $visibleSuccess")
392 // [kotlin_IconMapObject_setVisible]
394 // [kotlin_IconMapObject_getMapObjectType]
395 // Get map object type
396 val objectType = iconMapObject!!.mapObjectType
397 println("Icon map object type: $objectType")
398 // [kotlin_IconMapObject_getMapObjectType]
400 // [kotlin_MapObject_setAlpha_1]
401 // Set alpha transparency
402 val alphaSuccess = iconMapObject!!.setAlpha(0.8)
403 println("Set icon alpha to 0.8: $alphaSuccess")
404 // [kotlin_MapObject_setAlpha_1]
406 // [kotlin_MapObject_setInteractive_1]
407 // Set interactive mode
408 val interactiveSuccess = iconMapObject!!.setInteractive(true)
409 println("Set icon interactive to true: $interactiveSuccess")
410 // [kotlin_MapObject_setInteractive_1]
412 // [kotlin_MapObject_setTitle_1]
414 val titleSuccess = iconMapObject!!.setTitle("Icon Object")
415 println("Set icon title to 'Icon Object': $titleSuccess")
416 // [kotlin_MapObject_setTitle_1]
418 // [kotlin_MapObject_setData_1]
420 val customData = mapOf("key" to "value", "number" to "42")
421 val dataSuccess = iconMapObject!!.setData(customData)
422 println("Set icon custom data: $dataSuccess")
423 // [kotlin_MapObject_setData_1]
425 // [kotlin_MapObject_getId_1]
427 val objectId = iconMapObject!!.id
428 println("Icon object ID: $objectId")
429 // [kotlin_MapObject_getId_1]
431 // [kotlin_MapObject_getType_1]
433 val objectTypeString = iconMapObject!!.type
434 println("Icon object type: $objectTypeString")
435 // [kotlin_MapObject_getType_1]
437 // [kotlin_MapObject_getData_1]
439 val retrievedData = iconMapObject!!.data
440 println("Icon custom data: $retrievedData")
441 // [kotlin_MapObject_getData_1]
444 // [kotlin_LocationWindow_removeIconMapObject]
445 // Remove icon map object
446 if (iconMapObject != null) {
447 val removed = locationWindow!!.removeIconMapObject(iconMapObject!!)
448 println("Removed icon map object: $removed")
451 // [kotlin_LocationWindow_removeIconMapObject]
453 // Test multiple icon objects
454 val icons = mutableListOf<IconMapObject>()
456 val icon = locationWindow!!.addIconMapObject()
458 icon.setPosition(LocationPoint(60.0 * i, 120.0 * i))
459 icon.setIcon("path/to/icon$i.png")
460 icon.setSize(Size(24.0, 24.0))
462 println("Created icon $i at (${60.0 * i}, ${120.0 * i})")
466 for (i in icons.indices) {
467 locationWindow!!.removeIconMapObject(icons[i])
468 println("Removed icon $i")
473 * Demonstrate polygon map objects
475 private fun demonstratePolygonMapObjects() {
476 println("--- Polygon Map Objects ---")
478 if (locationWindow == null) {
479 println("LocationWindow not available yet")
483 // [kotlin_LocationWindow_addPolygonMapObject]
484 // Add polygon map object
485 polygonMapObject = locationWindow!!.addPolygonMapObject()
486 println("Added polygon map object")
487 // [kotlin_LocationWindow_addPolygonMapObject]
489 if (polygonMapObject != null) {
490 // [kotlin_PolygonMapObject_setPolygon]
491 // Set polygon geometry
498 val metricPolygon = Polygon(points)
499 val polygon = LocationPolygon(metricPolygon, 1, 0)
500 val success = polygonMapObject!!.setPolygon(polygon)
501 println("Set polygon with ${points.size} points: $success")
502 // [kotlin_PolygonMapObject_setPolygon]
504 // [kotlin_PolygonMapObject_setColor]
506 val colorSuccess = polygonMapObject!!.setColor(0.0, 1.0, 0.0, 0.7)
507 println("Set polygon color to green with 70% opacity: $colorSuccess")
508 // [kotlin_PolygonMapObject_setColor]
510 // [kotlin_PolygonMapObject_setOrder]
511 // Set polygon rendering order
512 val orderSuccess = polygonMapObject!!.setOrder(2)
513 println("Set polygon rendering order to 2: $orderSuccess")
514 // [kotlin_PolygonMapObject_setOrder]
516 // [kotlin_PolygonMapObject_setOutlineColor]
517 // Set polygon outline color
518 val outlineColorSuccess = polygonMapObject!!.setOutlineColor(0.0, 0.0, 1.0, 1.0)
519 println("Set polygon outline color to blue: $outlineColorSuccess")
520 // [kotlin_PolygonMapObject_setOutlineColor]
522 // [kotlin_PolygonMapObject_setOutlineWidth]
523 // Set polygon outline width
524 val outlineWidthSuccess = polygonMapObject!!.setOutlineWidth(2.0)
525 println("Set polygon outline width to 2.0 pixels: $outlineWidthSuccess")
526 // [kotlin_PolygonMapObject_setOutlineWidth]
528 // [kotlin_PolygonMapObject_setOutlineAlpha]
529 // Set polygon outline alpha
530 val outlineAlphaSuccess = polygonMapObject!!.setOutlineAlpha(0.8)
531 println("Set polygon outline alpha to 0.8: $outlineAlphaSuccess")
532 // [kotlin_PolygonMapObject_setOutlineAlpha]
534 // [kotlin_PolygonMapObject_setOutlineOrder]
535 // Set polygon outline order
536 val outlineOrderSuccess = polygonMapObject!!.setOutlineOrder(1)
537 println("Set polygon outline order to 1: $outlineOrderSuccess")
538 // [kotlin_PolygonMapObject_setOutlineOrder]
540 // [kotlin_PolygonMapObject_setVisible]
542 val visibleSuccess = polygonMapObject!!.setVisible(true)
543 println("Set polygon visibility to true: $visibleSuccess")
544 // [kotlin_PolygonMapObject_setVisible]
546 // [kotlin_PolygonMapObject_getMapObjectType]
547 // Get map object type
548 val objectType = polygonMapObject!!.mapObjectType
549 println("Polygon map object type: $objectType")
550 // [kotlin_PolygonMapObject_getMapObjectType]
552 // [kotlin_MapObject_setAlpha_2]
553 // Set alpha transparency
554 val alphaSuccess = polygonMapObject!!.setAlpha(0.6)
555 println("Set polygon alpha to 0.6: $alphaSuccess")
556 // [kotlin_MapObject_setAlpha_2]
558 // [kotlin_MapObject_setInteractive_2]
559 // Set interactive mode
560 val interactiveSuccess = polygonMapObject!!.setInteractive(true)
561 println("Set polygon interactive to true: $interactiveSuccess")
562 // [kotlin_MapObject_setInteractive_2]
564 // [kotlin_MapObject_setTitle_2]
566 val titleSuccess = polygonMapObject!!.setTitle("Polygon Object")
567 println("Set polygon title to 'Polygon Object': $titleSuccess")
568 // [kotlin_MapObject_setTitle_2]
570 // [kotlin_MapObject_setData_2]
572 val customData = mapOf("key" to "value", "number" to "42")
573 val dataSuccess = polygonMapObject!!.setData(customData)
574 println("Set polygon custom data: $dataSuccess")
575 // [kotlin_MapObject_setData_2]
577 // [kotlin_MapObject_getId_2]
579 val objectId = polygonMapObject!!.id
580 println("Polygon object ID: $objectId")
581 // [kotlin_MapObject_getId_2]
583 // [kotlin_MapObject_getType_2]
585 val objectTypeString = polygonMapObject!!.type
586 println("Polygon object type: $objectTypeString")
587 // [kotlin_MapObject_getType_2]
589 // [kotlin_MapObject_getData_2]
591 val retrievedData = polygonMapObject!!.data
592 println("Polygon custom data: $retrievedData")
593 // [kotlin_MapObject_getData_2]
596 // [kotlin_LocationWindow_removePolygonMapObject]
597 // Remove polygon map object
598 if (polygonMapObject != null) {
599 val removed = locationWindow!!.removePolygonMapObject(polygonMapObject!!)
600 println("Removed polygon map object: $removed")
601 polygonMapObject = null
603 // [kotlin_LocationWindow_removePolygonMapObject]
605 // Test multiple polygon objects
606 val polygons = mutableListOf<PolygonMapObject>()
608 val polygon = locationWindow!!.addPolygonMapObject()
609 if (polygon != null) {
611 Point(300.0 + i * 50, 400.0 + i * 50),
612 Point(350.0 + i * 50, 450.0 + i * 50),
613 Point(400.0 + i * 50, 400.0 + i * 50),
614 Point(350.0 + i * 50, 350.0 + i * 50)
616 val metricPoly = Polygon(points)
617 val polygonGeometry = LocationPolygon(metricPoly, 1, 0)
618 polygon.setPolygon(polygonGeometry)
619 polygon.setColor(0.0, 0.0, 1.0, 0.5)
620 polygons.add(polygon)
621 println("Created polygon $i with ${points.size} points")
625 for (i in polygons.indices) {
626 locationWindow!!.removePolygonMapObject(polygons[i])
627 println("Removed polygon $i")
632 * Demonstrate polyline map objects
634 private fun demonstratePolylineMapObjects() {
635 println("--- Polyline Map Objects ---")
637 if (locationWindow == null) {
638 println("LocationWindow not available yet")
642 // [kotlin_PolylineMapObject_constructor]
643 // Create polyline map object
650 val metricPolyline = Polyline(points)
651 val polyline = LocationPolyline(metricPolyline, 1, 0)
652 polylineMapObject = locationWindow!!.addPolylineMapObject()
653 println("Created polyline map object with ${points.size} points")
654 // [kotlin_PolylineMapObject_constructor]
656 // [kotlin_PolylineMapObject_getPolyline]
658 val polylineShape = polylineMapObject!!.getPolyLine()
659 println("Polyline has ${polylineShape.getPolyline().getPoints().size} points")
660 // [kotlin_PolylineMapObject_getPolyline]
662 // [kotlin_LocationWindow_addPolylineMapObject]
663 // Add polyline map object
664 polylineMapObject = locationWindow!!.addPolylineMapObject()
665 println("Added polyline map object")
666 // [kotlin_LocationWindow_addPolylineMapObject]
668 if (polylineMapObject != null) {
669 // [kotlin_PolylineMapObject_setPolyLine]
670 // Set polyline geometry
677 val metricPl = Polyline(points)
678 val polyline = LocationPolyline(metricPl, 1, 0)
679 val success = polylineMapObject!!.setPolyLine(polyline)
680 println("Set polyline with ${points.size} points: $success")
681 // [kotlin_PolylineMapObject_setPolyLine]
683 // [kotlin_PolylineMapObject_setWidth]
684 // Set polyline width
685 val widthSuccess = polylineMapObject!!.setWidth(3.0)
686 println("Set polyline width to 3.0 pixels: $widthSuccess")
687 // [kotlin_PolylineMapObject_setWidth]
689 // [kotlin_PolylineMapObject_setColor]
690 // Set polyline color
691 val colorSuccess = polylineMapObject!!.setColor(0.0, 1.0, 0.0, 0.8)
692 println("Set polyline color to green with 80% opacity: $colorSuccess")
693 // [kotlin_PolylineMapObject_setColor]
695 // [kotlin_PolylineMapObject_setOrder]
696 // Set polyline rendering order
697 val orderSuccess = polylineMapObject!!.setOrder(1)
698 println("Set polyline rendering order to 1: $orderSuccess")
699 // [kotlin_PolylineMapObject_setOrder]
701 // [kotlin_PolylineMapObject_setCapType]
702 // Set polyline cap type
703 val capTypeSuccess = polylineMapObject!!.setCapType(CapType.ROUND)
704 println("Set polyline cap type to ROUND: $capTypeSuccess")
705 // [kotlin_PolylineMapObject_setCapType]
707 // [kotlin_PolylineMapObject_setJoinType]
708 // Set polyline join type
709 val joinTypeSuccess = polylineMapObject!!.setJoinType(JoinType.ROUND)
710 println("Set polyline join type to ROUND: $joinTypeSuccess")
711 // [kotlin_PolylineMapObject_setJoinType]
713 // [kotlin_PolylineMapObject_setMiterLimit]
714 // Set polyline miter limit
715 val miterLimitSuccess = polylineMapObject!!.setMiterLimit(2.0)
716 println("Set polyline miter limit to 2.0: $miterLimitSuccess")
717 // [kotlin_PolylineMapObject_setMiterLimit]
719 // [kotlin_PolylineMapObject_setOutlineWidth]
720 // Set polyline outline width
721 val outlineWidthSuccess = polylineMapObject!!.setOutlineWidth(1.0)
722 println("Set polyline outline width to 1.0 pixels: $outlineWidthSuccess")
723 // [kotlin_PolylineMapObject_setOutlineWidth]
725 // [kotlin_PolylineMapObject_setOutlineColor]
726 // Set polyline outline color
727 val outlineColorSuccess = polylineMapObject!!.setOutlineColor(0.0, 0.0, 0.0, 1.0)
728 println("Set polyline outline color to black: $outlineColorSuccess")
729 // [kotlin_PolylineMapObject_setOutlineColor]
731 // [kotlin_PolylineMapObject_setOutlineAlpha]
732 // Set polyline outline alpha
733 val outlineAlphaSuccess = polylineMapObject!!.setOutlineAlpha(0.5)
734 println("Set polyline outline alpha to 0.5: $outlineAlphaSuccess")
735 // [kotlin_PolylineMapObject_setOutlineAlpha]
737 // [kotlin_PolylineMapObject_setOutlineOrder]
738 // Set polyline outline rendering order
739 val outlineOrderSuccess = polylineMapObject!!.setOutlineOrder(0)
740 println("Set polyline outline rendering order to 0: $outlineOrderSuccess")
741 // [kotlin_PolylineMapObject_setOutlineOrder]
743 // [kotlin_PolylineMapObject_setOutlineCapType]
744 // Set polyline outline cap type
745 val outlineCapTypeSuccess = polylineMapObject!!.setOutlineCapType(CapType.SQUARE)
746 println("Set polyline outline cap type to SQUARE: $outlineCapTypeSuccess")
747 // [kotlin_PolylineMapObject_setOutlineCapType]
749 // [kotlin_PolylineMapObject_setOutlineJoinType]
750 // Set polyline outline join type
751 val outlineJoinTypeSuccess = polylineMapObject!!.setOutlineJoinType(JoinType.MITER)
752 println("Set polyline outline join type to MITER: $outlineJoinTypeSuccess")
753 // [kotlin_PolylineMapObject_setOutlineJoinType]
755 // [kotlin_PolylineMapObject_setOutlineMiterLimit]
756 // Set polyline outline miter limit
757 val outlineMiterLimitSuccess = polylineMapObject!!.setOutlineMiterLimit(3.0)
758 println("Set polyline outline miter limit to 3.0: $outlineMiterLimitSuccess")
759 // [kotlin_PolylineMapObject_setOutlineMiterLimit]
761 // [kotlin_PolylineMapObject_setVisible]
763 val visibleSuccess = polylineMapObject!!.setVisible(true)
764 println("Set polyline visibility to true: $visibleSuccess")
765 // [kotlin_PolylineMapObject_setVisible]
767 // [kotlin_PolylineMapObject_getMapObjectType]
768 // Get map object type
769 val objectType = polylineMapObject!!.mapObjectType
770 println("Polyline map object type: $objectType")
771 // [kotlin_PolylineMapObject_getMapObjectType]
773 // [kotlin_MapObject_setAlpha_3]
774 // Set alpha transparency
775 val alphaSuccess = polylineMapObject!!.setAlpha(0.7)
776 println("Set polyline alpha to 0.7: $alphaSuccess")
777 // [kotlin_MapObject_setAlpha_3]
779 // [kotlin_MapObject_setInteractive_3]
780 // Set interactive mode
781 val interactiveSuccess = polylineMapObject!!.setInteractive(true)
782 println("Set polyline interactive to true: $interactiveSuccess")
783 // [kotlin_MapObject_setInteractive_3]
785 // [kotlin_MapObject_setTitle_3]
787 val titleSuccess = polylineMapObject!!.setTitle("Polyline Object")
788 println("Set polyline title to 'Polyline Object': $titleSuccess")
789 // [kotlin_MapObject_setTitle_3]
791 // [kotlin_MapObject_setData_3]
793 val customData = mapOf("key" to "value", "number" to "42")
794 val dataSuccess = polylineMapObject!!.setData(customData)
795 println("Set polyline custom data: $dataSuccess")
796 // [kotlin_MapObject_setData_3]
798 // [kotlin_MapObject_getId_3]
800 val objectId = polylineMapObject!!.id
801 println("Polyline object ID: $objectId")
802 // [kotlin_MapObject_getId_3]
804 // [kotlin_MapObject_getType_3]
806 val objectTypeString = polylineMapObject!!.type
807 println("Polyline object type: $objectTypeString")
808 // [kotlin_MapObject_getType_3]
810 // [kotlin_MapObject_getData_3]
812 val retrievedData = polylineMapObject!!.data
813 println("Polyline custom data: $retrievedData")
814 // [kotlin_MapObject_getData_3]
817 // [kotlin_LocationWindow_removePolylineMapObject]
818 // Remove polyline map object
819 if (polylineMapObject != null) {
820 val removed = locationWindow!!.removePolylineMapObject(polylineMapObject!!)
821 println("Removed polyline map object: $removed")
822 polylineMapObject = null
824 // [kotlin_LocationWindow_removePolylineMapObject]
826 // Test multiple polyline objects
827 val polylines = mutableListOf<PolylineMapObject>()
829 val polyline = locationWindow!!.addPolylineMapObject()
830 if (polyline != null) {
832 Point(120.0 + i * 30, 130.0 + i * 30),
833 Point(125.0 + i * 30, 135.0 + i * 30),
834 Point(130.0 + i * 30, 140.0 + i * 30)
836 val metricPl = Polyline(points)
837 val polylineGeometry = LocationPolyline(metricPl, 1, 0)
838 polyline.setPolyLine(polylineGeometry)
839 polyline.setColor(1.0, 0.0, 0.0, 0.6)
840 polyline.setWidth(2.0)
841 polylines.add(polyline)
842 println("Created polyline $i with ${points.size} points")
846 for (i in polylines.indices) {
847 locationWindow!!.removePolylineMapObject(polylines[i])
848 println("Removed polyline $i")
853 * Demonstrate dotted polyline map objects
855 private fun demonstrateDottedPolylineMapObjects() {
856 println("--- Dotted Polyline Map Objects ---")
858 if (locationWindow == null) {
859 println("LocationWindow not available yet")
863 // [kotlin_DottedPolylineMapObject_constructor]
864 // Create dotted polyline map object
871 val dottedMetric = Polyline(points)
872 val polyline = LocationPolyline(dottedMetric, 1, 0)
873 dottedPolylineMapObject = locationWindow!!.addDottedPolylineMapObject()
874 println("Created dotted polyline map object with ${points.size} points")
875 // [kotlin_DottedPolylineMapObject_constructor]
877 // [kotlin_DottedPolylineMapObject_getPolyline]
878 // Access dotted polyline
879 val dottedPolylineShape = dottedPolylineMapObject!!.getPolyLine()
880 println("Dotted polyline has ${dottedPolylineShape.getPolyline().getPoints().size} points")
881 // [kotlin_DottedPolylineMapObject_getPolyline]
883 // [kotlin_LocationWindow_addDottedPolylineMapObject]
884 // Add dotted polyline map object
885 dottedPolylineMapObject = locationWindow!!.addDottedPolylineMapObject()
886 println("Added dotted polyline map object")
887 // [kotlin_LocationWindow_addDottedPolylineMapObject]
889 if (dottedPolylineMapObject != null) {
890 // [kotlin_DottedPolylineMapObject_setPolyline]
891 // Set dotted polyline geometry
898 val dottedPl = Polyline(points)
899 val polyline = LocationPolyline(dottedPl, 1, 0)
900 val success = dottedPolylineMapObject!!.setPolyline(polyline)
901 println("Set dotted polyline with ${points.size} points: $success")
902 // [kotlin_DottedPolylineMapObject_setPolyline]
904 // [kotlin_DottedPolylineMapObject_setColor]
905 // Set dotted polyline color
906 val colorSuccess = dottedPolylineMapObject!!.setColor(0.5, 0.0, 1.0, 0.8)
907 println("Set dotted polyline color to purple with 80% opacity: $colorSuccess")
908 // [kotlin_DottedPolylineMapObject_setColor]
910 // [kotlin_DottedPolylineMapObject_setWidth]
911 // Set dotted polyline width
912 val widthSuccess = dottedPolylineMapObject!!.setWidth(3.0)
913 println("Set dotted polyline width to 3.0 pixels: $widthSuccess")
914 // [kotlin_DottedPolylineMapObject_setWidth]
916 // [kotlin_DottedPolylineMapObject_setOrder]
917 // Set dotted polyline rendering order
918 val orderSuccess = dottedPolylineMapObject!!.setOrder(2)
919 println("Set dotted polyline rendering order to 2: $orderSuccess")
920 // [kotlin_DottedPolylineMapObject_setOrder]
922 // [kotlin_DottedPolylineMapObject_setCollisionEnabled]
923 // Enable collision detection
924 val collisionSuccess = dottedPolylineMapObject!!.setCollisionEnabled(true)
925 println("Enabled collision detection for dotted polyline: $collisionSuccess")
926 // [kotlin_DottedPolylineMapObject_setCollisionEnabled]
928 // [kotlin_DottedPolylineMapObject_setPlacement]
929 // Set placement type
930 val placementSuccess = dottedPolylineMapObject!!.setPlacement(Placement.CENTER)
931 println("Set dotted polyline placement to CENTER: $placementSuccess")
932 // [kotlin_DottedPolylineMapObject_setPlacement]
934 // [kotlin_DottedPolylineMapObject_setPlacementMinRatio]
935 // Set placement min ratio
936 val minRatioSuccess = dottedPolylineMapObject!!.setPlacementMinRatio(0.5)
937 println("Set dotted polyline placement min ratio to 0.5: $minRatioSuccess")
938 // [kotlin_DottedPolylineMapObject_setPlacementMinRatio]
940 // [kotlin_DottedPolylineMapObject_setPlacementSpacing]
941 // Set placement spacing
942 val spacingSuccess = dottedPolylineMapObject!!.setPlacementSpacing(10.0)
943 println("Set dotted polyline placement spacing to 10.0: $spacingSuccess")
944 // [kotlin_DottedPolylineMapObject_setPlacementSpacing]
946 // [kotlin_DottedPolylineMapObject_setPriority]
947 // Set rendering priority
948 val prioritySuccess = dottedPolylineMapObject!!.setPriority(1)
949 println("Set dotted polyline rendering priority to 1: $prioritySuccess")
950 // [kotlin_DottedPolylineMapObject_setPriority]
952 // [kotlin_DottedPolylineMapObject_setRepeatDistance]
953 // Set repeat distance
954 val repeatDistanceSuccess = dottedPolylineMapObject!!.setRepeatDistance(20.0)
955 println("Set dotted polyline repeat distance to 20.0: $repeatDistanceSuccess")
956 // [kotlin_DottedPolylineMapObject_setRepeatDistance]
958 // [kotlin_DottedPolylineMapObject_setRepeatGroup]
960 val repeatGroupSuccess = dottedPolylineMapObject!!.setRepeatGroup(1)
961 println("Set dotted polyline repeat group to 1: $repeatGroupSuccess")
962 // [kotlin_DottedPolylineMapObject_setRepeatGroup]
964 // [kotlin_DottedPolylineMapObject_setSize]
966 val size = Size(16.0, 16.0)
967 val sizeSuccess = dottedPolylineMapObject!!.setSize(size)
968 println("Set dotted polyline size to (${size.width}, ${size.height}): $sizeSuccess")
969 // [kotlin_DottedPolylineMapObject_setSize]
971 // [kotlin_DottedPolylineMapObject_setVisible]
973 val visibleSuccess = dottedPolylineMapObject!!.setVisible(true)
974 println("Set dotted polyline visibility to true: $visibleSuccess")
975 // [kotlin_DottedPolylineMapObject_setVisible]
977 // [kotlin_DottedPolylineMapObject_getMapObjectType]
978 // Get map object type
979 val objectType = dottedPolylineMapObject!!.mapObjectType
980 println("Dotted polyline map object type: $objectType")
981 // [kotlin_DottedPolylineMapObject_getMapObjectType]
983 // [kotlin_MapObject_setAlpha_4]
984 // Set alpha transparency
985 val alphaSuccess = dottedPolylineMapObject!!.setAlpha(0.8)
986 println("Set dotted polyline alpha to 0.8: $alphaSuccess")
987 // [kotlin_MapObject_setAlpha_4]
989 // [kotlin_MapObject_setInteractive_4]
990 // Set interactive mode
991 val interactiveSuccess = dottedPolylineMapObject!!.setInteractive(true)
992 println("Set dotted polyline interactive to true: $interactiveSuccess")
993 // [kotlin_MapObject_setInteractive_4]
995 // [kotlin_MapObject_setTitle_4]
997 val titleSuccess = dottedPolylineMapObject!!.setTitle("Dotted Polyline Object")
998 println("Set dotted polyline title to 'Dotted Polyline Object': $titleSuccess")
999 // [kotlin_MapObject_setTitle_4]
1001 // [kotlin_MapObject_setData_4]
1003 val customData = mapOf("key" to "value", "number" to "42")
1004 val dataSuccess = dottedPolylineMapObject!!.setData(customData)
1005 println("Set dotted polyline custom data: $dataSuccess")
1006 // [kotlin_MapObject_setData_4]
1008 // [kotlin_MapObject_getId_4]
1010 val objectId = dottedPolylineMapObject!!.id
1011 println("Dotted polyline object ID: $objectId")
1012 // [kotlin_MapObject_getId_4]
1014 // [kotlin_MapObject_getType_4]
1016 val objectTypeString = dottedPolylineMapObject!!.type
1017 println("Dotted polyline object type: $objectTypeString")
1018 // [kotlin_MapObject_getType_4]
1020 // [kotlin_MapObject_getData_4]
1022 val retrievedData = dottedPolylineMapObject!!.data
1023 println("Dotted polyline custom data: $retrievedData")
1024 // [kotlin_MapObject_getData_4]
1027 // [kotlin_LocationWindow_removeDottedPolylineMapObject]
1028 // Remove dotted polyline map object
1029 if (dottedPolylineMapObject != null) {
1030 val removed = locationWindow!!.removeDottedPolylineMapObject(dottedPolylineMapObject!!)
1031 println("Removed dotted polyline map object: $removed")
1032 dottedPolylineMapObject = null
1034 // [kotlin_LocationWindow_removeDottedPolylineMapObject]
1036 // Test multiple dotted polyline objects
1037 val dottedPolylines = mutableListOf<DottedPolylineMapObject>()
1039 val dottedPolyline = locationWindow!!.addDottedPolylineMapObject()
1040 if (dottedPolyline != null) {
1041 val points = listOf(
1042 Point(180.0 + i * 30, 190.0 + i * 30),
1043 Point(185.0 + i * 30, 195.0 + i * 30),
1044 Point(190.0 + i * 30, 200.0 + i * 30)
1046 val pl = Polyline(points)
1047 val polylineGeometry = LocationPolyline(pl, 1, 0)
1048 dottedPolyline.setPolyline(polylineGeometry)
1049 dottedPolylines.add(dottedPolyline)
1050 println("Created dotted polyline $i with ${points.size} points")
1054 for (i in dottedPolylines.indices) {
1055 locationWindow!!.removeDottedPolylineMapObject(dottedPolylines[i])
1056 println("Removed dotted polyline $i")
1061 * Demonstrate remove all map objects
1063 private fun demonstrateRemoveAllMapObjects() {
1064 println("--- Remove All Map Objects ---")
1066 if (locationWindow == null) {
1067 println("LocationWindow not available yet")
1071 println("Current map objects count: ${getMapObjectsCount()}")
1073 // [kotlin_LocationWindow_removeAllMapObjects]
1074 // Remove all map objects
1075 locationWindow!!.removeAllMapObjects()
1076 println("Removed all map objects")
1077 // [kotlin_LocationWindow_removeAllMapObjects]
1079 println("Map objects count after removal: ${getMapObjectsCount()}")
1083 * Get current map objects count
1085 private fun getMapObjectsCount(): Int {
1087 if (circleMapObject != null) count++
1088 if (iconMapObject != null) count++
1089 if (polygonMapObject != null) count++
1090 if (polylineMapObject != null) count++
1091 if (dottedPolylineMapObject != null) count++
1098 private fun cleanup() {
1099 println("--- Cleanup ---")
1101 if (locationWindow != null) {
1102 locationWindow!!.removeAllMapObjects()
1103 println("Cleaned up all map objects")
1106 circleMapObject = null
1107 iconMapObject = null
1108 polygonMapObject = null
1109 polylineMapObject = null
1110 dottedPolylineMapObject = null
1111 println("Cleared map objects references")
1115// Main function to run the example
1117 LocationWindowMapObjectsExample()