Answer the question
In order to leave comments, you need to log in
How to center the map using external controls?
A map is displayed on the page, I want to select cities from the drop-down list next to it and so that the map itself is centered on this city, how can I implement this?
Answer the question
In order to leave comments, you need to log in
We add an attribute containing the coordinates of the city to the select items:
<option value="[55.751244,37.618423]">Москва</option>
select.addEventListener('change', function() {
map.setCenter(JSON.parse(this.value));
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question