Bounding Box with longitude and latitude

Hello,

I am trying to use the Traffic Incident Details API and trying to work how I set the boundingBox values. I was trying to traffic information for London in the UK. A good example of how this is achieved would be good.

Thanks,
Scott.

Hello Scott.

Here you can find a documentation regarding Incident Details API: https://developer.tomtom.com/traffic-api/traffic-api-documentation-traffic-incidents/incident-details .

BoundingBox parameter should contains four comma-separated values: minLat,minLon,maxLat,maxLon. The first two are for the lower-left corner and the second two are for the upper-right corner of the map.

An example call for London city:
https://api.tomtom.com/traffic/services/4/incidentDetails/s1/51.484586770990404,-0.17678571769417317,51.50382680255797,-0.1319339427044781/13/-1/json?key=YOUR_VALID_API_KEY&projection=EPSG4326

Regards,
Mateusz

1 Like

Yes. I read the documentation. The values in the documentation example ie API explorer aren’t longitude and latitude. I’ve tried laong and lat values for whole UK and got no data back.

1 Like

If possible, please share your API call which is not working for you or compare it to a valid example API call from the previous post.
Are you sure that you are not exceeding the maximum allowed size of the bounding box?

1 Like

Hi Scott,

Did you ever sort this? I’m seeing the same issues:

curl -X GET “https://api.tomtom.com/traffic/services/4/incidentDetails/s3/-1.3423889692%2C53.2084608948%2C-0.0734680707%2C53.5769766218/10/-1/json?key=*****” -H “accept: /

No never got this working! Sorry! Let me know if you do.

Hi.

Matthew - there are no incidents returned from your call because the bounding box is not formulated according to the API documentation.

I really encourage both of you to take a look and play with the Traffic tutorial.

The following screenshot presents Matthews bounding box and traffic incidents inside it:

You can find a corrected call for a given bounding box below:

https://api.tomtom.com/traffic/services/4/incidentDetails/s3/53.2084608948,-1.3423889692,53.5769766218,-0.0734680707/10/-1/json?key=YOUR_API_KEY&projection=EPSG4326

Please note, that for a given zoom level(in this case 10) you will receive a lot of clusters which you can either expand by using the expandCluster parameter or use a night style which does not group incidents into clusters at all.

Hope this helps a little bit :slight_smile:

Regards,
Mateusz

Thanks that’s actually worked, apart from me having lat lon the opposite way around, it seems you need to specify the projection as well, ie:

This works
https://api.tomtom.com/traffic/services/4/incidentDetails/s3/53.2084608948,-1.3423889692,53.5769766218,-0.0734680707/10/-1/json?key=***&projection=EPSG4326

this doesn’t:
https://api.tomtom.com/traffic/services/4/incidentDetails/s3/53.2084608948,-1.3423889692,53.5769766218,-0.0734680707/10/-1/json?key=***

I’m glad that I could help :slight_smile:

You don’t need to specify projection. According to the documentation when you will not do that, the default projection will be used and in order to retrieve similar results as previously, you have to transform your coordinates to match the default projection, which in this case is the Web Mercator.
See the following call: https://api.tomtom.com/traffic/services/4/incidentDetails/s3/7021651.01,-149434.05,7090444.34,-8178.43/10/-1/json?key=YOUR_API_KEY

Regards,
Mateusz