Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 用一个位置发送到谷歌地图_Android_Eclipse_Google Maps_Coordinates - Fatal编程技术网

Android 用一个位置发送到谷歌地图

Android 用一个位置发送到谷歌地图,android,eclipse,google-maps,coordinates,Android,Eclipse,Google Maps,Coordinates,我正在开发一个Android应用程序,我需要给用户指明到达某些地方的方向。我有这些地方的坐标,但我发现很难获得用户的当前位置,为了绕过这个问题,我想知道我是否可以将用户发送到谷歌地图,只显示他想要到达的地方的坐标,谷歌地图会给用户提供正确的方向吗?或者我必须指定他的位置吗?我刚刚发现了一个黑客程序,可以实现您的目标 String directionsUrl = "https://www.google.co.in/maps/dir/'" + sourceLat + "," + sourceLng

我正在开发一个Android应用程序,我需要给用户指明到达某些地方的方向。我有这些地方的坐标,但我发现很难获得用户的当前位置,为了绕过这个问题,我想知道我是否可以将用户发送到谷歌地图,只显示他想要到达的地方的坐标,谷歌地图会给用户提供正确的方向吗?或者我必须指定他的位置吗?

我刚刚发现了一个黑客程序,可以实现您的目标

String directionsUrl = "https://www.google.co.in/maps/dir/'" + sourceLat + "," + sourceLng + "'/'" + destLat + "," + destLng + "'/";
然后使用意图打开URL

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(directionsUrl));
startActivity(intent);

然后Android将提供可以执行该操作的应用程序列表,然后只需选择谷歌地图即可。

这将对您有所帮助

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("http://maps.google.com/maps?saddr=srclatitude,srclongitude&daddr=destlat,destlong"));
startActivity(intent);

谢谢我希望Google Maps本身能够获取用户当前位置,但没问题,我会找到一种方法获取位置并将其传递给stringI。我认为使用LocationManager类获取当前位置信息应该不会有太多问题。绘制路线是比较棘手的一点。