open google maps through intent for specific location in android

后端 未结 12 1131
别那么骄傲
别那么骄傲 2020-11-30 20:17

I\'m designing one application in which I want to show specific location on Map. I\'m passing String of address which is already placed on Google Map

12条回答
  •  心在旅途
    2020-11-30 20:52

    As of 2020 you can also consider using Google Maps URLs, the API designed by Google in order to create universal cross-platform links. You can open Google maps on web, Android or iOS using the same URL string in form:

    https://www.google.com/maps/search/?api=1¶meters

    In case when you need show certain location you can use an URL like

    https://www.google.com/maps/search/?api=1&query=36.26577,-92.54324

    The code snippet is

    String url = "https://www.google.com/maps/search/?api=1&query="+address;
    Intent intent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse(url));
    startActivity(intent);
    

    I hope this helps!

提交回复
热议问题