How to set google map center and zoom level which all markers are visible... English Posting

OK, guys. Let me do simplest way. :-) Although I use jQuery, but it doesn't matter, does it?

//server side returns marker information by JSON type
function loadAllMarkers(url, target_map)
{
  jQuery.ajax({
    url: url,
    type: "get",
    dataType: "json",
    success: function(markers) {
      var bound = new GLatLngBounds();
      markers.each(function(marker) {
        var latlng = new GLatLng(marker.latitude, marker.longitude);
        bound.extend(latlng);
        target_map.addOverlay(new GMarker(latlng, {title:marker.name}));
      });
      target_map.setCenter(bound.getCenter());
      target_map.setZoom(map.getBoundsZoomLevel(bound));
    }
  });
}

트랙백

이 글과 관련된 글 쓰기 (트랙백 보내기)
TrackbackURL : http://classpath.egloos.com/tb/5032781 [도움말]

덧글

덧글 입력 영역


구글애드센스