如何使用地址打开Google地图(使用Intents或将Google地图添加到我的应用程序中)?我有地址,但我没有经度/纬度。我该怎么做?谢谢。如何使用地址打开Google地图?
回答
从我的个人代码库。 ;)
public static Intent viewOnMap(String address) {
return new Intent(Intent.ACTION_VIEW,
Uri.parse(String.format("geo:0,0?q=%s",
URLEncoder.encode(address))));
}
public static Intent viewOnMap(String lat, String lng) {
return new Intent(Intent.ACTION_VIEW,
Uri.parse(String.format("geo:%s,%s", lat, lng)));
}
您可以使用Google Geocoding API将您的物理地址转换为经度和纬度。 API将其返回到XML或JSON格式。你只需要解析数据来获取经纬度。接收到经纬度后,您可以在mapview上加载它。
地理编码API链接:
https://developers.google.com/maps/documentation/geocoding/
希望这有助于。
使用下面的代码,
String map = "http://maps.google.co.in/maps?q=" + str_location;
//其中str_location是地址字符串
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(map));
startActivity(i);
更改此URL的大胆部分公司地址。 http://maps.google.com/maps/geo?q=620 + 8 +大道+新+纽约,+ NY + 10018,+美国 &输出= CSV & OE:如果你有一个加号(+)字符替换所有的空格,但应与空间工作太这是最好的= utf8 & sensor = false
向上面的URL提出请求。欲了解更多信息,请参阅http://androidadvice.blogspot.in/2010/09/asynchronous-web-request.html
这将生成一个看起来像这样的代码:
200,8,40.7562008,-73.9903784
第一个数字200表示,该地址是好的。第二个数字8表示地址的准确度。最后两个数字,40.7562008和-73.9903784,是这个地址的经度和纬度。使用这些让你的谷歌地图工作。
注:以上步骤已经从http://webdesign.about.com/od/javascript/ss/add-google-maps-to-a-web-page_2.htm
复制2017年的建议是使用Google Maps URLs API,它提供通用的跨平台的网址,由谷歌的做法。您可以在您的意图中使用这些网址。从文件,例如URL的
例子:
https://www.google.com/maps/search/?api=1&query=centurylink+field
希望这有助于!
- 1. 使用JSON在部分视图中打开Google地图
- 2. 在地图上点击打开Google地图信息窗口
- 3. 展开Google地图图标大小
- 4. 如何使用RSelenium打开Google Chrome?
- 5. 如何在弹出窗口中打开Google地图链接?
- 6. 当您打开Google地图网址时,您如何默认行走路线?
- 7. 如何使用“maps:”方案打开Google地图应用程序?
- 8. 打开Google地图上的表格Javascript
- 9. 在特定设备上获取ActivityNotFoundException以打开Google地图
- 10. Android - 第二次打开Google地图v2或SupportMapFragment时出错
- 11. 当我打开Google地图时出现白框
- 12. 打开Google地图后GPS位置更新更准确吗?
- 13. 无法打开Google地图活动。 Android
- 14. 从地图标记打开Google方向转换为div
- 15. 无法在边栏列表中打开Google地图标记
- 16. 使用Iframe打开Google Play商店
- 17. Android:如何打开Google Map?
- 18. 如何在使用Browserify时公开Google地图的回调函数?
- 19. Cordova/Android:当物理邮寄地址被点击时,请勿打开Google地图
- 20. 如何使用Python打开Google Chrome并传入参数?
- 21. 鼠标按下时展开Google地图圈子
- 22. 如何在UIWebView中打开Google街景视图?
- 23. Firefox无法打开Google(sec_error_unknown_issuer)
- 24. 在Facebox中打开Google Map
- 25. 自动打开Google Apps脚本UI
- 26. 打开Google Compute Engine端口8000
- 27. 在Javascript中打开Google页面
- 28. 从VBA/Excel打开Google Chrome
- 29. 黑莓手机 - 在浏览器中打开Google地图时出错
- 30. 如何在iOS中使用方向和语音打开Google地图导航Url?