This is the documentation of version 1.0.0-rc.0. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Type Alias PlaceIconConfig<P>

    The icons of place markers, including custom icons.

    // Custom icons for specific categories
    const iconConfig: PlaceIconConfig = {
    categoryIcons: [
    { id: 'RESTAURANT', image: '/icons/food.png', pixelRatio: 2 },
    { id: 'HOTEL_OR_MOTEL', image: '/icons/hotel.png', pixelRatio: 2 }
    ]
    };

    Type Parameters

    Index
    categoryIcons?: CustomImage<MapStylePOICategory>[]

    Custom icons for specific place categories, which places in those categories use instead of the default style.

    A place takes the entry for its own category. Otherwise, it takes the first entry for the map category its category falls in, as the map's own POIs do. For example, RESTAURANT reaches an ITALIAN_RESTAURANT, and CAFE a CAFE_PUB. That second match takes only entries with an image, so the same list given to POIsModuleConfig.icon restyles both alike.

    Configuration for the default place icon.

    • The default icon is the one used for clicked locations and addresses without a specific category, or via custom mapping.
    mapping?: IconMapping<Place<P>>

    A custom mapping that picks the icon of each place.

    fn receives places of the shape the module was created for, so your own properties are typed. A poiCategory resolves through the marker type, as a place's own category does.

    // Direct image ID mapping
    mapping: {
    to: 'imageID',
    fn: (place) => place.properties.poi?.name?.includes('urgent') ? 'urgent-icon' : 'default-icon'
    }

    // POI category mapping, from a property of your own
    type Venue = CommonPlaceProps & { venueCategory?: MapStylePOICategory };
    await PlacesModule.create<Venue>(map, {
    icon: { mapping: { to: 'poiCategory', fn: (place) => place.properties.venueCategory ?? 'RESTAURANT' } },
    });