2010-03-31 101 views
2

我试图从我的应用程序启动Google地图。我使用的是:启动Google地图应用程序

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); 

我中心在纽约的某个地方的地图进行了测试,但谷歌地图打开,不集中在那里。 我遵循Android Developer的站点参考使用:“geo:latitude,longitude”模式。

,你看到打印日志:

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

任何人知道什么可能是问题吗?

回答

3

尝试使用:

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

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

+0

啊,你固定它。好。 – 2010-03-31 14:16:07

2

您需要除以1E6,因为GeoPoint不会返回一倍。

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

我喜欢这样亲自在那里DADDR将(center.getLatitudeE6()/1E6)+","+(center.getLongitudeE6()/1E6)

startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("http://maps.google.com/maps?f=d&saddr="+saddr+"&daddr="+daddr+"&hl=en"))); 
相关问题