Skip to content

Commit cf4b5cb

Browse files
authored
Merge pull request #179989 from stevemunk/SM-iOS-SDK-Indoor-Maps
Using indoor maps in the iOS SDK
2 parents ff49fdc + a5d136d commit cf4b5cb

File tree

3 files changed

+85
-1
lines changed

3 files changed

+85
-1
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: Use the Azure Maps indoor maps module to develop iOS applications with Microsoft Creator services
3+
description: Learn how to use the Microsoft Azure Maps indoor maps module for the iOS SDK to render maps by embedding the module's JavaScript libraries.
4+
author: stevemunk
5+
ms.author: v-munksteve
6+
ms.date: 11/18/2021
7+
ms.topic: how-to
8+
ms.service: azure-maps
9+
services: azure-maps
10+
manager: eriklind
11+
---
12+
13+
# Using indoor maps in the iOS SDK
14+
15+
The Azure Maps iOS SDK allows you to render indoor maps created in Azure Maps Creator services.
16+
17+
## Prerequisites
18+
19+
1. Be sure to complete the steps in the [Quickstart: Create an iOS app](quick-ios-app.md). Code blocks in this article can be inserted into the `viewDidLoad` function of `ViewController`.
20+
1. [Create a Creator resource](how-to-manage-creator.md)
21+
1. Get a `tilesetId` by completing the [tutorial for creating Indoor maps](tutorial-creator-indoor-maps.md). You'll need to use this identifier to render indoor maps with the Azure Maps iOS SDK.
22+
23+
## Instantiate the indoor manager
24+
25+
To load the indoor tilesets and map style of the tiles, you must instantiate an `IndoorManager` and keep a strong reference to it.
26+
27+
```swift
28+
guard let indoor = try? IndoorManager(azureMap: map, options: [.tilesetID({Your-tilesetID})]) else { return }
29+
self.indoorManager = indoor
30+
```
31+
32+
> [!IMPORTANT]
33+
> This guide assumes that your Creator service was created in the United States. If your Creator service was created in Europe, add the following code:
34+
>
35+
> ```swift
36+
> self.indoorManager.setOptions([.geography(.eu)])
37+
> ```
38+
39+
## Indoor level picker control
40+
41+
The *Indoor Level Picker* control allows you to change the level of the rendered map. You can optionally initialize an `IndoorControl` and set to the appropriate option on the `IndoorManager` as in the following code:
42+
43+
```swift
44+
let levelControl = IndoorControl(options: [.controlPosition(.topRight)])
45+
self.indoorManager.setOptions([.levelControl(levelControl)])
46+
```
47+
48+
> [!TIP]
49+
> The *level picker* appears when you tap on a facility.
50+
51+
## Indoor events
52+
53+
Add a delegate to the `IndoorManager` to listen to indoor map events:
54+
55+
```swift
56+
self.indoorManager.addDelegate(self)
57+
```
58+
59+
`IndoorManagerDelegate` has one method, which is invoked when a facility or floor changes.
60+
61+
```swift
62+
func indoorManager(
63+
_ manager: IndoorManager,
64+
didSelectFacility selectedFacility: IndoorFacilitySelection,
65+
previousSelection: IndoorFacilitySelection
66+
) {
67+
// code that you want to run after a facility or floor has been changed
68+
print("New selected facility's ID:", selectedFacility.facilityID)
69+
print("New selected floor:", selectedFacility.levelsOrdinal)
70+
}
71+
```
72+
73+
## Example
74+
75+
The screenshot below shows the above code displaying an indoor map.
76+
77+
![A screenshot that displays an indoor map created using the above sample code.](./media/ios-sdk/indoor-maps/indoor.png)
78+
79+
## Additional information
80+
81+
- [Creator for indoor maps](creator-indoor-maps.md)
82+
- [Drawing package requirements](drawing-requirements.md)
1.22 MB
Loading

articles/azure-maps/toc.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,9 @@ items:
280280
- name: Develop with the iOS SDK
281281
items:
282282
- name: Getting started with iOS map control
283-
href: how-to-use-ios-map-control-library.md
283+
href: how-to-use-ios-map-control-library.md
284+
- name: Use the Azure Maps indoor maps module
285+
href: how-to-use-indoor-module-ios.md
284286
- name: Use Azure Maps in Power BI
285287
items:
286288
- name: Getting started

0 commit comments

Comments
 (0)