Android - launch google map via web url

后端 未结 4 483
暖寄归人
暖寄归人 2020-12-04 14:35

On the iPhone, a maps.google.com URL is intercepted and loaded by the native google maps application. I would like do the same on Android, but Google Maps is being loaded in

相关标签:
4条回答
  • 2020-12-04 15:20

    At this moment I use a javascript function that change the following templates:

    'urlTemplates': {
                "default": "http://maps.google.com?q={streetAddress} {addressLocality} {addressRegion} {postalCode} {addressCountry}",
                "ios": "maps:?saddr=Current Location&daddr={streetAddress} {addressLocality} {addressRegion} {postalCode} {addressCountry}",
                "android": "geo:{streetAddress} {addressLocality} {addressRegion} {postalCode} {addressCountry}",
                "windows_phone7": "maps:{streetAddress} {addressLocality} {addressRegion} {postalCode} {addressCountry}",
                "windows_phone8": "bingmaps:?where={streetAddress} {addressLocality} {addressRegion} {postalCode} {addressCountry}",
                "blackberry": "javascript:blackberry.launch.newMap({'address':{'address1':'{streetAddress}','city':'{addressLocality}','country':'{addressCountry}','stateProvince':'{addressRegion}','zipPostal':'{postalCode}'}});"
    

    with what informations I got depending on the device, I do not remember from where I got all the templates and I am sorry for that, and after that I open the the address using window.location.href.

    Hope this will help you. Because at the time I need this I spent a lot of time researching it.

    0 讨论(0)
  • 2020-12-04 15:24
    <html>
      <body>
      <H1>
       <a href="geo:42,2?z=8">Click here for maps</a>
     </h1>
       <BR><BR>
       <a href="geo:53,-9?saddr=(53,-9)&daddr=(42,4)">Click here for route maps</a>
     </body>
    </html>
    

    The first click correctly loads the Google App on Android and zooms. In the second click I an trying to replicate a two point route (start address->destination address) and it doesn't seem to work.

    0 讨论(0)
  • 2020-12-04 15:26

    I really suffered a lot from this but finally got answer .
    Don't use href , it will not work .

    For Navigation - window.open("google.navigation:q=23.3728831,85.3372199&mode=d" , '_system');

    For Search - window.open("geo:0,0?q=pizza" , '_system');

    Read Here - https://developers.google.com/maps/documentation/android/intents

    0 讨论(0)
  • 2020-12-04 15:33

    Typing geo:0,0?q=google into the address bar opens the maps activity and searches for google nearby.

    I assume this will work from a link in a page, but haven't checked.

    a full list of accessible intents here: http://developer.android.com/guide/appendix/g-app-intents.html

    0 讨论(0)
提交回复
热议问题