1

場所 (都市または国) を入力し、情報ウィンドウが開いている場合、次のコードは、開いている情報ウィンドウの領域内の場所のみを検索します。

function codeAddress() {
var address = document.getElementById("address").value;
geocoder.geocode( { 'address': address}, function(results, status) {
  if (status == google.maps.GeocoderStatus.OK) {
    map.setCenter(results[0].geometry.location);
    map.fitBounds(results[0].geometry.viewport);
         } else {
    alert("Sorry, we couldn't find the location for the following reason: " + status);
  }
});

}

fitBounds なしで位置ビューポートにズームしたい

この種の作品:

map.setZoom(13);

しかし、ズームレベルを指定したくありません

後者のコードからのリンクは次のとおりです: http://www.hostelbars.com/map_test_v3_3.html

助けていただければ幸いです - ありがとう!

4

1 に答える 1

0

おそらく、開いている情報ウィンドウではなく、表示されているマップの境界にジオコーディングを制限したいですか?

結果を処理するときではなく、リクエスト内の目的の境界についてジオコーダーに通知する必要があります。

http://code.google.com/apis/maps/documentation/javascript/reference.html#GeocoderRequestを参照してください

geocoderRequestの境界をmap.getBounds()に設定します。

于 2012-01-03T23:59:53.503 に答える