하루 종일 검색하고 수많은 코드 메소드를 사용해도 Google지도를 올바르게 가운데 맞추기 및 확대/축소하는 데 문제가 있습니다.Google지도 v3 - 경계를 마커 중심으로 설정
누군가 내 코드에서 잘못하고있는 것을 분명히 지적 할만큼 친절한 지 궁금합니다. 모든 것이 v2에서 잘 돌아 갔지만 Im은 v3으로 업데이트하는 데 어려움이 있습니다. 정보 지도에 대한
은 훨씬 더 큰 PHP 애플리케이션의 작은 부분이며, 다음 & 긴 맵 매개 변수가 이미 주요 음식물에 사용 선언 된 다른 방법에 의해 얻어졌다 LAT 필요 : -
var myDestination=new google.maps.LatLng(e_lat,e_long);
var myHome=new google.maps.LatLng(h_lat,h_long);
확대/축소와 가운데를 제외한 모든 것이 정상적으로 작동하는 것 같습니다. 다음과 같이 문제있는 코드는 다음과 같습니다 -
function initialize()
{
// set the map properties
var mapProp = {
center:myHome,
zoom:12,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
// set the home marker
var marker_home=new google.maps.Marker({
position:myHome,
icon:'house.png'
});
marker_home.setMap(map);
//set the destination marker
var marker_destination=new google.maps.Marker({
position:myDestination,
icon:'flag_red.png'
});
marker_destination.setMap(map);
//google polyline between the 2 points
var myPolyline = [myDestination,myHome];
var directPath = new google.maps.Polyline({
path:myPolyline,
strokeColor:"#0000FF",
strokeOpacity:0.8,
strokeWeight:2
});
directPath.setMap(map);
// Make an array of the LatLng's of the markers you want to show
var LatLngList = array (new google.maps.LatLng (e_lat,e_long), new google.maps.LatLng (h_lat,h_long));
// Create a new viewpoint bound
var bounds = new google.maps.LatLngBounds();
// Go through each...
for (var i = 0, LtLgLen = LatLngList.length; i < LtLgLen; i++) {
// And increase the bounds to take this point
bounds.extend (LatLngList[i]);
}
// Fit these bounds to the map
map.fitBounds (bounds);
}
google.maps.event.addDomListener(window, 'load', initialize);
TIA 정의되지 않은 도움 :) 코드 "배열"에서
를 사용해야합니까? 자바 스크립트 오류가 발생합니까? 당신은 단지 2 점을 가지고 있기 때문에, 그것은 루프없이 작동해야합니다. 문제가있는지도에 대한 링크를 제공 할 수 있습니까 (아니면 jsfiddle을 만들 수 있습니까)? – geocodezip
fitBounds가 제대로 작동하지 않아서 두 지점 사이를 정확하게 중심에 있지 않다는 점을 표시하는 것 같습니다. 당신은 내가 교체 한 응답을 http://jsfiddle.net/klaw/tQf9n/3/ – klaw