Launch Google Maps app

后端 未结 2 946
小鲜肉
小鲜肉 2021-01-21 09:30

I\'m trying to launch Google maps from my application. I\'m using:

GeoPoint center = _mapView.getMapCenter(); 

Uri uri = Uri.parse(\"geo:\"+center.getLatitudeE         


        
相关标签:
2条回答
  • 2021-01-21 10:20

    Try to use:

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

    The geo: Uri format takes decimal latitude/longitude and not E6 format (degrees * 1E6).

    0 讨论(0)
  • 2021-01-21 10:25

    You need to divide by 1E6 since GeoPoint doesn't return a double.

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

    I like this way personally where daddr would be (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")));
    
    0 讨论(0)
提交回复
热议问题