Android Google Maps URL查询-离线时放置标记

问题描述 投票:1回答:1

我正在使用Google的published format for map URLs从我的Android应用启动以下意图:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com/maps/search/?api=1&query=51.196327,-7.325649")));

我要做的就是在查询位置将标记放置在地图上。当我在线时,它工作正常,但是如果我离线,我得到的只是一条[[无法连接消息。即使我拒绝了该消息,标记也不会出现。如果我下载要标记的区域的离线地图,甚至会发生这种情况。

脱机标记是我应用程序的重要组成部分,因此,即使无法加载下面的地图,我也想知道是否可以通过URL放置图钉吗?如果有一种方法可以仅放置标记并绕过任何本地搜索,那将是理想的选择。目前,Maps坚持在附近搜索不需要的东西。
java android google-maps url location
1个回答
2
投票
实际上可以通过移动设备离线在Google地图中放置和显示标记。

您可以使用其custom url scheme

Uri gmmIntentUri = Uri.parse("geo:51.196327,-7.325649?q=51.196327,-7.325649"); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); if (mapIntent.resolveActivity(getPackageManager()) != null) { startActivity(mapIntent); }

geo:之后设置中心坐标,然后q参数将执行搜索(就像您正在做的那样),如果将坐标设置为搜索参数,它将在其中显示标记。] >

kotlin

中的相同示例:val gmmIntentUri = Uri.parse("geo:51.196327,-7.325649?q=51.196327,-7.325649") val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) mapIntent.setPackage("com.google.android.apps.maps") if (mapIntent.resolveActivity(packageManager) != null) { startActivity(mapIntent) }
如果您未在该设备上安装google maps应用,则可以提供其他条件来执行某些操作。
© www.soinside.com 2019 - 2024. All rights reserved.