Loading...
Searching...
No Matches
LocationWindowMapObjectsExample.kt
Go to the documentation of this file.
1package com.navigine.examples
2
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
20
21/**
22 * LocationWindowMapObjects usage example for Kotlin
23 * Demonstrates specific methods: addCircleMapObject, removeCircleMapObject, addIconMapObject,
24 * removeIconMapObject, addPolygonMapObject, addPolylineMapObject, removePolylineMapObject,
25 * addDottedPolylineMapObject, removeDottedPolylineMapObject, removeAllMapObjects
26 */
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
34
35 init {
36 demonstrateLocationWindowMapObjectsMethods()
37 }
38
39 /**
40 * Demonstrate LocationWindowMapObjects methods
41 */
42 private fun demonstrateLocationWindowMapObjectsMethods() {
43 println("=== LocationWindowMapObjects Example ===")
44
45 // Initialize LocationWindow (in real app, this would be provided by the framework)
46 // locationWindow = getLocationWindow()
47
48 demonstrateCircleMapObjects()
49 demonstrateIconMapObjects()
50 demonstratePolygonMapObjects()
51 demonstratePolylineMapObjects()
52 demonstrateDottedPolylineMapObjects()
53 demonstrateRemoveAllMapObjects()
54
55 cleanup()
56 }
57
58 /**
59 * Demonstrate circle map objects
60 */
61 private fun demonstrateCircleMapObjects() {
62 println("--- Circle Map Objects ---")
63
64 if (locationWindow == null) {
65 println("LocationWindow not available yet")
66 return
67 }
68
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]
75
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]
81
82 // [kotlin_CircleMapObject_getRadius]
83 // Access circle radius
84 val radius = circleMapObject!!.getRadius()
85 println("Circle radius: $radius")
86 // [kotlin_CircleMapObject_getRadius]
87
88 // [kotlin_LocationWindow_addCircleMapObject]
89 // Add circle map object
90 circleMapObject = locationWindow!!.addCircleMapObject()
91 println("Added circle map object")
92 // [kotlin_LocationWindow_addCircleMapObject]
93
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]
101
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]
108
109 // [kotlin_CircleMapObject_setRadius]
110 // Set circle radius
111 val radiusSuccess = circleMapObject!!.setRadius(10.0)
112 println("Set circle radius to 10.0 meters: $radiusSuccess")
113 // [kotlin_CircleMapObject_setRadius]
114
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]
120
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]
126
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]
132
133 // [kotlin_CircleMapObject_setOutlineColor]
134 // Set outline color
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]
138
139 // [kotlin_CircleMapObject_setOutlineAlpha]
140 // Set outline alpha
141 val outlineAlphaSuccess = circleMapObject!!.setOutlineAlpha(0.5)
142 println("Set circle outline alpha to 0.5: $outlineAlphaSuccess")
143 // [kotlin_CircleMapObject_setOutlineAlpha]
144
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]
150
151 // [kotlin_CircleMapObject_setColor]
152 // Set circle color
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]
156
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]
162
163 // [kotlin_MapObject_setVisible]
164 // Set visibility
165 val visibleSuccess = circleMapObject!!.setVisible(true)
166 println("Set circle visibility to true: $visibleSuccess")
167 // [kotlin_MapObject_setVisible]
168
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]
174
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]
180
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]
186
187 // [kotlin_MapObject_setTitle]
188 // Set title
189 val titleSuccess = circleMapObject!!.setTitle("Circle Object")
190 println("Set circle title to 'Circle Object': $titleSuccess")
191 // [kotlin_MapObject_setTitle]
192
193 // [kotlin_MapObject_setData]
194 // Set custom data
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]
199
200 // [kotlin_MapObject_getId]
201 // Get object ID
202 val objectId = circleMapObject!!.id
203 println("Circle object ID: $objectId")
204 // [kotlin_MapObject_getId]
205
206 // [kotlin_MapObject_getType]
207 // Get object type
208 val objectTypeString = circleMapObject!!.type
209 println("Circle object type: $objectTypeString")
210 // [kotlin_MapObject_getType]
211
212 // [kotlin_MapObject_getData]
213 // Get custom data
214 val retrievedData = circleMapObject!!.data
215 println("Circle custom data: $retrievedData")
216 // [kotlin_MapObject_getData]
217 }
218
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
225 }
226 // [kotlin_LocationWindow_removeCircleMapObject]
227
228 // Test multiple circle objects
229 val circles = mutableListOf<CircleMapObject>()
230 for (i in 0..2) {
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)
236 circles.add(circle)
237 println("Created circle $i at (${50.0 * i}, ${100.0 * i}) with radius ${5.0 + i * 2.0}")
238 }
239 }
240
241 for (i in circles.indices) {
242 locationWindow!!.removeCircleMapObject(circles[i])
243 println("Removed circle $i")
244 }
245 }
246
247 /**
248 * Demonstrate icon map objects
249 */
250 private fun demonstrateIconMapObjects() {
251 println("--- Icon Map Objects ---")
252
253 if (locationWindow == null) {
254 println("LocationWindow not available yet")
255 return
256 }
257
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]
264
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]
270
271 // [kotlin_LocationWindow_addIconMapObject]
272 // Add icon map object
273 iconMapObject = locationWindow!!.addIconMapObject()
274 println("Added icon map object")
275 // [kotlin_LocationWindow_addIconMapObject]
276
277 if (iconMapObject != null) {
278 // [kotlin_IconMapObject_setPosition]
279 // Set icon position
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]
284
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]
291
292 // [kotlin_IconMapObject_setIcon]
293 // Set icon image
294 val iconSuccess = iconMapObject!!.setIcon("path/to/icon.png")
295 println("Set icon image: $iconSuccess")
296 // [kotlin_IconMapObject_setIcon]
297
298 // [kotlin_IconMapObject_setBitmap]
299 // Set icon bitmap
300 val bitmapSuccess = iconMapObject!!.setBitmap("path/to/bitmap.png")
301 println("Set icon bitmap: $bitmapSuccess")
302 // [kotlin_IconMapObject_setBitmap]
303
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]
309
310 // [kotlin_IconMapObject_setSize]
311 // Set icon size
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]
316
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]
322
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]
328
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]
334
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]
340
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]
346
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]
352
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]
358
359 // [kotlin_IconMapObject_setVisible]
360 // Set visibility
361 val visibleSuccess = iconMapObject!!.setVisible(true)
362 println("Set icon visibility to true: $visibleSuccess")
363 // [kotlin_IconMapObject_setVisible]
364
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]
370
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]
376
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]
382
383 // [kotlin_MapObject_setTitle_1]
384 // Set title
385 val titleSuccess = iconMapObject!!.setTitle("Icon Object")
386 println("Set icon title to 'Icon Object': $titleSuccess")
387 // [kotlin_MapObject_setTitle_1]
388
389 // [kotlin_MapObject_setData_1]
390 // Set custom data
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]
395
396 // [kotlin_MapObject_getId_1]
397 // Get object ID
398 val objectId = iconMapObject!!.id
399 println("Icon object ID: $objectId")
400 // [kotlin_MapObject_getId_1]
401
402 // [kotlin_MapObject_getType_1]
403 // Get object type
404 val objectTypeString = iconMapObject!!.type
405 println("Icon object type: $objectTypeString")
406 // [kotlin_MapObject_getType_1]
407
408 // [kotlin_MapObject_getData_1]
409 // Get custom data
410 val retrievedData = iconMapObject!!.data
411 println("Icon custom data: $retrievedData")
412 // [kotlin_MapObject_getData_1]
413 }
414
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")
420 iconMapObject = null
421 }
422 // [kotlin_LocationWindow_removeIconMapObject]
423
424 // Test multiple icon objects
425 val icons = mutableListOf<IconMapObject>()
426 for (i in 0..2) {
427 val icon = locationWindow!!.addIconMapObject()
428 if (icon != null) {
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))
432 icons.add(icon)
433 println("Created icon $i at (${60.0 * i}, ${120.0 * i})")
434 }
435 }
436
437 for (i in icons.indices) {
438 locationWindow!!.removeIconMapObject(icons[i])
439 println("Removed icon $i")
440 }
441 }
442
443 /**
444 * Demonstrate polygon map objects
445 */
446 private fun demonstratePolygonMapObjects() {
447 println("--- Polygon Map Objects ---")
448
449 if (locationWindow == null) {
450 println("LocationWindow not available yet")
451 return
452 }
453
454 // [kotlin_LocationWindow_addPolygonMapObject]
455 // Add polygon map object
456 polygonMapObject = locationWindow!!.addPolygonMapObject()
457 println("Added polygon map object")
458 // [kotlin_LocationWindow_addPolygonMapObject]
459
460 if (polygonMapObject != null) {
461 // [kotlin_PolygonMapObject_setPolygon]
462 // Set polygon geometry
463 val points = listOf(
464 LocationPoint(50.0, 60.0),
465 LocationPoint(55.0, 65.0),
466 LocationPoint(60.0, 60.0),
467 LocationPoint(55.0, 55.0)
468 )
469 val polygon = LocationPolygon(points)
470 val success = polygonMapObject!!.setPolygon(polygon)
471 println("Set polygon with ${points.size} points: $success")
472 // [kotlin_PolygonMapObject_setPolygon]
473
474 // [kotlin_PolygonMapObject_setColor]
475 // Set polygon color
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]
479
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]
485
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]
491
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]
497
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]
503
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]
509
510 // [kotlin_PolygonMapObject_setVisible]
511 // Set visibility
512 val visibleSuccess = polygonMapObject!!.setVisible(true)
513 println("Set polygon visibility to true: $visibleSuccess")
514 // [kotlin_PolygonMapObject_setVisible]
515
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]
521
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]
527
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]
533
534 // [kotlin_MapObject_setTitle_2]
535 // Set title
536 val titleSuccess = polygonMapObject!!.setTitle("Polygon Object")
537 println("Set polygon title to 'Polygon Object': $titleSuccess")
538 // [kotlin_MapObject_setTitle_2]
539
540 // [kotlin_MapObject_setData_2]
541 // Set custom data
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]
546
547 // [kotlin_MapObject_getId_2]
548 // Get object ID
549 val objectId = polygonMapObject!!.id
550 println("Polygon object ID: $objectId")
551 // [kotlin_MapObject_getId_2]
552
553 // [kotlin_MapObject_getType_2]
554 // Get object type
555 val objectTypeString = polygonMapObject!!.type
556 println("Polygon object type: $objectTypeString")
557 // [kotlin_MapObject_getType_2]
558
559 // [kotlin_MapObject_getData_2]
560 // Get custom data
561 val retrievedData = polygonMapObject!!.data
562 println("Polygon custom data: $retrievedData")
563 // [kotlin_MapObject_getData_2]
564 }
565
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
572 }
573 // [kotlin_LocationWindow_removePolygonMapObject]
574
575 // Test multiple polygon objects
576 val polygons = mutableListOf<PolygonMapObject>()
577 for (i in 0..2) {
578 val polygon = locationWindow!!.addPolygonMapObject()
579 if (polygon != null) {
580 val points = listOf(
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)
585 )
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")
591 }
592 }
593
594 for (i in polygons.indices) {
595 locationWindow!!.removePolygonMapObject(polygons[i])
596 println("Removed polygon $i")
597 }
598 }
599
600 /**
601 * Demonstrate polyline map objects
602 */
603 private fun demonstratePolylineMapObjects() {
604 println("--- Polyline Map Objects ---")
605
606 if (locationWindow == null) {
607 println("LocationWindow not available yet")
608 return
609 }
610
611 // [kotlin_PolylineMapObject_constructor]
612 // Create polyline map object
613 val points = listOf(
614 LocationPoint(100.0, 110.0),
615 LocationPoint(105.0, 115.0),
616 LocationPoint(110.0, 120.0),
617 LocationPoint(115.0, 125.0)
618 )
619 val polyline = LocationPolyline(points)
620 polylineMapObject = locationWindow!!.addPolylineMapObject()
621 println("Created polyline map object with ${points.size} points")
622 // [kotlin_PolylineMapObject_constructor]
623
624 // [kotlin_PolylineMapObject_getPolyline]
625 // Access polyline
626 val polylineShape = polylineMapObject!!.getPolyLine()
627 println("Polyline has ${polylineShape.points.size} points")
628 // [kotlin_PolylineMapObject_getPolyline]
629
630 // [kotlin_LocationWindow_addPolylineMapObject]
631 // Add polyline map object
632 polylineMapObject = locationWindow!!.addPolylineMapObject()
633 println("Added polyline map object")
634 // [kotlin_LocationWindow_addPolylineMapObject]
635
636 if (polylineMapObject != null) {
637 // [kotlin_PolylineMapObject_setPolyLine]
638 // Set polyline geometry
639 val points = listOf(
640 LocationPoint(100.0, 110.0),
641 LocationPoint(105.0, 115.0),
642 LocationPoint(110.0, 120.0),
643 LocationPoint(115.0, 125.0)
644 )
645 val polyline = LocationPolyline(points)
646 val success = polylineMapObject!!.setPolyLine(polyline)
647 println("Set polyline with ${points.size} points: $success")
648 // [kotlin_PolylineMapObject_setPolyLine]
649
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]
655
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]
661
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]
667
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]
673
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]
679
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]
685
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]
691
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]
697
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]
703
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]
709
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]
715
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]
721
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]
727
728 // [kotlin_PolylineMapObject_setVisible]
729 // Set visibility
730 val visibleSuccess = polylineMapObject!!.setVisible(true)
731 println("Set polyline visibility to true: $visibleSuccess")
732 // [kotlin_PolylineMapObject_setVisible]
733
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]
739
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]
745
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]
751
752 // [kotlin_MapObject_setTitle_3]
753 // Set title
754 val titleSuccess = polylineMapObject!!.setTitle("Polyline Object")
755 println("Set polyline title to 'Polyline Object': $titleSuccess")
756 // [kotlin_MapObject_setTitle_3]
757
758 // [kotlin_MapObject_setData_3]
759 // Set custom data
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]
764
765 // [kotlin_MapObject_getId_3]
766 // Get object ID
767 val objectId = polylineMapObject!!.id
768 println("Polyline object ID: $objectId")
769 // [kotlin_MapObject_getId_3]
770
771 // [kotlin_MapObject_getType_3]
772 // Get object type
773 val objectTypeString = polylineMapObject!!.type
774 println("Polyline object type: $objectTypeString")
775 // [kotlin_MapObject_getType_3]
776
777 // [kotlin_MapObject_getData_3]
778 // Get custom data
779 val retrievedData = polylineMapObject!!.data
780 println("Polyline custom data: $retrievedData")
781 // [kotlin_MapObject_getData_3]
782 }
783
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
790 }
791 // [kotlin_LocationWindow_removePolylineMapObject]
792
793 // Test multiple polyline objects
794 val polylines = mutableListOf<PolylineMapObject>()
795 for (i in 0..2) {
796 val polyline = locationWindow!!.addPolylineMapObject()
797 if (polyline != null) {
798 val points = listOf(
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)
802 )
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")
809 }
810 }
811
812 for (i in polylines.indices) {
813 locationWindow!!.removePolylineMapObject(polylines[i])
814 println("Removed polyline $i")
815 }
816 }
817
818 /**
819 * Demonstrate dotted polyline map objects
820 */
821 private fun demonstrateDottedPolylineMapObjects() {
822 println("--- Dotted Polyline Map Objects ---")
823
824 if (locationWindow == null) {
825 println("LocationWindow not available yet")
826 return
827 }
828
829 // [kotlin_DottedPolylineMapObject_constructor]
830 // Create dotted polyline map object
831 val points = listOf(
832 LocationPoint(160.0, 170.0),
833 LocationPoint(165.0, 175.0),
834 LocationPoint(170.0, 180.0),
835 LocationPoint(175.0, 185.0)
836 )
837 val polyline = LocationPolyline(points)
838 dottedPolylineMapObject = locationWindow!!.addDottedPolylineMapObject()
839 println("Created dotted polyline map object with ${points.size} points")
840 // [kotlin_DottedPolylineMapObject_constructor]
841
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]
847
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]
853
854 if (dottedPolylineMapObject != null) {
855 // [kotlin_DottedPolylineMapObject_setPolyline]
856 // Set dotted polyline geometry
857 val points = listOf(
858 LocationPoint(160.0, 170.0),
859 LocationPoint(165.0, 175.0),
860 LocationPoint(170.0, 180.0),
861 LocationPoint(175.0, 185.0)
862 )
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]
867
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]
873
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]
879
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]
885
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]
891
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]
897
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]
903
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]
909
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]
915
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]
921
922 // [kotlin_DottedPolylineMapObject_setRepeatGroup]
923 // Set repeat group
924 val repeatGroupSuccess = dottedPolylineMapObject!!.setRepeatGroup(1)
925 println("Set dotted polyline repeat group to 1: $repeatGroupSuccess")
926 // [kotlin_DottedPolylineMapObject_setRepeatGroup]
927
928 // [kotlin_DottedPolylineMapObject_setSize]
929 // Set size
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]
934
935 // [kotlin_DottedPolylineMapObject_setVisible]
936 // Set visibility
937 val visibleSuccess = dottedPolylineMapObject!!.setVisible(true)
938 println("Set dotted polyline visibility to true: $visibleSuccess")
939 // [kotlin_DottedPolylineMapObject_setVisible]
940
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]
946
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]
952
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]
958
959 // [kotlin_MapObject_setTitle_4]
960 // Set title
961 val titleSuccess = dottedPolylineMapObject!!.setTitle("Dotted Polyline Object")
962 println("Set dotted polyline title to 'Dotted Polyline Object': $titleSuccess")
963 // [kotlin_MapObject_setTitle_4]
964
965 // [kotlin_MapObject_setData_4]
966 // Set custom data
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]
971
972 // [kotlin_MapObject_getId_4]
973 // Get object ID
974 val objectId = dottedPolylineMapObject!!.id
975 println("Dotted polyline object ID: $objectId")
976 // [kotlin_MapObject_getId_4]
977
978 // [kotlin_MapObject_getType_4]
979 // Get object type
980 val objectTypeString = dottedPolylineMapObject!!.type
981 println("Dotted polyline object type: $objectTypeString")
982 // [kotlin_MapObject_getType_4]
983
984 // [kotlin_MapObject_getData_4]
985 // Get custom data
986 val retrievedData = dottedPolylineMapObject!!.data
987 println("Dotted polyline custom data: $retrievedData")
988 // [kotlin_MapObject_getData_4]
989 }
990
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
997 }
998 // [kotlin_LocationWindow_removeDottedPolylineMapObject]
999
1000 // Test multiple dotted polyline objects
1001 val dottedPolylines = mutableListOf<DottedPolylineMapObject>()
1002 for (i in 0..2) {
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)
1009 )
1010 val polylineGeometry = LocationPolyline(points)
1011 dottedPolyline.setPolyline(polylineGeometry)
1012 dottedPolylines.add(dottedPolyline)
1013 println("Created dotted polyline $i with ${points.size} points")
1014 }
1015 }
1016
1017 for (i in dottedPolylines.indices) {
1018 locationWindow!!.removeDottedPolylineMapObject(dottedPolylines[i])
1019 println("Removed dotted polyline $i")
1020 }
1021 }
1022
1023 /**
1024 * Demonstrate remove all map objects
1025 */
1026 private fun demonstrateRemoveAllMapObjects() {
1027 println("--- Remove All Map Objects ---")
1028
1029 if (locationWindow == null) {
1030 println("LocationWindow not available yet")
1031 return
1032 }
1033
1034 println("Current map objects count: ${getMapObjectsCount()}")
1035
1036 // [kotlin_LocationWindow_removeAllMapObjects]
1037 // Remove all map objects
1038 locationWindow!!.removeAllMapObjects()
1039 println("Removed all map objects")
1040 // [kotlin_LocationWindow_removeAllMapObjects]
1041
1042 println("Map objects count after removal: ${getMapObjectsCount()}")
1043 }
1044
1045 /**
1046 * Get current map objects count
1047 */
1048 private fun getMapObjectsCount(): Int {
1049 var count = 0
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++
1055 return count
1056 }
1057
1058 /**
1059 * Cleanup resources
1060 */
1061 private fun cleanup() {
1062 println("--- Cleanup ---")
1063
1064 if (locationWindow != null) {
1065 locationWindow!!.removeAllMapObjects()
1066 println("Cleaned up all map objects")
1067 }
1068
1069 circleMapObject = null
1070 iconMapObject = null
1071 polygonMapObject = null
1072 polylineMapObject = null
1073 dottedPolylineMapObject = null
1074 println("Cleared map objects references")
1075 }
1076}
1077
1078// Main function to run the example
1079fun main() {
1080 LocationWindowMapObjectsExample()
1081}