How to get the speed Limit of current route

Is there any API that returns the Speed Limit of the current route?

Hi,
you can use Reverse geocoding, which returns ReverseGeocoderSearchResponse that contains an address with a speed limit at the desired position. Do not forget about setting withReturnSpeedLimit to true.

For example:

    val reverseGeocoderSearchQuery = ReverseGeocoderSearchQueryBuilder(latLng.latitude, latLng.longitude).withReturnSpeedLimit(true).build()
    searchApi.reverseGeocoding(reverseGeocoderSearchQuery, object: RevGeoSearchResultListener {
        override fun onSearchResult(response: ReverseGeocoderSearchResponse?) {
            val address = response?.addresses?.first()?.address ?: return
            val speedLimit = address.speedLimit
        }

        override fun onSearchError(error: SearchError?) {
            error?.printStackTrace()
        }

    })
1 Like

Could you please explain , how to get searchApi object and what should be the SEARCH_API_KEY?

You can find how to initialize SearchAPI object here in documentation section. The SEARCH_API_KEY is your TomTom API key, it has to have the Search API product enabled (you can check it once you log in https://developer.tomtom.com/user/me/apps).

1 Like