Search in MapsIndoors

Searching through your MapsIndoors data is an integral part of a great user experience with your maps. Users can look for places to go, or filter what is shown on the map.

Searches work on all MapsIndoors geodata. It is up to you to create a search experience that fits your use case. To aid you in this, there are a range of filters you can apply to the search queries to get the best results. E.g. you can filter by Categories, search only a specific part of the map or search near a Location.

See the full list of parameters in the reference guide.

Example of creating a search query

const searchParameters = {
q: 'Office',
near: { lat: 38.897579747054046, lng: -77.03658652944773 }, // // Blue Room, The White House
take: 1
}

mapsindoors.services.LocationsService.getLocations(searchParameters).then(locations => {
console.log(locations);
});

All three return a list of Locations from your Solution matching the parameters they are given. The results are ranked upon the 3 following factors:

  • If a "near" parameter is set, how close is the origin point to the result?
  • How well does the search input text match the text of the result (using the "Levenshtein distance" algorithm)?
  • Which kind of geodata is the result (e.g. Buildings are ranked over POIs)?

This means that the first item in the search result list will be the one matching the 3 factors best and so forth.

Display search results on the map

When displaying the search results it is helpful to filter the map to only show matching Locations. Matching Buildings and Venues will still be shown on the map, as they give context to the user, even if they aren't selectable on the map.

Filter the map to display searched locations on the map

const searchParameters = {
q: 'Office',
near: { lat: 38.897579747054046, lng: -77.03658652944773 }, // // Blue Room, The White House
take: 1
}

mapsindoors.services.LocationsService.getLocations(searchParameters).then(locations => {
mapsIndoorsInstance.filter(locations.map(location => location.id), false);
});

Clearing the map of your filter

After displaying the search results on your map you can then clear the filter so that all Locations show up on the map again.

Example of clearing your map filter to show all Locations again

mapsIndoorsInstance.filter(null);