spring - Google Maps API 在 Chrome 和 RestTemplate 之间具有不同的结果
问题描述
该服务正在使用 google maps api ( geocode )。
当我使用 spring resttemplate 的默认 bean 配置执行 GET 时,我的值与在 Web 浏览器 (Chrome) 上执行此 GET 时不同。
调用 Chrome 并使用 resttemplate:
当我执行反向地理编码时,chrome 执行更加精确。
结果: 铬:
location: {
lat: -23.5577251,
lng: -46.5948733
},
休息模板:
location: {
lat: -23.5574375,
lng: -46.5948733
},
我试过使用 Double、Float 和 BigDecimal。我尝试在序列化之前创建一个反序列化器来获取这个值,但是值是一样的。
我正在使用 Java 8 和 Spring Boot 2.0.3。
有人知道如何准确吗?
解决方案
我正在使用 UriComponentsBuilder ,当我使用 toUriString 时,url 被格式化为浏览器,并且无法正常工作。
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(googleHost)
.queryParam("key", apiKey)
.queryParam(input, address)
.queryParam("language", language);
它现在正在使用 StringUtils.join(...) 来构建 URI。
String googleurl = StringUtils.join(googleGeocodingHost,
"?key=", apiKey, "&", input, "=", address, "&language=", language);
推荐阅读
- php - 在 PHP 中显示来自数据库的 Youtube 视频
- c - 分段错误错误 - C 中的二叉搜索树
- python-3.x - pip 安装私有 Github 存储库的简单方法?
- spring-boot - 如何使用 Google OAuth2 进行注销?
- firebase - 递归获取用户列表 [Firebase + Saga]
- c++ - 将图链接到自身的副本并运行约束 dijkstra C++
- mongodb - MongoDB聚合框架在查找时非常慢
- python - 是否有一个 Excel 函数来查找而不是在第一次匹配时停止但查找所有值(日期)并在匹配某个日期时返回“是/否”
- javascript - gun.js 中的两种不同形式
- html - 为什么我的图片在 Safari 上可以向右旋转 45 度,而在其他浏览器上却不行?