How can I change the location center of a map using Leaflet API?

前端 未结 4 1816
礼貌的吻别
礼貌的吻别 2021-02-04 21:11

My map (Mapbox) takes up the whole background of the site so the center is in the middle of the site. But the focus of the map for the user is on the right side because I have

4条回答
  •  Happy的楠姐
    2021-02-04 22:03

    If you have multiple markers and want to center the map in their bounds and at the same time you have overlapping container, you can use the fitBounds options (paddingTopLeft, paddingBottomRight, padding).

    http://leafletjs.com/reference.html#map-paddingtopleft

提交回复
热议问题