Is there an equivalent in Baidu like fitBounds in GoogleMap? I have multiple markers on a Baidu map and I would like to show all the markers with the proper positioning and zoom level.
Asked
Active
Viewed 3,045 times
3 Answers
10
Just stumbling upon this thread. The answer to this question is:
var points = [Point_1,...,Point_n];
map.setViewport(points);
points
is simply an array containing objects of type BMap.Point
that you want within the map viewport.

Harvester316
- 381
- 1
- 8
- 17
1
Although this answer worked for me, with the change of direct latlng
object instead of BMap.Point
object to make it work.

gowsick
- 11
- 3
0
It is possible to show multiple markers on Baidu Map.
I have displayed Baidu Map with an area of 230x125 so I have shown the China on the area like below:
var map = new BMap.Map("id_of_map_loading_area");
var point = new BMap.Point(101.841797,35.433724); //China on the center of the area
map.centerAndZoom(point,3); // Change value 3 to see difference
map.enableScrollWheelZoom(); // Zoom effect to the map using mouse.

Web_Developer
- 1,251
- 2
- 18
- 34