Google Maps API v3.22还原为旧版控件

时间:2015-09-16 13:15:41

标签: javascript google-maps google-maps-api-3

谷歌昨天发布了他们的地图api的v3.22,它移动了一堆标准控件。

根据http://googlegeodevelopers.blogspot.co.uk/2015/09/new-controls-style-for-google-maps.html#gpluscomments的Google博客,您可以暂时恢复旧版控件,但我可以这样做。

博客文章说只是在初始化地图之前添加google.maps.controlsStyle = 'azteca',但我仍然会显示旧的控件,并且它们与我的一些自定义控件发生冲突。

我尝试在initialize()例程的开头添加该行(设置所有地图选项并创建map对象;并且也在{{1}之前声明。

有没有人知道我做错了什么?

2 个答案:

答案 0 :(得分:3)

他们在帖子中(以及documentation

中有拼写错误

Issue in the issue tracker

google.maps.controlsStyle = 'azteca';

应该是:

google.maps.controlStyle = 'azteca';

代码段



var map;

function initMap() {
  google.maps.controlStyle = 'azteca'
  map = new google.maps.Map(document.getElementById('map'), {
    center: {
      lat: -34.397,
      lng: 150.644
    },
    zoom: 8
  });
}
google.maps.event.addDomListener(window, 'load', initMap);

html,
body,
#map {
  height: 100%;
  width: 100%;
}

<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map"></div>
&#13;
&#13;
&#13;

答案 1 :(得分:2)

试试这个: google.maps.controlStyle ='azteca';