Skip to main content

TomTom Provider

Setup

  1. Create a TomTom Developer account
  2. Get your API key from the dashboard

Usage

import { LocationAutocomplete } from '@julekgwa/react-native-places-autocomplete';

export default function App() {
return (
<LocationAutocomplete
provider="tomtom"
providerConfig={{
apiKey: 'YOUR_TOMTOM_API_KEY'
}}
onLocationSelect={(location) => {
console.log(location);
}}
/>
);
}

Configuration Options

<LocationAutocomplete
provider="tomtom"
providerConfig={{ apiKey: 'YOUR_API_KEY' }}
queryOptions={{
limit: 5, // Number of results
language: 'en-GB', // Response language
countrySet: 'US,CA', // Limit to countries
radius: 10000, // Search radius in meters
typeahead: true, // Enable typeahead suggestions
}}
/>

Query options

The queryOptions object customizes TomTom API requests. Use the table below to understand each available option for the TomTom provider.

NameTypeRequiredDefaultDescriptionExample
baseURLstringNoapi.tomtom.comBase host for TomTom API calls (region-specific hosts available).api.tomtom.com
versionNumberstringNo2Service version to call.2
ext"json" | "jsonp" | "js" | "xml"NojsonResponse format extension.json
keystringNoAPI key; normally supplied via providerConfig.YOUR_API_KEY
querystringNoThe search query string (URL-encoded when required).Berlin Pariser 20
typeaheadbooleanNofalseEnable predictive/typeahead mode for partial input.true
limitnumberNo10Maximum number of results (default 10, max 100).25
ofsnumberNo0Result offset within the full result set (pagination).50
countrySetstringNoComma-separated country codes (ISO alpha-2 or alpha-3) to limit search.FR,ES
geoBiasstringNoLocation bias: point:lat,lon or rectangle:topLeftLat,topLeftLon,btmRightLat,btmRightLon. Point precedence.point:52.52,13.405
latnumberNoLatitude for point-radius bias.52.52
lonnumberNoLongitude for point-radius bias.13.405
radiusnumberNoRadius in meters for filtering around lat/lon.10000
topLeftstringNoBounding box top-left coords lat,lon.52.6,13.3
btmRightstringNoBounding box bottom-right coords lat,lon.52.4,13.5
languagestringNoIETF language tag for returned results.en-GB
extendedPostalCodesForstringNoComma-separated indexes for which extended postal codes are returned (e.g. POI,PAD).POI,PAD
minFuzzyLevelnumberNo1Minimum fuzziness (1–4).1
maxFuzzyLevelnumberNo2Maximum fuzziness (1–4).2
idxSetstringNoComma-separated indexes to use for search (e.g. POI,PAD,Str).POI,PAD,Str
categorySetstringNoComma-separated POI category identifiers.7315,7315017
brandSetstringNoComma-separated brand names to filter by.TomTom,Foobar
connectorSetstringNoComma-separated connector types for EV stations.IEC62196Type2CableAttached
minPowerKWnumberNoMinimum power (kW) for EV stations.22.2
maxPowerKWnumberNoMaximum power (kW) for EV stations.43.2
fuelSetstringNoComma-separated fuel types.Diesel,Petrol
vehicleTypeSetstringNoComma-separated vehicle types.Car,Truck
viewstringNoUnifiedGeopolitical view context (country-specific overrides available).AR, CN, IN
openingHoursstringNoPOI opening hours mode (e.g. nextSevenDays).nextSevenDays
timeZonestringNoTimezone mode (e.g. iana).iana
mapcodesstringNoComma-separated mapcodes to return.Local,Alternative
relatedPois"off" | "child" | "parent" | "all"NoInclude related POIs in results.child
entityTypeSetstringNoComma-separated entity types to filter by.Municipality,Neighbourhood

Response Format

// TomTom Raw Response Types
interface TomTomResult {
type: string;
id: string;
score: number;
address: {
streetNumber?: string;
streetName?: string;
municipality?: string;
municipalitySubdivision?: string;
countrySecondarySubdivision?: string;
countrySubdivision?: string;
countrySubdivisionName?: string;
countrySubdivisionCode?: string;
postalCode?: string;
extendedPostalCode?: string;
countryCode: string;
country: string;
countryCodeISO3: string;
freeformAddress: string;
localName?: string;
};
position: {
lat: number;
lon: number;
};
viewport?: {
topLeftPoint: {
lat: number;
lon: number;
};
btmRightPoint: {
lat: number;
lon: number;
};
};
}

// LocationSuggestion with TomTom raw data
interface LocationSuggestion<Raw = TomTomResult> {
place_id: string;
display_name: string;
lat: string;
lon: string;
type: string;
importance: number;
raw?: Raw; // Contains the original TomTom response
}

```jsx
<LocationAutocomplete
provider="tomtom"
onLocationSelect={(location) => {
console.log(location.display_name); // Formatted address
console.log(location.lat, location.lon); // Coordinates
console.log(location.raw?.address); // Structured address
console.log(location.raw?.viewport); // Bounding box
}}
/>

Pricing

TomTom offers: