2013-06-28 8 views
1

지도상의 경로 그룹을 그려주는 코드가 있습니다. 모든 경로가 표시되도록지도를 확대/축소하려면지도를 얻으려고하고 있지만 아무 것도 작동하지 않습니다. 여기가 시작되기 전에 코드가 어떻게 생겼는지입니다 : Google지도를 확대/축소하려고 할 때 내 머리를 맞출 수 없습니다.

var points = new Array(); 
var pointsData = []; 
var pointsData = $('#master-' + r + ' > #route-data').html(); 
if (pointsData != '') 
{ 
    var pointsArray = JSON.parse(pointsData); 
    for (var p=0; p<pointsArray.length; p++) { 
     points.push(new google.maps.LatLng(pointsArray[p][0], pointsArray[p][1])); 
    } 
    $.OverMap.drawRoute(points); 
} 
else $.OverMap.drawDirections({preserveViewport:false}); 

그리고 바이올린을 켜는 후

:

map = this.map.map; 

map.fitBounds(this.map.bounds); 
zoomChangeBoundsListener = 
    google.maps.event.addListenerOnce(map, 'bounds_changed', function(event) { 
     if (this.getZoom()){ 
      this.setZoom(16); 
     } 
}); 
setTimeout(function(){google.maps.event.removeListener(zoomChangeBoundsListener)}, 2000); 

// Draw route 
var bounds = new google.maps.LatLngBounds(); 
var points = new Array(); 
var pointsData = []; 
var pointsData = $('#master-' + r + ' > #route-data').html(); 
if (pointsData != '') 
{ 
    var pointsArray = JSON.parse(pointsData); 
    for (var p=0; p<pointsArray.length; p++) { 
     points.push(new google.maps.LatLng(pointsArray[p][0], pointsArray[p][1])); 
     bounds.extend(pointsArray[p][0], pointsArray[p][1]); 
    } 
    $.OverMap.drawRoute(points); 
} 
else $.OverMap.drawDirections({preserveViewport:false}); 

내가 잘못거야 어디 사람이 지적 할 수 있습니까?

답변

0

google.maps.LatLngBounds.extendgoogle.maps.LatLng 개체를 인수로 취합니다.

하지 :

for (var p=0; p<pointsArray.length; p++) { 
    points.push(new google.maps.LatLng(pointsArray[p][0], pointsArray[p][1])); 
    bounds.extend(pointsArray[p][0], pointsArray[p][1]); 
} 

대신 수행

for (var p=0; p<pointsArray.length; p++) { 
    var pt = new google.maps.LatLng(pointsArray[p][0], pointsArray[p][1]); 
    points.push(pt); 
    bounds.extend(pt); 
} 
+0

덕분에 많은 코드는 여전히 작동하지 않지만, 지금은 내가 잘못받은 것 중 하나 알고있다. – ninjachicken1