1import kotlinx.coroutines.delay
2import kotlinx.coroutines.runBlocking
4import com.navigine.idl.kotlin.DebugFlag
5import com.navigine.idl.kotlin.LocationWindow
8 * LocationWindowCommon usage example for Kotlin
9 * Demonstrates specific methods: setSublocationId, screenPositionToGlobal, globalToScreenPosition,
10 * selectMapFeature, deselectMapFeature, deselectAllMapFeatures, selectedMapFeatures,
11 * zoomFactor, minZoomFactor, maxZoomFactor
13class LocationWindowCommonExample {
15 private var locationWindow: LocationWindow? = null
16 private var userLocationLayer: UserLocationLayer? = null
17 private var routeLayer: RouteLayer? = null
18 private var routeLayerListener: RouteLayerListener? = null
19 private var routeViewListener: RouteViewListener? = null
22 demonstrateLocationWindowCommonMethods()
26 * Demonstrate LocationWindowCommon methods
28 fun demonstrateLocationWindowCommonMethods() {
29 println("=== LocationWindowCommon Methods ===")
31 demonstrateSetSublocationId()
32 demonstrateOperatingMode()
33 demonstrateSublocationQueries()
34 demonstrateSublocationChangeListener()
35 demonstrateUserLocationLayer()
36 demonstrateRouteLayer()
37 demonstrateCoordinateConversion()
38 demonstrateMapFeatureSelection()
39 demonstrateApplyLayerFilter()
40 demonstrateDebugFlags()
41 demonstrateZoomProperties()
45 * Demonstrate debug overlay flags (static LocationWindow API).
47 fun demonstrateDebugFlags() {
48 println("--- Debug flags ---")
50 // [kotlin_DebugFlag_enum]
51 val allFlags = listOf(
56 DebugFlag.DRAW_ALL_LABELS,
57 DebugFlag.SELECTION_BUFFER
59 println("Debug flag enum values: ${allFlags.size}")
60 // [kotlin_DebugFlag_enum]
62 // [kotlin_LocationWindow_setDebugFlag]
63 LocationWindow.setDebugFlag(DebugFlag.INFOS, true)
64 LocationWindow.setDebugFlag(DebugFlag.STATS, false)
65 println("Updated debug flags on LocationWindow")
66 // [kotlin_LocationWindow_setDebugFlag]
68 // [kotlin_LocationWindow_getDebugFlag]
69 val infosOn = LocationWindow.getDebugFlag(DebugFlag.INFOS)
70 println("Debug flag INFOS enabled: $infosOn")
71 // [kotlin_LocationWindow_getDebugFlag]
76 * Demonstrate operating mode (indoor / outdoor basemap).
78 fun demonstrateOperatingMode() {
79 println("--- Operating Mode ---")
81 if (locationWindow == null) {
82 println("LocationWindow not available yet")
86 // [kotlin_OperatingMode_enum]
88 OperatingMode.INDOOR_ONLY,
89 OperatingMode.OUTDOOR,
90 OperatingMode.OUTDOOR_INDOOR
92 println("Operating modes: ${modes.size}")
93 // [kotlin_OperatingMode_enum]
95 // [kotlin_LocationWindow_setOperatingMode]
96 locationWindow!!.setOperatingMode(OperatingMode.OUTDOOR_INDOOR)
97 println("Set operating mode to OUTDOOR_INDOOR")
98 // [kotlin_LocationWindow_setOperatingMode]
100 // [kotlin_LocationWindow_getOperatingMode]
101 val currentMode = locationWindow!!.operatingMode
102 println("Current operating mode: $currentMode")
103 // [kotlin_LocationWindow_getOperatingMode]
105 // [kotlin_MapTheme_enum]
106 val themes = listOf(MapTheme.LIGHT, MapTheme.DARK)
107 println("Map themes: ${themes.size}")
108 // [kotlin_MapTheme_enum]
110 // [kotlin_LocationWindow_setMapTheme]
111 locationWindow!!.mapTheme = MapTheme.DARK
112 println("Set map theme to DARK")
113 // [kotlin_LocationWindow_setMapTheme]
115 // [kotlin_LocationWindow_getMapTheme]
116 val currentTheme = locationWindow!!.mapTheme
117 println("Current map theme: $currentTheme")
118 // [kotlin_LocationWindow_getMapTheme]
120 // [kotlin_TileKind_enum]
121 val kinds = listOf(TileKind.VECTOR, TileKind.RASTER)
122 println("Tile kinds: ${kinds.size}")
123 // [kotlin_TileKind_enum]
125 // [kotlin_TileSchema_enum]
126 val schemas = listOf(TileSchema.SHORTBREAD, TileSchema.OPEN_MAP_TILES, TileSchema.MAPBOX_STREETS)
127 println("Tile schemas: ${schemas.size}")
128 // [kotlin_TileSchema_enum]
130 // [kotlin_HttpTileSource_record]
131 val http = HttpTileSource(
132 "https://api.maptiler.com/tiles/v3-openmaptiles/{z}/{x}/{y}.pbf",
134 mapOf("key" to "YOUR_MAPTILER_KEY"))
135 // [kotlin_HttpTileSource_record]
137 // [kotlin_MbtilesTileSource_record]
138 val offline = MbtilesTileSource("/path/to/map.mbtiles")
139 // [kotlin_MbtilesTileSource_record]
141 // [kotlin_TileProvider_record]
142 val osmHttp = TileProvider(
143 TileSchema.OPEN_MAP_TILES,
150 val mbtiles = TileProvider(
151 TileSchema.SHORTBREAD,
158 // [kotlin_TileProvider_record]
160 // [kotlin_LocationWindow_setTileProvider]
161 locationWindow!!.tileProvider = osmHttp
162 locationWindow!!.tileProvider = null
163 val imagery = TileProvider(
164 TileSchema.SHORTBREAD,
166 "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
172 "© OpenStreetMap contributors",
174 locationWindow!!.tileProvider = imagery
175 // [kotlin_LocationWindow_setTileProvider]
177 // [kotlin_AttributionAlignment_record]
178 val alignment = AttributionAlignment(
179 AttributionHorizontalAlignment.RIGHT,
180 AttributionVerticalAlignment.BOTTOM)
181 // [kotlin_AttributionAlignment_record]
183 // [kotlin_LocationWindow_setAttributionAlignment]
184 locationWindow!!.attributionAlignment = alignment
185 // [kotlin_LocationWindow_setAttributionAlignment]
187 // [kotlin_LocationWindow_getAttribution]
188 val attribution = locationWindow!!.attribution
189 println("Attribution: $attribution")
190 // [kotlin_LocationWindow_getAttribution]
194 * Demonstrate setSublocationId method
196 fun demonstrateSetSublocationId() {
197 println("--- setSublocationId Method ---")
199 if (locationWindow == null) {
200 println("LocationWindow not available yet")
204 // [kotlin_LocationWindow_setSublocationId]
205 // Set sublocation ID to switch between floors
206 locationWindow!!.setSublocationId(1)
207 println("Set sublocation ID to 1 (first floor)")
208 // [kotlin_LocationWindow_setSublocationId]
210 // [kotlin_LocationWindow_setSublocationId_2]
211 // Set sublocation ID to another floor
212 locationWindow!!.setSublocationId(2)
213 println("Set sublocation ID to 2 (second floor)")
214 // [kotlin_LocationWindow_setSublocationId_2]
216 // [kotlin_LocationWindow_setSublocationId_3]
217 // Set sublocation ID to ground floor
218 locationWindow!!.setSublocationId(0)
219 println("Set sublocation ID to 0 (ground floor)")
220 // [kotlin_LocationWindow_setSublocationId_3]
222 // Test with different sublocation IDs
223 val sublocationIds = listOf(1, 2, 3, 0, 5)
224 for (id in sublocationIds) {
225 locationWindow!!.setSublocationId(id)
226 println("Switched to sublocation ID: $id")
231 * Demonstrate getters for sublocation and enclosing camera
233 fun demonstrateSublocationQueries() {
234 println("--- getSublocationId & getEnclosingCamera ---")
236 if (locationWindow == null) {
237 println("LocationWindow not available yet")
241 // [kotlin_LocationWindow_getSublocationId]
242 val currentId = locationWindow!!.getSublocationId()
243 if (currentId != null) {
244 println("Current sublocation id: $currentId")
246 println("Current sublocation id is not set")
248 // [kotlin_LocationWindow_getSublocationId]
250 // [kotlin_LocationWindow_getEnclosingCamera]
251 val boundingBox = BoundingBox(GlobalPoint(55.75, 37.61), GlobalPoint(55.76, 37.63))
252 val camera = locationWindow!!.getEnclosingCamera(boundingBox)
253 println("Camera that fits bounding box: $camera")
254 // [kotlin_LocationWindow_getEnclosingCamera]
256 // [kotlin_LocationWindow_setFocusRect]
257 val focus = ScreenRect(ScreenPoint(0.0, 0.0), ScreenPoint(1000.0, 1600.0))
258 locationWindow!!.focusRect = focus
259 // [kotlin_LocationWindow_setFocusRect]
261 // [kotlin_LocationWindow_getEnclosingCameraWithFocus]
262 val padded = locationWindow!!.getEnclosingCameraWithFocus(boundingBox, focus, null, null)
263 println("Camera that fits bounding box in focus rect: $padded")
264 // [kotlin_LocationWindow_getEnclosingCameraWithFocus]
268 * Demonstrate sublocation change listener usage
270 fun demonstrateSublocationChangeListener() {
271 println("--- Sublocation Change Listener ---")
273 if (locationWindow == null) {
274 println("LocationWindow not available yet")
278 val listener = DemoSublocationChangeListener()
280 // [kotlin_LocationWindow_addSublocationChangeListener]
281 locationWindow!!.addSublocationChangeListener(listener)
282 println("Added sublocation change listener")
283 // [kotlin_LocationWindow_addSublocationChangeListener]
285 locationWindow!!.setSublocationId(1)
286 locationWindow!!.setSublocationId(2)
288 // [kotlin_LocationWindow_removeSublocationChangeListener]
289 locationWindow!!.removeSublocationChangeListener(listener)
290 println("Removed sublocation change listener")
291 // [kotlin_LocationWindow_removeSublocationChangeListener]
295 * Demonstrate user location layer controls
297 fun demonstrateUserLocationLayer() {
298 println("--- UserLocationLayer ---")
300 if (userLocationLayer == null) {
301 println("UserLocationLayer not available yet")
305 // [kotlin_UserLocationLayer_setVisible]
306 userLocationLayer!!.setVisible(true)
307 println("User location layer set visible")
308 // [kotlin_UserLocationLayer_setVisible]
310 // [kotlin_UserLocationLayer_isVisible]
311 val visible = userLocationLayer!!.isVisible
312 println("User location layer is visible: $visible")
313 // [kotlin_UserLocationLayer_isVisible]
315 // [kotlin_UserLocationLayer_setAnchor]
316 val anchor = ScreenPoint(100.0f, 200.0f)
317 userLocationLayer!!.setAnchor(anchor)
318 println("Set user location anchor to: (${anchor.x}, ${anchor.y})")
319 // [kotlin_UserLocationLayer_setAnchor]
321 // [kotlin_UserLocationLayer_anchorEnabled]
322 val anchorEnabled = userLocationLayer!!.anchorEnabled
323 println("Anchor enabled: $anchorEnabled")
324 // [kotlin_UserLocationLayer_anchorEnabled]
326 // [kotlin_UserLocationLayer_setHeadingModeActive]
327 userLocationLayer!!.setHeadingModeActive(true)
328 println("Heading-up mode enabled")
329 // [kotlin_UserLocationLayer_setHeadingModeActive]
331 // [kotlin_UserLocationLayer_headingModeActive]
332 val headingModeActive = userLocationLayer!!.headingModeActive
333 println("Heading-up mode active: $headingModeActive")
334 // [kotlin_UserLocationLayer_headingModeActive]
336 // [kotlin_UserLocationLayer_setFollowMode]
337 userLocationLayer!!.setFollowMode(UserLocationFollowMode.HEADING)
338 println("Follow mode set to heading")
339 // [kotlin_UserLocationLayer_setFollowMode]
341 // [kotlin_UserLocationLayer_followMode]
342 val followMode = userLocationLayer!!.followMode
343 println("Follow mode: $followMode")
344 // [kotlin_UserLocationLayer_followMode]
346 // [kotlin_UserLocationLayer_setArrowBitmap]
347 userLocationLayer!!.setArrowBitmap(ImageProvider.fromFile("/path/to/arrow.png", true))
348 userLocationLayer!!.setArrowBitmap(null)
349 println("Custom arrow bitmap cleared")
350 // [kotlin_UserLocationLayer_setArrowBitmap]
352 // [kotlin_UserLocationLayer_setAccuracyColor]
353 userLocationLayer!!.setAccuracyColor(0x4230AAD9)
354 println("Accuracy circle color updated")
355 // [kotlin_UserLocationLayer_setAccuracyColor]
357 // [kotlin_UserLocationLayer_resetAnchor]
358 userLocationLayer!!.resetAnchor()
359 println("Anchor reset to default")
360 // [kotlin_UserLocationLayer_resetAnchor]
364 * Demonstrate route layer controls
366 fun demonstrateRouteLayer() {
367 println("--- RouteLayer ---")
369 if (routeLayer == null) {
370 println("RouteLayer not available yet")
374 // [kotlin_RouteLayer_setVisible]
375 routeLayer!!.setVisible(true)
376 println("Route layer set visible")
377 // [kotlin_RouteLayer_setVisible]
379 // [kotlin_RouteLayer_isVisible]
380 val visible = routeLayer!!.isVisible
381 println("Route layer is visible: $visible")
382 // [kotlin_RouteLayer_isVisible]
384 // [kotlin_RouteLayer_setTraveledColor]
385 routeLayer!!.setTraveledColor(0xB4787878.toInt())
386 println("Traveled color updated")
387 // [kotlin_RouteLayer_setTraveledColor]
389 // [kotlin_RouteLayer_setRemainingColor]
390 routeLayer!!.setRemainingColor(0xFF30AAD9.toInt())
391 println("Remaining color updated")
392 // [kotlin_RouteLayer_setRemainingColor]
394 // [kotlin_RouteLayer_setWidth]
395 routeLayer!!.setWidth(8.0f)
396 println("Route width updated")
397 // [kotlin_RouteLayer_setWidth]
399 // [kotlin_RouteLayer_setRemainingStyle]
400 routeLayer!!.setRemainingStyle(RouteRemainingStyle.DOTTED)
401 println("Remaining style set to DOTTED")
402 // [kotlin_RouteLayer_setRemainingStyle]
404 // [kotlin_RouteLayer_remainingStyle]
405 val remainingStyle = routeLayer!!.remainingStyle
406 println("Remaining style: $remainingStyle")
407 // [kotlin_RouteLayer_remainingStyle]
409 // [kotlin_RouteLayer_setRemainingPointSize]
410 routeLayer!!.setRemainingPointSize(8.0f, 8.0f)
411 println("Remaining point size updated")
412 // [kotlin_RouteLayer_setRemainingPointSize]
414 // [kotlin_RouteLayer_setRemainingPlacement]
415 routeLayer!!.setRemainingPlacement(Placement.SPACED)
416 println("Remaining placement updated")
417 // [kotlin_RouteLayer_setRemainingPlacement]
419 // [kotlin_RouteLayer_setRemainingPlacementSpacing]
420 routeLayer!!.setRemainingPlacementSpacing(8.0f)
421 println("Remaining placement spacing updated")
422 // [kotlin_RouteLayer_setRemainingPlacementSpacing]
424 // [kotlin_RouteLayer_setRemainingPlacementMinRatio]
425 routeLayer!!.setRemainingPlacementMinRatio(0.0f)
426 println("Remaining placement min ratio updated")
427 // [kotlin_RouteLayer_setRemainingPlacementMinRatio]
429 // [kotlin_RouteLayer_setRemainingCollisionEnabled]
430 routeLayer!!.setRemainingCollisionEnabled(false)
431 println("Remaining collision disabled")
432 // [kotlin_RouteLayer_setRemainingCollisionEnabled]
434 // [kotlin_RouteLayer_setRemainingDashLength]
435 routeLayer!!.setRemainingDashLength(0.5f)
436 println("Remaining dash length updated")
437 // [kotlin_RouteLayer_setRemainingDashLength]
439 // [kotlin_RouteLayer_setRemainingGapLength]
440 routeLayer!!.setRemainingGapLength(0.4f)
441 println("Remaining gap length updated")
442 // [kotlin_RouteLayer_setRemainingGapLength]
444 val from = RouteEndpoint(
445 GlobalPoint(55.751244, 37.618423),
446 1) // null for outdoor point
447 val to = RouteEndpoint(
448 GlobalPoint(55.751700, 37.619000),
449 2) // null for outdoor point
451 // [kotlin_RouteLayer_setRoute]
452 routeLayer!!.setRoute(from, to)
453 println("Static route applied")
454 // [kotlin_RouteLayer_setRoute]
456 // [kotlin_RouteLayer_setTarget]
457 routeLayer!!.setTarget(to)
458 println("Guidance target applied")
459 // [kotlin_RouteLayer_setTarget]
461 // [kotlin_RouteLayer_routes]
462 val routes = routeLayer!!.routes()
463 println("Visible routes: ${routes.size}")
464 // [kotlin_RouteLayer_routes]
466 // [kotlin_RouteLayer_selectedRoute]
467 val selectedRoute = routeLayer!!.selectedRoute()
468 if (selectedRoute != null) {
469 println("Selected route length: ${selectedRoute.length()}")
471 // [kotlin_RouteLayer_selectedRoute]
473 // [kotlin_RouteLayer_selectRoute]
474 routes.firstOrNull()?.let { routeLayer!!.selectRoute(it) }
475 // [kotlin_RouteLayer_selectRoute]
477 // [kotlin_RouteLayer_addRouteLayerListener]
478 routeLayerListener = object : RouteLayerListener {
479 override fun onRouteChanged(status: RouteLayerStatus, route: RouteView?) {
480 println("Route status: $status")
483 override fun onRouteAdvanced(progress: RouteProgress) {
484 println("Remaining distance: ${progress.remainingDistance}, time: ${progress.remainingTime}s")
487 override fun onRouteTargetReached() {
488 println("Route target reached")
491 routeLayer!!.addRouteLayerListener(routeLayerListener!!)
492 // [kotlin_RouteLayer_addRouteLayerListener]
494 // [kotlin_RouteLayer_addRouteViewListener]
495 routeViewListener = object : RouteViewListener {
496 override fun onRouteViewsChanged() {
497 println("Route views changed")
500 override fun onSelectedRouteChanged(route: RouteView?) {
501 println("Selected route changed")
504 override fun onRouteViewTap(route: RouteView) {
505 routeLayer!!.selectRoute(route)
508 routeLayer!!.addRouteViewListener(routeViewListener!!)
509 // [kotlin_RouteLayer_addRouteViewListener]
511 // [kotlin_RouteLayer_clear]
513 println("Route layer cleared")
514 // [kotlin_RouteLayer_clear]
518 * Demonstrate coordinate conversion methods
520 fun demonstrateCoordinateConversion() {
521 println("--- Coordinate Conversion Methods ---")
523 if (locationWindow == null) {
524 println("LocationWindow not available yet")
528 // [kotlin_LocationWindow_screenPositionToGlobal]
529 val screenPoint = ScreenPoint(100.0, 200.0)
530 val globalPoint = locationWindow!!.screenPositionToGlobal(screenPoint)
531 println("Screen position (${screenPoint.x}, ${screenPoint.y}) converted to WGS84: (${globalPoint.latitude}, ${globalPoint.longitude})")
532 // [kotlin_LocationWindow_screenPositionToGlobal]
534 // [kotlin_LocationWindow_getVisibleRegion]
535 val visibleRegion = locationWindow!!.visibleRegion
536 println("Viewport top-left: ${visibleRegion.topLeft}")
537 // [kotlin_LocationWindow_getVisibleRegion]
539 // [kotlin_LocationWindow_getFocusRegion]
540 val focusRegion = locationWindow!!.focusRegion
541 println("Focus-rect top-left: ${focusRegion.topLeft}")
542 // [kotlin_LocationWindow_getFocusRegion]
544 // [kotlin_LocationWindow_globalToScreenPosition]
545 val globalPoint2 = GlobalPoint(55.7558, 37.6176)
546 val screenPoint2 = locationWindow!!.globalToScreenPosition(globalPoint2, true)
547 println("WGS84 (${globalPoint2.latitude}, ${globalPoint2.longitude}) converted to screen with clipping: (${screenPoint2.x}, ${screenPoint2.y})")
548 // [kotlin_LocationWindow_globalToScreenPosition]
550 // Test coordinate conversion with different values
551 val testScreenPoints = listOf(
552 ScreenPoint(0.0, 0.0),
553 ScreenPoint(250.0, 250.0),
554 ScreenPoint(1000.0, 600.0)
557 for ((index, screenPoint) in testScreenPoints.withIndex()) {
558 val global = locationWindow!!.screenPositionToGlobal(screenPoint)
559 val backToScreen = locationWindow!!.globalToScreenPosition(global, false)
560 println("Test $index: Screen (${screenPoint.x}, ${screenPoint.y}) -> WGS84 (${global.latitude}, ${global.longitude}) -> Screen (${backToScreen.x}, ${backToScreen.y})")
565 * Demonstrate map feature selection methods
567 fun demonstrateMapFeatureSelection() {
568 println("--- Map Feature Selection Methods ---")
570 if (locationWindow == null) {
571 println("LocationWindow not available yet")
575 // [kotlin_LocationWindow_selectMapFeature]
576 // Select map feature by ID
577 val featureId = "room_101"
578 val selected = locationWindow!!.selectMapFeature(featureId)
579 println("Selected map feature $featureId: $selected")
580 // [kotlin_LocationWindow_selectMapFeature]
582 // [kotlin_LocationWindow_selectMapFeature_2]
583 // Select another map feature
584 val featureId2 = "office_205"
585 val selected2 = locationWindow!!.selectMapFeature(featureId2)
586 println("Selected map feature $featureId2: $selected2")
587 // [kotlin_LocationWindow_selectMapFeature_2]
589 // [kotlin_LocationWindow_getSelectedMapFeatures]
590 // Get list of selected map features
591 val selectedFeatures = locationWindow!!.selectedMapFeatures
592 println("Currently selected map features: ${selectedFeatures.size} features")
593 for (feature in selectedFeatures) {
594 println(" - $feature")
596 // [kotlin_LocationWindow_getSelectedMapFeatures]
598 // [kotlin_LocationWindow_deselectMapFeature]
599 // Deselect specific map feature
600 val deselected = locationWindow!!.deselectMapFeature(featureId)
601 println("Deselected map feature $featureId: $deselected")
602 // [kotlin_LocationWindow_deselectMapFeature]
604 // [kotlin_LocationWindow_deselectMapFeature_2]
605 // Deselect another map feature
606 val deselected2 = locationWindow!!.deselectMapFeature(featureId2)
607 println("Deselected map feature $featureId2: $deselected2")
608 // [kotlin_LocationWindow_deselectMapFeature_2]
610 // [kotlin_LocationWindow_deselectAllMapFeatures]
611 // Deselect all map features
612 locationWindow!!.deselectAllMapFeatures()
613 println("Deselected all map features")
614 // [kotlin_LocationWindow_deselectAllMapFeatures]
616 // [kotlin_LocationWindow_getSelectedMapFeatures_2]
617 // Verify all features are deselected
618 val remainingFeatures = locationWindow!!.selectedMapFeatures
619 println("Remaining selected features after deselect all: ${remainingFeatures.size} features")
620 // [kotlin_LocationWindow_getSelectedMapFeatures_2]
622 // Test multiple feature selection and deselection
623 val testFeatureIds = listOf("room_101", "office_205", "meeting_room_301", "cafe_401")
625 // Select multiple features
626 for (featureId in testFeatureIds) {
627 val success = locationWindow!!.selectMapFeature(featureId)
628 println("Selected feature $featureId: $success")
631 // Check selected features
632 val allSelected = locationWindow!!.selectedMapFeatures
633 println("All selected features: ${allSelected.size} features")
635 // Deselect all at once
636 locationWindow!!.deselectAllMapFeatures()
637 println("Deselected all features at once")
641 * Demonstrate applyLayerFilter method
643 fun demonstrateApplyLayerFilter() {
644 println("--- applyLayerFilter Method ---")
646 if (locationWindow == null) {
647 println("LocationWindow not available yet")
651 // [kotlin_MapFilterCondition_constructor]
652 // Create filter condition: show only venues with category "Toilet" or "Cafe"
653 val condition = MapFilterCondition("category", listOf("Toilet", "Cafe"))
654 // [kotlin_MapFilterCondition_constructor]
656 // [kotlin_LocationWindow_applyLayerFilter]
657 // Apply filter to venues layer
658 val conditions = listOf(MapFilterCondition("category", listOf("Toilet", "Cafe")))
659 locationWindow!!.applyLayerFilter("venues", conditions)
660 println("Applied layer filter: show venues with category Toilet or Cafe")
661 // [kotlin_LocationWindow_applyLayerFilter]
663 // Reset filter (show all venues)
664 locationWindow!!.applyLayerFilter("venues", emptyList())
665 println("Reset layer filter: show all venues")
669 * Demonstrate zoom properties
671 fun demonstrateZoomProperties() {
672 println("--- Zoom Properties ---")
674 if (locationWindow == null) {
675 println("LocationWindow not available yet")
679 // [kotlin_LocationWindow_getZoomFactor]
680 // Get current zoom factor
681 val currentZoom = locationWindow!!.zoomFactor
682 println("Current zoom factor: $currentZoom")
683 // [kotlin_LocationWindow_getZoomFactor]
685 // [kotlin_LocationWindow_setZoomFactor]
687 locationWindow!!.zoomFactor = 150.0
688 println("Set zoom factor to 150.0")
689 // [kotlin_LocationWindow_setZoomFactor]
691 // [kotlin_LocationWindow_getMinZoomFactor]
692 // Get minimum zoom factor
693 val minZoomFactor = locationWindow!!.minZoomFactor
694 println("Minimum zoom factor: $minZoomFactor")
695 // [kotlin_LocationWindow_getMinZoomFactor]
697 // [kotlin_LocationWindow_setMinZoomFactor]
698 // Set minimum zoom factor
699 locationWindow!!.minZoomFactor = 50.0
700 println("Set minimum zoom factor to 50.0")
701 // [kotlin_LocationWindow_setMinZoomFactor]
703 // [kotlin_LocationWindow_getMaxZoomFactor]
704 // Get maximum zoom factor
705 val maxZoomFactor = locationWindow!!.maxZoomFactor
706 println("Maximum zoom factor: $maxZoomFactor")
707 // [kotlin_LocationWindow_getMaxZoomFactor]
709 // [kotlin_LocationWindow_setMaxZoomFactor]
710 // Set maximum zoom factor
711 locationWindow!!.maxZoomFactor = 300.0
712 println("Set maximum zoom factor to 300.0")
713 // [kotlin_LocationWindow_setMaxZoomFactor]
715 // Test zoom factor changes
716 val testZoomFactors = listOf(100.0, 125.0, 150.0, 200.0, 250.0)
717 for (zoom in testZoomFactors) {
718 locationWindow!!.zoomFactor = zoom
719 println("Changed zoom factor to: ${locationWindow!!.zoomFactor}")
723 println("Testing zoom limits...")
724 locationWindow!!.zoomFactor = locationWindow!!.minZoomFactor
725 println("Set to minimum zoom: ${locationWindow!!.zoomFactor}")
727 locationWindow!!.zoomFactor = locationWindow!!.maxZoomFactor
728 println("Set to maximum zoom: ${locationWindow!!.zoomFactor}")
731 locationWindow!!.zoomFactor = 100.0
732 println("Reset zoom factor to default: ${locationWindow!!.zoomFactor}")
736 * Main demonstration method
738 suspend fun runExample() {
739 println("=== LocationWindowCommon Example ===")
741 // Simulate LocationWindow initialization
744 // TODO: User will implement LocationWindow initialization here
745 // locationWindow = getLocationWindow()
747 // Run demonstrations
748 demonstrateLocationWindowCommonMethods()
750 println("=== Example completed ===")
755 * Function to run the example
757fun main() = runBlocking {
758 val example = LocationWindowCommonExample()
762class DemoSublocationChangeListener : SublocationChangeListener {
763 // [kotlin_SublocationChangeListener_onActiveSublocationChanged]
764 override fun onActiveSublocationChanged(sublocationId: Int) {
765 println("Active sublocation changed to: $sublocationId")
767 // [kotlin_SublocationChangeListener_onActiveSublocationChanged]