从超链接打开谷歌地图

时间:2012-04-18 07:11:41

标签: android google-maps

我正在尝试专门为Android用户设计一个网页,所以我想知道是否有一个超级链接格式可以打开谷歌地图就像呼叫功能,例如

<a href="tel:0766551121"> Call me now </a>

3 个答案:

答案 0 :(得分:41)

如果通过“打开Goog​​le地图”表示原生Android Google地图应用程序而不是在Android浏览器中打开链接,那么根据Geo Intents,您可以使用以下Geo URI格式触发意图这将打开设备上的Google Maps应用程序到指定的位置或查询:

  • geo:纬度,经度
  • 地理:纬度,经度Z =变焦
  • 地理:0,0 Q =我+街道+地址
  • 地理:0,0 Q =业务+邻近+城市

对于Google街景,您可以使用:

  • google.streetview:cbll =纬度,经度和安培; CBP = 1,偏航,,俯仰,缩放&安培; MZ = mapZoom

有关可用选项的详细信息,请参阅the official Google Maps Intents documentation

答案 1 :(得分:9)

使用GEO URI在超级链接上打开地图,点击:

<a href="geo:37.786971,-122.399677;u=35">open map</a>

答案 2 :(得分:2)

我将使用@Mnemonic Flow

  • geo:纬度,经度
  • 地理:纬度,经度Z =变焦
  • 地理:0,0 Q =我+街道+地址
  • 地理:0,0 Q =业务+邻近+城市

创建你的Uri

示例

第1步:创建

之类的链接
Uri uri; 
  • geo:纬度,经度

    uri = Uri.parse("geo:47.6,-122.3")

  • 地理:纬度,经度Z =变焦

    uri = Uri.parse("geo:47.6,-122.3?z=11")

  • 地理:0,0 Q =我+街道+地址

    uri = Uri.parse("geo:0,0q=The+Eldorado+Park,+Rampar+Mota,+Gujarat,+India")

  • 地理:0,0 Q =业务+邻近+城市

    uri = Uri.parse("geo:0,0q=The+Eldorado+Park,+Rampar+Mota,+Gujarat,+India")

第1步创建如下方法

public void showMap(Uri geoLocation) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(geoLocation);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}

并像这样打电话

showMap(uri);

第2步:在最明显的文件中添加intent-filter

<activity YourActivity>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="geo" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>