2

Googleマップを使用してさまざまな場所のリストを表示するアプリを開発しています。すべて正常に動作し、現在の場所と最も近い場所で作業しており、これを表示するためにズームしますが、ズームアウトするように設定するためにこれを変更しようとしました最も近い建物だけでなく、すべての建物を表示する

編集:これは作業コードです

// Sets the bounds of the map to include at lease one visable marker
function setBounds(){
if ( markerCluster.getMarkers().length > 0 && homeMarker != null){
    map.setZoom(17);
    var visableMarkers = markerCluster.getMarkers();
    // want to set the starting position at the homeMarker

    //Make an array of the LatLng's of the markers you want to show
    var LatLngList = new Array ();
    LatLngList.push(homeMarker.position);
    $.each(visableMarkers, function() {
        LatLngList.push(this.position);    
    });

    //  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); 
}
}
4

1 に答える 1

2

配列のコードLatLngListが正しくありません。

var LatLngList = new Array (new google.maps.LatLng (52.537,-2.061), new google.maps.LatLng (52.564,-2.017));
于 2012-04-23T16:34:26.143 に答える