Display a map off center

I am displaying a map on a webpage based off of a lat/long and want to offset the center by a certain number of pixels. How would I do that? I saw that there is a map.fitBounds, but it requires a “bounds” parameter, and I am not sure how to determine that if I only have a lat/long.

Apologies if I missed it in the examples or documentation. I gave it an honest look but didn’t find it.

const map = tt.map({
key: ‘’,
container: ‘mapControl’,
center: [-79.9959, 40.4406],
})

Hmm… based on current Zoom level you can translate number of pixels to distance with a table from: Zoom Levels and Tile Grid | Map Display API Documentation | Map Display API | TomTom Developer Portal
Then using transformTranslate from Turf.js you can calculate shifted position.

1 Like