Open google maps from hyperlink

后端 未结 3 1267
面向向阳花
面向向阳花 2020-12-05 10:06

I am trying to design a webpage specially for android users so i was wondering if there is a hyper link format that can open up google maps just like the call function eg

3条回答
  •  一向
    一向 (楼主)
    2020-12-05 10:41

    I am going with @Mnemonic Flow

    • geo:latitude,longitude
    • geo:latitude,longitude?z=zoom
    • geo:0,0?q=my+street+address
    • geo:0,0?q=business+near+city

    Create your Uri

    Example

    Step 1 : Create link like

    Uri uri; 
    
    • geo:latitude,longitude

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

    • geo:latitude,longitude?z=zoom

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

    • geo:0,0?q=my+street+address

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

    • geo:0,0?q=business+near+city

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

    Step 1 Create method like below

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

    And Call like this

    showMap(uri);
    

    Step 2 : Add intent-filter in you manifiest file

    
        
            
            
            
        
    
    

提交回复
热议问题