S
S
Sergey questions2018-06-02 20:40:04
JavaScript
Sergey questions, 2018-06-02 20:40:04

Leaflet - how to get the latitude and longitude data of the extreme left, right, top and bottom of the visible area of ​​the map?

Hello.
Leafleft - https://leafletjs.com/ has a function - getCenter , which displays the latitude and longitude of the center of the map at the currently viewed scale and size.
Question:
How to get the extreme upper and lower extreme latitude of the visible area, the extreme right and left longitude?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick Sdk, 2018-06-02
@smartycms

first you need to get the "bounds" object (Bounds)
and then from this object we can get the values ​​\u200b\u200bthat we need
LatLngBounds Methods (latitude/longitude of the bounds)

bounds.getSouthWest() // юго-западная точка
bounds.getSouthEast() // юго-восточная точка
bounds.getNorthEast() // северо-восточная точка
bounds.getNorthWest() // северо-западная точка

in response, we get an object with the latitude and longitude of the point
By and large, you can even use it in this form
map.getBounds().getSouthWest().lat // широта юго-западной точки
map.getBounds().getNorthEast().lng // долгота северо-восточной точки

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question