5class DemoRouteLayerListener: NSObject, RouteLayerListener {
6 func onRouteChanged(_ status: RouteLayerStatus, route: RouteView?) {
7 print("Route status: \(status)")
10 func onRouteAdvanced(_ progress: RouteProgress) {
11 print("Remaining distance: \(progress.remainingDistance), time: \(progress.remainingTime)s")
14 func onRouteTargetReached() {
15 print("Route target reached")
19class DemoRouteViewListener: NSObject, RouteViewListener {
20 private weak var routeLayer: RouteLayer?
22 init(routeLayer: RouteLayer) {
23 self.routeLayer = routeLayer
26 func onRouteViewsChanged() {
27 print("Route views changed")
30 func onSelectedRouteChanged(_ route: RouteView?) {
31 print("Selected route changed")
34 func onRouteViewTap(_ route: RouteView) {
35 routeLayer?.selectRoute(route)
40 * LocationWindowCommon usage example for Swift
41 * Demonstrates specific methods: setSublocationId, screenPositionToGlobal, globalToScreenPosition,
42 * selectMapFeature, deselectMapFeature, deselectAllMapFeatures, selectedMapFeatures,
43 * zoomFactor, minZoomFactor, maxZoomFactor
45class LocationWindowCommonExample {
47 private var locationWindow: LocationWindow?
48 private var userLocationLayer: UserLocationLayer?
49 private var routeLayer: RouteLayer?
50 private var routeLayerListener: RouteLayerListener?
51 private var routeViewListener: RouteViewListener?
54 demonstrateLocationWindowCommonMethods()
58 * Demonstrate LocationWindowCommon methods
60 func demonstrateLocationWindowCommonMethods() {
61 print("=== LocationWindowCommon Methods ===")
63 demonstrateSetSublocationId()
64 demonstrateOperatingMode()
65 demonstrateSublocationQueries()
66 demonstrateSublocationChangeListener()
67 demonstrateUserLocationLayer()
68 demonstrateRouteLayer()
69 demonstrateCoordinateConversion()
70 demonstrateMapFeatureSelection()
71 demonstrateApplyLayerFilter()
72 demonstrateDebugFlags()
73 demonstrateZoomProperties()
77 * Demonstrate debug overlay flags (static NCLocationWindow API).
79 func demonstrateDebugFlags() {
80 print("--- Debug flags ---")
82 // [swift_DebugFlag_enum]
83 let allFlags: [NCDebugFlag] = [.none, .infos, .stats, .labels, .drawAllLabels, .selectionBuffer]
84 print("Debug flag enum values: \(allFlags.count)")
85 // [swift_DebugFlag_enum]
87 // [swift_LocationWindow_setDebugFlag]
88 NCLocationWindow.setDebugFlag(.infos, on: true)
89 NCLocationWindow.setDebugFlag(.stats, on: false)
90 print("Updated debug flags on LocationWindow")
91 // [swift_LocationWindow_setDebugFlag]
93 // [swift_LocationWindow_getDebugFlag]
94 let infosOn = NCLocationWindow.getDebugFlag(.infos)
95 print("Debug flag INFOS enabled: \(infosOn)")
96 // [swift_LocationWindow_getDebugFlag]
101 * Demonstrate operating mode (indoor / outdoor basemap).
103 func demonstrateOperatingMode() {
104 print("--- Operating Mode ---")
106 guard let locationWindow = locationWindow else {
107 print("LocationWindow not available yet")
111 // [swift_OperatingMode_enum]
112 let modes: [NCOperatingMode] = [.indoorOnly, .outdoor, .outdoorIndoor]
113 print("Operating modes: \(modes.count)")
114 // [swift_OperatingMode_enum]
116 // [swift_LocationWindow_setOperatingMode]
117 locationWindow.setOperatingMode(.outdoorIndoor)
118 print("Set operating mode to outdoorIndoor")
119 // [swift_LocationWindow_setOperatingMode]
121 // [swift_LocationWindow_getOperatingMode]
122 let currentMode = locationWindow.getOperatingMode()
123 print("Current operating mode: \(currentMode)")
124 // [swift_LocationWindow_getOperatingMode]
126 // [swift_MapTheme_enum]
127 let themes: [NCMapTheme] = [.light, .dark]
128 print("Map themes: \(themes.count)")
129 // [swift_MapTheme_enum]
131 // [swift_LocationWindow_setMapTheme]
132 locationWindow.setMapTheme(.dark)
133 print("Set map theme to dark")
134 // [swift_LocationWindow_setMapTheme]
136 // [swift_LocationWindow_getMapTheme]
137 let currentTheme = locationWindow.getMapTheme()
138 print("Current map theme: \(currentTheme)")
139 // [swift_LocationWindow_getMapTheme]
141 // [swift_TileKind_enum]
142 let kinds: [NCTileKind] = [.vector, .raster]
143 print("Tile kinds: \(kinds.count)")
144 // [swift_TileKind_enum]
146 // [swift_TileSchema_enum]
147 let schemas: [NCTileSchema] = [.shortbread, .openMapTiles, .mapboxStreets]
148 print("Tile schemas: \(schemas.count)")
149 // [swift_TileSchema_enum]
151 // [swift_HttpTileSource_record]
152 let http = NCHttpTileSource(
153 urlTemplate: "https://api.maptiler.com/tiles/v3-openmaptiles/{z}/{x}/{y}.pbf",
155 queryParameters: ["key": "YOUR_MAPTILER_KEY"])
156 // [swift_HttpTileSource_record]
158 // [swift_MbtilesTileSource_record]
159 let offline = NCMbtilesTileSource(path: "/path/to/map.mbtiles")
160 // [swift_MbtilesTileSource_record]
162 // [swift_TileProvider_record]
163 let osmHttp = NCTileProvider(
164 schema: .openMapTiles,
171 let mbtiles = NCTileProvider(
179 // [swift_TileProvider_record]
181 // [swift_LocationWindow_setTileProvider]
182 locationWindow.setTileProvider(osmHttp)
183 locationWindow.setTileProvider(nil)
184 let imageryHttp = NCHttpTileSource(
185 urlTemplate: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
187 queryParameters: nil)
188 let imagery = NCTileProvider(
194 attribution: "© OpenStreetMap contributors",
196 locationWindow.setTileProvider(imagery)
197 // [swift_LocationWindow_setTileProvider]
199 // [swift_AttributionAlignment_record]
200 let alignment = NCAttributionAlignment(
201 horizontalAlignment: .right,
202 verticalAlignment: .bottom)
203 // [swift_AttributionAlignment_record]
205 // [swift_LocationWindow_setAttributionAlignment]
206 locationWindow.setAttributionAlignment(alignment)
207 // [swift_LocationWindow_setAttributionAlignment]
209 // [swift_LocationWindow_getAttribution]
210 let attribution = locationWindow.getAttribution()
211 print("Attribution: \(attribution)")
212 // [swift_LocationWindow_getAttribution]
216 * Demonstrate setSublocationId method
218 func demonstrateSetSublocationId() {
219 print("--- setSublocationId Method ---")
221 guard let locationWindow = locationWindow else {
222 print("LocationWindow not available yet")
226 // [swift_LocationWindow_setSublocationId]
227 // Set sublocation ID to switch between floors
228 locationWindow.setSublocationId(1)
229 print("Set sublocation ID to 1 (first floor)")
230 // [swift_LocationWindow_setSublocationId]
232 // [swift_LocationWindow_setSublocationId_2]
233 // Set sublocation ID to another floor
234 locationWindow.setSublocationId(2)
235 print("Set sublocation ID to 2 (second floor)")
236 // [swift_LocationWindow_setSublocationId_2]
238 // [swift_LocationWindow_setSublocationId_3]
239 // Set sublocation ID to ground floor
240 locationWindow.setSublocationId(0)
241 print("Set sublocation ID to 0 (ground floor)")
242 // [swift_LocationWindow_setSublocationId_3]
244 // Test with different sublocation IDs
245 let sublocationIds = [1, 2, 3, 0, 5]
246 for id in sublocationIds {
247 locationWindow.setSublocationId(id)
248 print("Switched to sublocation ID: \(id)")
253 * Demonstrate getters for sublocation and enclosing camera
255 func demonstrateSublocationQueries() {
256 print("--- getSublocationId & getEnclosingCamera ---")
258 guard let locationWindow = locationWindow else {
259 print("LocationWindow not available yet")
263 // [swift_LocationWindow_getSublocationId]
264 if let currentId = locationWindow.getSublocationId() {
265 print("Current sublocation id: \(currentId)")
267 print("Current sublocation id is not set")
269 // [swift_LocationWindow_getSublocationId]
271 // [swift_LocationWindow_getEnclosingCamera]
272 let boundingBox = BoundingBox(
273 bottomLeft: GlobalPoint(latitude: 55.75, longitude: 37.61),
274 topRight: GlobalPoint(latitude: 55.76, longitude: 37.63))
275 let camera = locationWindow.getEnclosingCamera(boundingBox)
276 print("Camera that fits bounding box: \(camera)")
277 // [swift_LocationWindow_getEnclosingCamera]
279 // [swift_LocationWindow_setFocusRect]
280 let focus = ScreenRect(
281 topLeft: ScreenPoint(x: 0, y: 0),
282 bottomRight: ScreenPoint(x: 1000, y: 1600))
283 locationWindow.setFocusRect(focus)
284 // [swift_LocationWindow_setFocusRect]
286 // [swift_LocationWindow_getEnclosingCameraWithFocus]
287 let padded = locationWindow.getEnclosingCameraWithFocus(
288 boundingBox, focusRect: focus, azimuth: nil, tilt: nil)
289 print("Camera that fits bounding box in focus rect: \(padded)")
290 // [swift_LocationWindow_getEnclosingCameraWithFocus]
294 * Demonstrate sublocation change listener usage
296 func demonstrateSublocationChangeListener() {
297 print("--- Sublocation Change Listener ---")
299 guard let locationWindow = locationWindow else {
300 print("LocationWindow not available yet")
304 let listener = DemoSublocationChangeListener()
306 // [swift_LocationWindow_addSublocationChangeListener]
307 locationWindow.addSublocationChangeListener(listener)
308 print("Added sublocation change listener")
309 // [swift_LocationWindow_addSublocationChangeListener]
311 locationWindow.setSublocationId(1)
312 locationWindow.setSublocationId(2)
314 // [swift_LocationWindow_removeSublocationChangeListener]
315 locationWindow.removeSublocationChangeListener(listener)
316 print("Removed sublocation change listener")
317 // [swift_LocationWindow_removeSublocationChangeListener]
321 * Demonstrate user location layer controls
323 func demonstrateUserLocationLayer() {
324 print("--- UserLocationLayer ---")
326 guard let userLocationLayer = userLocationLayer else {
327 print("UserLocationLayer not available yet")
331 // [swift_UserLocationLayer_setVisible]
332 userLocationLayer.setVisible(true)
333 print("User location layer set visible")
334 // [swift_UserLocationLayer_setVisible]
336 // [swift_UserLocationLayer_isVisible]
337 let visible = userLocationLayer.isVisible()
338 print("User location layer is visible: \(visible)")
339 // [swift_UserLocationLayer_isVisible]
341 // [swift_UserLocationLayer_setAnchor]
342 let anchor = ScreenPoint(x: 100.0, y: 200.0)
343 userLocationLayer.setAnchor(anchor)
344 print("Set user location anchor to: (\(anchor.x), \(anchor.y))")
345 // [swift_UserLocationLayer_setAnchor]
347 // [swift_UserLocationLayer_anchorEnabled]
348 let anchorEnabled = userLocationLayer.anchorEnabled()
349 print("Anchor enabled: \(anchorEnabled)")
350 // [swift_UserLocationLayer_anchorEnabled]
352 // [swift_UserLocationLayer_setHeadingModeActive]
353 userLocationLayer.setHeadingModeActive(true)
354 print("Heading-up mode enabled")
355 // [swift_UserLocationLayer_setHeadingModeActive]
357 // [swift_UserLocationLayer_headingModeActive]
358 let headingModeActive = userLocationLayer.headingModeActive()
359 print("Heading-up mode active: \(headingModeActive)")
360 // [swift_UserLocationLayer_headingModeActive]
362 // [swift_UserLocationLayer_setFollowMode]
363 userLocationLayer.setFollowMode(.HEADING)
364 print("Follow mode set to heading")
365 // [swift_UserLocationLayer_setFollowMode]
367 // [swift_UserLocationLayer_followMode]
368 let followMode = userLocationLayer.followMode()
369 print("Follow mode: \(followMode)")
370 // [swift_UserLocationLayer_followMode]
372 // [swift_UserLocationLayer_setArrowBitmap]
373 if let arrow = UIImage(contentsOfFile: "/path/to/arrow.png") {
374 userLocationLayer.setArrowBitmap(arrow)
376 userLocationLayer.setArrowBitmap(nil)
377 print("Custom arrow bitmap cleared")
378 // [swift_UserLocationLayer_setArrowBitmap]
380 // [swift_UserLocationLayer_setAccuracyColor]
381 userLocationLayer.setAccuracyColor(UIColor(red: 0.19, green: 0.67, blue: 0.85, alpha: 0.26))
382 print("Accuracy circle color updated")
383 // [swift_UserLocationLayer_setAccuracyColor]
385 // [swift_UserLocationLayer_resetAnchor]
386 userLocationLayer.resetAnchor()
387 print("Anchor reset to default")
388 // [swift_UserLocationLayer_resetAnchor]
392 * Demonstrate route layer controls
394 func demonstrateRouteLayer() {
395 print("--- RouteLayer ---")
397 guard let routeLayer = routeLayer else {
398 print("RouteLayer not available yet")
402 // [swift_RouteLayer_setVisible]
403 routeLayer.setVisible(true)
404 print("Route layer set visible")
405 // [swift_RouteLayer_setVisible]
407 // [swift_RouteLayer_isVisible]
408 let visible = routeLayer.isVisible()
409 print("Route layer is visible: \(visible)")
410 // [swift_RouteLayer_isVisible]
412 // [swift_RouteLayer_setTraveledColor]
413 routeLayer.setTraveledColor(UIColor(red: 0.47, green: 0.47, blue: 0.47, alpha: 0.7))
414 print("Traveled color updated")
415 // [swift_RouteLayer_setTraveledColor]
417 // [swift_RouteLayer_setRemainingColor]
418 routeLayer.setRemainingColor(UIColor(red: 0.19, green: 0.67, blue: 0.85, alpha: 1.0))
419 print("Remaining color updated")
420 // [swift_RouteLayer_setRemainingColor]
422 // [swift_RouteLayer_setWidth]
423 routeLayer.setWidth(8.0)
424 print("Route width updated")
425 // [swift_RouteLayer_setWidth]
427 // [swift_RouteLayer_setRemainingStyle]
428 routeLayer.setRemainingStyle(.DOTTED)
429 print("Remaining style set to DOTTED")
430 // [swift_RouteLayer_setRemainingStyle]
432 // [swift_RouteLayer_remainingStyle]
433 let remainingStyle = routeLayer.remainingStyle()
434 print("Remaining style: \(remainingStyle)")
435 // [swift_RouteLayer_remainingStyle]
437 // [swift_RouteLayer_setRemainingPointSize]
438 routeLayer.setRemainingPointSize(8.0, height: 8.0)
439 print("Remaining point size updated")
440 // [swift_RouteLayer_setRemainingPointSize]
442 // [swift_RouteLayer_setRemainingPlacement]
443 routeLayer.setRemainingPlacement(.SPACED)
444 print("Remaining placement updated")
445 // [swift_RouteLayer_setRemainingPlacement]
447 // [swift_RouteLayer_setRemainingPlacementSpacing]
448 routeLayer.setRemainingPlacementSpacing(8.0)
449 print("Remaining placement spacing updated")
450 // [swift_RouteLayer_setRemainingPlacementSpacing]
452 // [swift_RouteLayer_setRemainingPlacementMinRatio]
453 routeLayer.setRemainingPlacementMinRatio(0.0)
454 print("Remaining placement min ratio updated")
455 // [swift_RouteLayer_setRemainingPlacementMinRatio]
457 // [swift_RouteLayer_setRemainingCollisionEnabled]
458 routeLayer.setRemainingCollisionEnabled(false)
459 print("Remaining collision disabled")
460 // [swift_RouteLayer_setRemainingCollisionEnabled]
462 // [swift_RouteLayer_setRemainingDashLength]
463 routeLayer.setRemainingDashLength(0.5)
464 print("Remaining dash length updated")
465 // [swift_RouteLayer_setRemainingDashLength]
467 // [swift_RouteLayer_setRemainingGapLength]
468 routeLayer.setRemainingGapLength(0.4)
469 print("Remaining gap length updated")
470 // [swift_RouteLayer_setRemainingGapLength]
472 let from = RouteEndpoint(
473 point: GlobalPoint(latitude: 55.751244, longitude: 37.618423),
474 sublocationId: NSNumber(value: 1)) // nil for outdoor point
475 let to = RouteEndpoint(
476 point: GlobalPoint(latitude: 55.751700, longitude: 37.619000),
477 sublocationId: NSNumber(value: 2)) // nil for outdoor point
479 // [swift_RouteLayer_setRoute]
480 routeLayer.setRoute(from, to: to)
481 print("Static route applied")
482 // [swift_RouteLayer_setRoute]
484 // [swift_RouteLayer_setTarget]
485 routeLayer.setTarget(to)
486 print("Guidance target applied")
487 // [swift_RouteLayer_setTarget]
489 // [swift_RouteLayer_routes]
490 let routes = routeLayer.routes()
491 print("Visible routes: \(routes.count)")
492 // [swift_RouteLayer_routes]
494 // [swift_RouteLayer_selectedRoute]
495 if let selectedRoute = routeLayer.selectedRoute() {
496 print("Selected route length: \(selectedRoute.length())")
498 // [swift_RouteLayer_selectedRoute]
500 // [swift_RouteLayer_selectRoute]
501 if let firstRoute = routes.first {
502 routeLayer.selectRoute(firstRoute)
504 // [swift_RouteLayer_selectRoute]
506 // [swift_RouteLayer_addRouteLayerListener]
507 routeLayerListener = DemoRouteLayerListener()
508 routeLayer.addRouteLayerListener(routeLayerListener)
509 // [swift_RouteLayer_addRouteLayerListener]
511 // [swift_RouteLayer_addRouteViewListener]
512 routeViewListener = DemoRouteViewListener(routeLayer: routeLayer)
513 routeLayer.addRouteViewListener(routeViewListener)
514 // [swift_RouteLayer_addRouteViewListener]
516 // [swift_RouteLayer_clear]
518 print("Route layer cleared")
519 // [swift_RouteLayer_clear]
523 * Demonstrate coordinate conversion methods
525 func demonstrateCoordinateConversion() {
526 print("--- Coordinate Conversion Methods ---")
528 guard let locationWindow = locationWindow else {
529 print("LocationWindow not available yet")
533 // [swift_LocationWindow_screenPositionToGlobal]
534 let screenPoint = ScreenPoint(x: 100.0, y: 200.0)
535 let globalPoint = locationWindow.screenPositionToGlobal(screenPoint)
536 print("Screen position (\(screenPoint.x), \(screenPoint.y)) converted to WGS84: (\(globalPoint.latitude), \(globalPoint.longitude))")
537 // [swift_LocationWindow_screenPositionToGlobal]
539 // [swift_LocationWindow_getVisibleRegion]
540 let visibleRegion = locationWindow.visibleRegion
541 print("Viewport top-left: \(visibleRegion.topLeft)")
542 // [swift_LocationWindow_getVisibleRegion]
544 // [swift_LocationWindow_getFocusRegion]
545 let focusRegion = locationWindow.focusRegion
546 print("Focus-rect top-left: \(focusRegion.topLeft)")
547 // [swift_LocationWindow_getFocusRegion]
549 // [swift_LocationWindow_globalToScreenPosition]
550 let globalPoint2 = GlobalPoint(latitude: 55.7558, longitude: 37.6176)
551 let screenPoint2 = locationWindow.globalToScreenPosition(globalPoint2, clipToViewport: true)
552 print("WGS84 (\(globalPoint2.latitude), \(globalPoint2.longitude)) converted to screen with clipping: (\(screenPoint2.x), \(screenPoint2.y))")
553 // [swift_LocationWindow_globalToScreenPosition]
555 let testScreenPoints = [
556 ScreenPoint(x: 0.0, y: 0.0),
557 ScreenPoint(x: 250.0, y: 250.0),
558 ScreenPoint(x: 1000.0, y: 600.0)
561 for (index, screenPoint) in testScreenPoints.enumerated() {
562 let global = locationWindow.screenPositionToGlobal(screenPoint)
563 let backToScreen = locationWindow.globalToScreenPosition(global, clipToViewport: false)
564 print("Test \(index): Screen (\(screenPoint.x), \(screenPoint.y)) -> WGS84 (\(global.latitude), \(global.longitude)) -> Screen (\(backToScreen.x), \(backToScreen.y))")
569 * Demonstrate map feature selection methods
571 func demonstrateMapFeatureSelection() {
572 print("--- Map Feature Selection Methods ---")
574 guard let locationWindow = locationWindow else {
575 print("LocationWindow not available yet")
579 // [swift_LocationWindow_selectMapFeature]
580 // Select map feature by ID
581 let featureId = "room_101"
582 let selected = locationWindow.selectMapFeature(featureId)
583 print("Selected map feature \(featureId): \(selected)")
584 // [swift_LocationWindow_selectMapFeature]
586 // [swift_LocationWindow_selectMapFeature_2]
587 // Select another map feature
588 let featureId2 = "office_205"
589 let selected2 = locationWindow.selectMapFeature(featureId2)
590 print("Selected map feature \(featureId2): \(selected2)")
591 // [swift_LocationWindow_selectMapFeature_2]
593 // [swift_LocationWindow_getSelectedMapFeatures]
594 // Get list of selected map features
595 let selectedFeatures = locationWindow.selectedMapFeatures
596 print("Currently selected map features: \(selectedFeatures.count) features")
597 for feature in selectedFeatures {
598 print(" - \(feature)")
600 // [swift_LocationWindow_getSelectedMapFeatures]
602 // [swift_LocationWindow_deselectMapFeature]
603 // Deselect specific map feature
604 let deselected = locationWindow.deselectMapFeature(featureId)
605 print("Deselected map feature \(featureId): \(deselected)")
606 // [swift_LocationWindow_deselectMapFeature]
608 // [swift_LocationWindow_deselectMapFeature_2]
609 // Deselect another map feature
610 let deselected2 = locationWindow.deselectMapFeature(featureId2)
611 print("Deselected map feature \(featureId2): \(deselected2)")
612 // [swift_LocationWindow_deselectMapFeature_2]
614 // [swift_LocationWindow_deselectAllMapFeatures]
615 // Deselect all map features
616 locationWindow.deselectAllMapFeatures()
617 print("Deselected all map features")
618 // [swift_LocationWindow_deselectAllMapFeatures]
620 // [swift_LocationWindow_getSelectedMapFeatures_2]
621 // Verify all features are deselected
622 let remainingFeatures = locationWindow.selectedMapFeatures
623 print("Remaining selected features after deselect all: \(remainingFeatures.count) features")
624 // [swift_LocationWindow_getSelectedMapFeatures_2]
626 // Test multiple feature selection and deselection
627 let testFeatureIds = ["room_101", "office_205", "meeting_room_301", "cafe_401"]
629 // Select multiple features
630 for featureId in testFeatureIds {
631 let success = locationWindow.selectMapFeature(featureId)
632 print("Selected feature \(featureId): \(success)")
635 // Check selected features
636 let allSelected = locationWindow.selectedMapFeatures
637 print("All selected features: \(allSelected.count) features")
639 // Deselect all at once
640 locationWindow.deselectAllMapFeatures()
641 print("Deselected all features at once")
645 * Demonstrate applyLayerFilter method
647 func demonstrateApplyLayerFilter() {
648 print("--- applyLayerFilter Method ---")
650 guard let locationWindow = locationWindow else {
651 print("LocationWindow not available yet")
655 // [swift_MapFilterCondition_constructor]
656 // Create filter condition: show only venues with category "Toilet" or "Cafe"
657 let condition = NCMapFilterCondition(property: "category", values: ["Toilet", "Cafe"])
658 // [swift_MapFilterCondition_constructor]
660 // [swift_LocationWindow_applyLayerFilter]
661 // Apply filter to venues layer
662 let conditions = [NCMapFilterCondition(property: "category", values: ["Toilet", "Cafe"])]
663 locationWindow.applyLayerFilter("venues", conditions: conditions)
664 print("Applied layer filter: show venues with category Toilet or Cafe")
665 // [swift_LocationWindow_applyLayerFilter]
667 // Reset filter (show all venues)
668 locationWindow.applyLayerFilter("venues", conditions: [])
669 print("Reset layer filter: show all venues")
673 * Demonstrate zoom properties
675 func demonstrateZoomProperties() {
676 print("--- Zoom Properties ---")
678 guard let locationWindow = locationWindow else {
679 print("LocationWindow not available yet")
683 // [swift_LocationWindow_getZoomFactor]
684 // Get current zoom factor
685 let currentZoom = locationWindow.zoomFactor
686 print("Current zoom factor: \(currentZoom)")
687 // [swift_LocationWindow_getZoomFactor]
689 // [swift_LocationWindow_setZoomFactor]
691 locationWindow.zoomFactor = 150.0
692 print("Set zoom factor to 150.0")
693 // [swift_LocationWindow_setZoomFactor]
695 // [swift_LocationWindow_getMinZoomFactor]
696 // Get minimum zoom factor
697 let minZoomFactor = locationWindow.minZoomFactor
698 print("Minimum zoom factor: \(minZoomFactor)")
699 // [swift_LocationWindow_getMinZoomFactor]
701 // [swift_LocationWindow_setMinZoomFactor]
702 // Set minimum zoom factor
703 locationWindow.minZoomFactor = 50.0
704 print("Set minimum zoom factor to 50.0")
705 // [swift_LocationWindow_setMinZoomFactor]
707 // [swift_LocationWindow_getMaxZoomFactor]
708 // Get maximum zoom factor
709 let maxZoomFactor = locationWindow.maxZoomFactor
710 print("Maximum zoom factor: \(maxZoomFactor)")
711 // [swift_LocationWindow_getMaxZoomFactor]
713 // [swift_LocationWindow_setMaxZoomFactor]
714 // Set maximum zoom factor
715 locationWindow.maxZoomFactor = 300.0
716 print("Set maximum zoom factor to 300.0")
717 // [swift_LocationWindow_setMaxZoomFactor]
719 // Test zoom factor changes
720 let testZoomFactors = [100.0, 125.0, 150.0, 200.0, 250.0]
721 for zoom in testZoomFactors {
722 locationWindow.zoomFactor = zoom
723 print("Changed zoom factor to: \(locationWindow.zoomFactor)")
727 print("Testing zoom limits...")
728 locationWindow.zoomFactor = locationWindow.minZoomFactor
729 print("Set to minimum zoom: \(locationWindow.zoomFactor)")
731 locationWindow.zoomFactor = locationWindow.maxZoomFactor
732 print("Set to maximum zoom: \(locationWindow.zoomFactor)")
735 locationWindow.zoomFactor = 100.0
736 print("Reset zoom factor to default: \(locationWindow.zoomFactor)")
740 * Main demonstration method
743 print("=== LocationWindowCommon Example ===")
745 // Simulate LocationWindow initialization
746 DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
747 // TODO: User will implement LocationWindow initialization here
748 // self.locationWindow = self.getLocationWindow()
750 // Run demonstrations
751 self.demonstrateLocationWindowCommonMethods()
753 print("=== Example completed ===")
759 * Function to run the example
762 let example = LocationWindowCommonExample()
765 // Keep the program running for a bit to see the output
766 RunLoop.main.run(until: Date().addingTimeInterval(2.0))
772class DemoSublocationChangeListener: NSObject, SublocationChangeListener {
773 // [swift_SublocationChangeListener_onActiveSublocationChanged]
774 func onActiveSublocationChanged(_ sublocationId: Int32) {
775 print("Active sublocation changed to: \(sublocationId)")
777 // [swift_SublocationChangeListener_onActiveSublocationChanged]