-1

我怎样才能让这个谷歌地图调整到折线边界的范围?

http://goo.gl/hjOcAx

我认为我使用这个是正确的:

var bounds = new google.maps.LatLngBounds();
    decodedPath.getPath().forEach(function(LatLng) {
    bounds.extend(LatLng);
});
map.setBounds(bounds);

但我也认为我把它放在了错误的地方。

4

1 回答 1

0
  1. decodedPath 是一个路径(不是折线)并且没有方法getPath()。利用:

    decodedPath.forEach(function(LatLng) {
       bounds.extend(LatLng);
    });
    
  2. 没有方法setBounds()fitBounds()改用。
于 2013-12-14T21:16:49.783 回答