0
私はアドレスを入力する前にgoogle address auto complete apiを使用しています。私はセッションでジオロケーションを設定しています。それはうまく動作しますが、円オブジェクトの引数については、 "位置"は、位置が定義されていないというjavascriptエラーが発生します。これをどうすれば回避するのですか?現在の場所を設定すると、位置は未定義に戻ります
function geolocate() {
if (navigator.geolocation && !sessionStorage.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
sessionStorage.geolocation = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
});
}
var circle = new google.maps.Circle({
center: sessionStorage.geolocation,
radius: position.coords.accuracy
});
autocomplete.setBounds(circle.getBounds());
}