1. 第一种方法:flyToBounds
var polygon = new L.Rectangle(L.latLngBounds([
[39.9031855750273, 116.39760275470988],
[39.88132436586913, 116.36142920205131]
]), {
weight: 5,
draggable: true,
transform: true,
color: 'blue',
fillColor: "transport",
fillOpacity: 0,
}).addTo(map);
map.flyToBounds(polygon.getBounds());
2. 第二种方法: setView
var position= [lat, lng];
map.setView(position, 13);
3. 第三种方法:fitBounds
var bounds=L.latLngBounds([
[39.9031855750273, 116.39760275470988],
[39.88132436586913, 116.36142920205131]
])
map.fitBounds(bounds);
4. flyTo
var position= [lat, lng];
map.flyTo(position, 13);
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41