Searching on a Map
Use the MPMapsIndoors.shared.locationsWith(query:filter:) method to search for content in your MapsIndoors Solution.
Setup a query for the nearest single best matching Location and display the result on the map
let filter = MPFilter()
let query = MPQuery()
query.query = "Office"
query.near = MPPoint(lat: 57.057964, lon: 9.9504112)
query.take = 1
let locations = await MPMapsIndoors.shared.locationsWith(query: query, filter: filter)
if let location = locations?.first {
self.mapControl?.goTo(entity: location)
}
Setup a query for a group of Locations and display the result on the map
let filter = MPFilter()
let query = MPQuery()
query.categories = ["Office"]
query.max = 50
let locations = await MPMapsIndoors.shared.locationsWith(query: query, filter: filter)
self.mapControl?.setFilter(locations: locations, behavior: .default)
if let location = locations?.first {
self.mapControl?.currentFloor = location.floor
}Please note that you are not guaranteed that the visible floor contains any search results, so that is why we change floor in the above example.
Use the MPLocationService class to search for content in your MapsIndoors Solution.
Setup a query for the nearest single best matching Location and display the result on the map
let filter = MPFilter()
let query = MPQuery()
query.query = "Office"
query.near = MPPoint(lat: 57.057964, lon: 9.9504112)
query.take = 1
MPLocationService.sharedInstance().getLocationsUsing(query, filter: filter) { (locations, error) in
if error == nil {
let location = locations?.first
self.mapControl?.go(to: location)
}
}Setup a query for a group of Locations and display the result on the map
let filter = MPFilter()
let query = MPQuery()
query.categories = ["Office"]
query.max = 50
MPLocationService.sharedInstance().getLocationsUsing(query, filter: filter) { (locations, error) in
if error == nil {
self.mapControl?.searchResult = locations
let firstLocation = locations?.first
self.mapControl?.currentFloor = firstLocation.floor
}
}Please note that you are not guaranteed that the visible floor contains any search results, so that is why we change floor in the above example.
Last updated
Was this helpful?