2014-06-16 2 views
0

주소의 마커가 확대됩니다. 단일 마커에 대해 확대/축소를 더 멀리하려면 어떻게합니까? 누구라도 도움이된다면 정말 좋을 것입니다! 여기 JavaScript가 있습니다. 어떤 도움 주셔서 감사합니다Google지도의 아이콘 위치 확대/축소를 변경 하시겠습니까?

$('#map_here').prepend('<div id="map"></div>'); 
     $(".static_map").remove(); 

    var map; 
    var bounds; 
    var geocoder; 
    var center; 

    function initialize() { 
     var mapOptions = { 
      center: new google.maps.LatLng(-34.397, 150.644), 
      zoom: 5 
     }; 
     map = new google.maps.Map(document.getElementById("map"), 
     mapOptions); 
     geocoder = new google.maps.Geocoder(); 
     bounds = new google.maps.LatLngBounds(); 
    } 
    function addMarkerToMap(location){ 
     var marker = new google.maps.Marker({map: map, position: location}); 
     bounds.extend(location); 
     map.fitBounds(bounds); 
    } 
    initialize(); 

    $("address").each(function(){ 
     var $address = $(this); 
     geocoder.geocode({address: $address.text()}, function(results, status){ 
      if(status == google.maps.GeocoderStatus.OK) addMarkerToMap(results[0].geometry.location); 
     }); 
    }); 

    google.maps.event.addDomListener(map, "idle", function(){ 
     center = map.getCenter(); 
    }); 

    $(window).resize(function(){ 
      map.setCenter(center); 
     });    

답변

0

발견 된 것. map.fitBounds (bounds); 앞에이 코드를 추가했습니다. 작동했습니다 :

google.maps.event.addListenerOnce(map, 'bounds_changed', function(event) { 
    if (this.getZoom() > 15) { 
      this.setZoom(15); 
    } 
}); 
관련 문제