POIs Module
The POIs Module controls Points of Interest displayed on the map, allowing you to show/hide POIs and filter them by category.
Initialization
import { TomTomMap, POIsModule } from '@tomtom-org/maps-sdk/map';
// Initialize mapconst map = new TomTomMap({ mapLibre: { container: 'map' } });
// Get POIs moduleconst poisModule = await POIsModule.get(map);Visibility Control
Control POI layer visibility on the map:
// Initialize with hidden POIsconst poisModule = await POIsModule.get(map, { visible: false});
// Hide all POIspoisModule.setVisible(false);
// Show all POIspoisModule.setVisible(true);
// Check current visibility stateconst visible = poisModule.isVisible();Filtering
Filter POIs by individual categories or category groups:
// Filter on initializationconst poisModule = await POIsModule.get(map, { visible: true, filters: { categories: { show: 'only', values: ['RESTAURANT', 'CAFE_PUB'] } }});
// Show categoriespoisModule.filterCategories({ show: 'only', values: ['RESTAURANT', 'CAFE_PUB', 'HOTEL_MOTEL']});
// Hide categoriespoisModule.filterCategories({ show: 'all_except', values: ['PARKING_GARAGE', 'OPEN_PARKING_AREA']});
// Show category groupspois.filterCategories({ show: 'only', values: ['FOOD_DRINKS_GROUP', 'SHOPPING_GROUP']});
// Hide category groupspois.filterCategories({ show: 'all_except', values: ['PARKING_GROUP', 'GAS_STATIONS_GROUP']});
// Reset filter and show all categoriespois.filterCategories(undefined);Available Category Groups
The module supports predefined category groups for convenient filtering:
- FOOD_DRINKS_GROUP - Restaurants, cafes, fast food, pubs, wineries
- SHOPPING_GROUP - Stores, malls, markets, supermarkets
- TRANSPORTATION_GROUP - Airports, train stations, bus stops, ferry terminals
- HEALTH_GROUP - Hospitals, clinics, pharmacies, doctors, dentists
- PARKING_GROUP - Parking garages and open parking areas
- HOLIDAY_TOURISM_GROUP - Tourist attractions, museums, beaches, scenic views
- EV_CHARGING_STATIONS_GROUP - Electric vehicle charging stations
- GAS_STATIONS_GROUP - Gas and petrol stations
- ACCOMMODATION_GROUP - Hotels, motels, camping grounds
- ENTERTAINMENT_GROUP - Cinemas, theaters, nightlife, casinos
- SPORTS_LEISURE_GROUP - Stadiums, sports centers, swimming pools, golf courses
- EDUCATION_GROUP - Schools, universities, libraries, cultural centers
- GOVERNMENT_GROUP - Government offices, courthouses, embassies, police, fire stations
Events
Handle user interactions with POIs:
// Click eventspois.events.on('click', (feature, lngLat) => { console.log('POI name:', feature.properties.name); console.log('Category:', feature.properties.category); console.log('ID:', feature.properties.id); console.log('Click coordinates:', lngLat);});
// Hover eventspois.events.on('hover', (feature, lngLat) => { console.log('Hovering over:', feature.properties.name);});
// Context menu (right-click)pois.events.on('contextmenu', (feature, lngLat) => { console.log('Right-clicked POI:', feature.properties.name);});
// Long hoverpois.events.on('long-hover', (feature, lngLat) => { console.log('Long hover on:', feature.properties.name);});
// Remove event listenerspois.events.off('click', handler);POI Feature Properties
POI features include the following properties in events:
id- Unique POI identifiername- POI name in native languagecategory- POI category (e.g., ‘RESTAURANT’, ‘HOTEL_MOTEL’)iconID- Icon sprite ID used for renderinggroup- Category group the POI belongs topriority- Importance level (lower number = more important)
API Reference
For complete documentation of all POIs Module properties, methods, and types, see the POIsModule API Reference .
Related Guides and Examples
Services Integration
- Search Services - Find places and display them with the Places Module alongside filtered POIs
Related Examples
- POI Filters - Interactive POI category filtering
- Geometry Search with POI Categories - Search for POIs within specific areas
- Places Customize - Combining POIs with custom place markers
Related Map Modules
- Places Module - Display custom places and search results on the map
- User Interaction Events - Handle user interactions with map features including POIs