【发布时间】:2021-01-17 10:40:41
【问题描述】:
我正在尝试从 Google 地方信息中获取纬度、经度和时区(印度 5.30)。地址由自动完成填充,从而得到纬度和经度。但我无法获得时区。我正在正确获取纬度和经度。谁能帮我获取时区。我的代码如下:
HTML
<input id="address" type="text" placeholder="Enter address here" />
<div>
<p>Latitude:
<input type="text" id="latitude" readonly />
</p>
<p>Longitude:
<input type="text" id="longitude" readonly />
</p>
<p>Timezone:
<input type="text" id="timezone" readonly />
</p>
</div>
脚本
<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY&libraries=places"></script>
<script>
google.maps.event.addDomListener(window, 'load', initialize);
function initialize() {
var input = document.getElementById('address');
var autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.addListener('place_changed', function () {
var place = autocomplete.getPlace();
// place variable will have all the information you are looking for.
document.getElementById("latitude").value = place.geometry['location'].lat();
document.getElementById("longitude").value = place.geometry['location'].lng();
});
}
</script>
【问题讨论】:
-
谁能帮帮我?
-
看起来可能已更改为
utc_offset_minutes? utc_offset_minutes -
请让我检查一下
-
我尝试更改此“document.getElementById("utc_offset_minutes").value”,但它不起作用
-
是的,我明白了。但同样的结果。 :(
标签: javascript google-maps google-places-api