Maps SDK for Web
Services
Overview
The Services library provides the necessary tools to integrate all Tomtom services with your application. We take care of all the aspects required to make the calls to the Tomtom APIs, such as the construction of the URL, validation, and error handling. It is worth noting that by using our help, you avoid making mistakes and extra calls to the service.We provide three different bundles of the library:
- services-web.min.js - use this file if you want to include the library directly on a web page,
it can be imported in the
<head>
of your HTML document. Thett
global object will be created and attached to thewindow
. - services.min.js - use this file if you are using a module bundler. It conforms the
UMD standard.
In case you use ES6 imports all you need is:
import tt from 'services.min.js'
- services-node.min.js - use this file if you want to use our services in Node.js.
If you want to display a map on the webpage, go to
Maps library documentation.
Difference between API responses and this library's responses
Services library provides an easy way to get responses from APIs like Search API, Routing API or Traffic API. In order to maintain consistency between data types returned by those APIs, and to make it more convenient to use those responses and data types with the Maps library, Services library alters original responses:- point representations like
[lat, lon]
,'lat, lon'
,{lon, lat}
,{latitude, longitude}
,{x, y}
are mapped to{lng, lat}
Object type. - some services responses are extended by additional methods like
toGeoJson()
(calculateRoute, calculateReachableRange, incidentDetails, alongRouteSearch, placeById, fuzzySearch, geometrySearch, nearbySearch, categorySearch, poiSearch, structuredGeocode, geocode).
Usage of this method is presented on the documentation page of each service mentioned.
- The
getTrackingId()
method is also available as part of the service response in order to obtain theTracking-ID
associated with the request.
Most services are asynchronous and return Promise except for staticImage and poiPhotos, which return URL string.