2013-12-14 5 views
-1

이 Google지도를 폴리 라인 경계의 경계로 크기를 조정하려면 어떻게해야합니까?Google지도의 폴리 라인 경계

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

을하지만, 나는 또한 잘못된 장소에 넣어라고 생각 :

http://goo.gl/hjOcAx

나는 내가 이것을 사용하는 것이 올바른라고 생각.

+0

v3에 'GPolyline.getBounds()'이 (가) v2에 없으므로 없습니다. Javascript가 내 장점이 아니지만이 해결책을 찾고 싶습니다 – user1194034

답변

0
  1. decodedPath는 경로 (폴리 라인이 아님)이며 getPath() 메서드가 없습니다. 사용 : 어떤 방법 setBounds() 없다

    decodedPath.forEach(function(LatLng) { 
        bounds.extend(LatLng); 
    }); 
    
  2. 대신 fitBounds()를 사용합니다.
+0

감사합니다! myLatlng 변수에서 하드 코딩 된 lat 및 lng 필드를 제거하고 myOptions 변수에서 'center'및 'zoom'속성을 fitBounds() 메서드로 제거했습니다. 매력처럼 작동 :) – user1194034