0

I'm trying to find a way to immediately centre a MapBox map on a given location using JavaScript and the closest example I've found so far is to use the 'flyTo' function:

map.flyTo({center: [device.lon, device.lat]});

I'm probably missing something obvious, but how do I just tell the map to immediately jump to that location?

0

I solved it with the following line:

map.setCenter([device.lon, device.lat]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.