javascript - 使用地理编码器获取纬度和经度,但经度和纬度不准确
问题描述
我首先使用 Place Autocomplete 来获取位置名称,例如 Paris。然后系统检索巴黎的地理位置。但检索到的地理位置是 -77.19452469999999 和 40.337568,这不是巴黎的坐标。
<form>
<div class=" search-container">
<input id="autocomplete" placeholder="Enter your address"
onFocus="geolocate()" type="text" style="width:50%; margin: 1%;" onchange="GetLatlong();" />
<input type="submit" class="btn-info" id="submit" name="submit" style="width:50%; margin: 1%; " />
</div>
</form>
这是Javascript代码
function GetLatlong()
{
var geocoder = new google.maps.Geocoder();
var address = document.getElementById('autocomplete').value;
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
//
window.location.href="http://localhost/disert/placesautocomplet/index.php?
longitude="+ longitude+"&latitude="+latitude;
alert(longitude);
alert(latitude);
}
});
}
我怎样才能得到正确的坐标而不是我得到的坐标。
解决方案
推荐阅读
- flutter - Flutter IOS上网
- linux - 如何从 http 请求中阻止端口服务器
- kotlin - 与 Eager 相比,使用延迟初始化有什么好处吗?
- bash - 使用 docker-compose run -rm 时的前缀
- wordpress - 工具,可以找到wordpress网站
- python - 为单元测试修补 python 类构造函数
- unity3d - 如何统一访问切片精灵?
- r - 如何根据自定义顺序对列进行排序?
- typo3 - Powermail (7.4.0) 默认验证码在 TYPO3 9.5.7 中不断失败
- javascript - sendRedirect() 不起作用,可能是因为调用 servlet 的方式(来自 jquery)