android - 启动谷歌地图应用

标签 android google-maps android-intent

我正在尝试从我的应用程序启动 Google map 。我正在使用:

GeoPoint center = _mapView.getMapCenter(); 

Uri uri = Uri.parse("geo:"+center.getLatitudeE6()+","+center.getLongitudeE6()); 

Log.d(LOG_TAG, "Launching Google Maps with Uri: ("+uri+")"); 
Intent intent = new Intent(Intent.ACTION_VIEW, uri);

startActivity(intent); 

我用一张以纽约某处为中心的 map 对其进行了测试,但 Google map 打开时并未以该处为中心。 我按照 Android 开发人员的网站引用使用:“geo:latitude,longitude”模式。

你看到打印的日志:

Launching Google Maps with Uri: (geo:40763500,-73979305) 

谁知道可能是什么问题?

最佳答案

尝试使用:

Uri uri = Uri.parse("geo:"+(center.getLatitudeE6()/1E6)+","+(center.getLongitudeE6()/1E6)); 

geo: Uri格式采用十进制纬度/经度而不是 E6 格式(度 * 1E6)。

关于android - 启动谷歌地图应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2553251/

相关文章:

android - JavaCV - 渲染到 GL 表面

android - 如何管理 LVL 无证响应?

javascript - VueJS Google 放置自动完成功能

php - 如何使用 Google Maps API 根据距离进行搜索?

android - 如何获得所有系统包 Intent 的通知——无论我的应用程序是否正在运行,当这些 Intent 被触发时

android - Gradle 构建 Android 项目 "Could not resolve all dependencies"错误

java - SSL 证书过期异常

android - Google Activity Recognition 是否适用于旧版 Android?

android - 如何获取所有提供具有特定模式的 Intent 的应用程序?

android - 将单选按钮值 "int"保存到共享首选项中