Display a Map
Last updated
Last updated
Now that we have the prerequisite API keys, and the project set up, we can start adding basic functionality to the app. We will start by having the app display a map.
Examples
Check out this Github repo for the full Getting Started code: iOS v4 Getting Started.
Note: Later in the Examples, Map Engine
and Map Provider
can refer to Google Maps and/or Mapbox.
In order to accomplish this we will be utilizing the MPMapControl Class and adding code to initialize MapsIndoors and show a map.
Within the ViewController
class, make the following changes:
The MPMapControl Class is the connective class between the Map Engine and MapsIndoors. It allows the two services to collaborate by overlaying the MapsIndoors information over the Map Engine information.
We have now added a very simple, non-interactive search feature! Running the app now should yield a combined map of The White House, showing both the external and internal geographical information. However, let us try and understand what is actually happening.
Feel free to change the query from the solution "mapspeople3d" to a known building in your MapsIndoors dataset.
Next, let us look into how we can add a search feature and interact with it. We set up a Query and Filter based on the MPQuery Class and MPFilter Class, respectively. These serve as our search specifications. Finally, we call the MPMapsIndoors.shared.locationsWith(query:filter:)
method, which searches through the full collection of locations based on our previously established query and filter. We then select the desired location and floor index on the map using the mapControl
instance. This handles the selection for MapsIndoors.