我有一个代码,用于检索纬度和经度信息。我有兴趣在 map 上显示该信息。我想为谷歌地图创建一个链接,其中包含检索到的“经度”和“纬度”信息。我正在使用Linkify
为此,如下:
**** Java 代码**:
String text = "maps.google.com/?q=latitude,longitude";
TextView label = (TextView)findViewById(R.id.textView);
label.setText(text);
Pattern pattern = Pattern.compile("maps.google.com");
Linkify.addLinks(label, pattern, "http://");
但是这段代码不起作用。有人可以帮我写代码吗? 我收到类似以下内容的信息。我的经度和纬度未与网址的其余部分链接。
最佳答案
您可以使用下面的代码来显示 map
String url = "geo:" + sLatitude + "," + sLongitude +"?z=22&q="+sLatitude + "," + sLongitude;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
上面的代码显示了使用手机中安装的谷歌地图应用程序的 map ,它还标记了缩放级别为 22 的位置。无需谷歌地图 api key
希望这会有所帮助......
关于android - 使用纬度和经度信息创建 Google 位置 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15060867/