2016-07-13 7 views
0

フロリダ州オーランドで設定した5マイルの範囲は、FLが機能していません。私は間違って何をしたのかよく分かりません。どんな助けでも大歓迎です。境界線がGoogle Places APIで動作しない

<input id="autocomplete" placeholder="Enter your address" type="text"></input> 

function initAutocomplete() { 

    //5 mile bounds around orlando, fl 

    var streetLng = -81.43061; 
    var streetLat = 28.56683; 

    var center = new google.maps.LatLng(parseInt(streetLat), parseInt(streetLng)); 
    var north = google.maps.geometry.spherical.computeOffset(center, 5, 0).lat(); 
    var east = google.maps.geometry.spherical.computeOffset(center, 5, 90).lng(); 
    var south = google.maps.geometry.spherical.computeOffset(center, 5, 180).lat(); 
    var west = google.maps.geometry.spherical.computeOffset(center, 5, -90).lng(); 
    var defaultBounds = new google.maps.LatLngBounds(new google.maps.LatLng(north, east), new google.maps.LatLng(south, west)); 

    new google.maps.places.Autocomplete(
    (document.getElementById('autocomplete')), { 
     componentRestrictions: { country: "us" }, types: ['address'], bounds: defaultBounds 
    }); 
} 

initAutocomplete(); 

https://jsfiddle.net/wybsfvLb/2/

おかげ

+0

のようになります。[このためのドキュメント](https://developers.google.com/places/web-service/autocompleteは)* *「これはにプレイスオートコンプリートサービスに指示することを言います*円**内の結果を表示することを好む*定義された領域外の結果が引き続き表示されることがあります。 "* –

+0

componentRestrictionsの下には、境界オプションがあります。 – Ryan

+0

はい、そうです。そしてドキュメンテーションはそれが命令ではなくヒント*であると言います。 –

答えて

0

私はdefaultBoundsを切り替えていました。コードは以下の

var defaultBounds = new google.maps.LatLngBounds(new google.maps.LatLng(south, west), new google.maps.LatLng(north, east)); 
関連する問題