Home  >  Q&A  >  body text

javascript - Baidu Map sets the center point at the beginning, how to use the button to transfer to the corresponding center point? ? ? ?


To achieve this, click the Qingdao or Xiamen buttons to transfer to the coordinate point location of Qingdao (or the corresponding)
Currently, the initial map center point is set to Xinjiang


This is how to initialize the map

$(".btn-Qing").on('click', function () {

// 百度地图API功能
map = new BMap.Map("map-container", { minZoom: 5, maxZoom: 10 });
var initPoint1 = new BMap.Point(120.369461, 36.118473);
map.centerAndZoom(initPoint1, 8);
map.addOverlay(initPoint1)
InitBMap();

})
This is what I wrote simply, but when I add that method at the end, there is no way to transfer it to Qingdao. Can anyone teach me how to do it?

三叔三叔2663 days ago955

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-07-05 11:08:47

    map.setCenter(new BMap.Point(116.304, 39.915))

    reply
    0
  • 巴扎黑

    巴扎黑2017-07-05 11:08:47

    reply
    0
  • Cancelreply