This is the documentation of version 1.0.0-rc.3. 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 PlaceIconConfig<P extends CommonPlaceProps = CommonPlaceProps> = {
        categoryIcons?: CustomImage<MapStylePOICategory>[];
        default?: DefaultPlaceIconConfig;
        mapping?: IconMapping<Place<P>>;
        opacity?: number;
    }

    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, and a plain sub-category such as SCHOOL_GENERIC then the entry for its parent, SCHOOL, with or without an image.

    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 last match takes only entries with an image, so given the same list as POIsModuleConfig.icon, a place it reaches draws the icon of the map's own POIs.

    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' } },
    });
    opacity?: number

    Opacity of the place icons, from 0 to 1, whichever marker type draws them. The labels take label.opacity. The cluster badges and a highlighted or selected place stay opaque, so a selected place still stands out.

    1