URL scheme for the Google Street View App (Not Google Maps)

前端 未结 1 787
温柔的废话
温柔的废话 2021-01-17 10:31

I\'m using Google Cardboard with the Street View App. I want to be able to create a link that sends users directly into the Street View App to view a specific location.

相关标签:
1条回答
  • 2021-01-17 11:24

    You can launch the Google Maps for iOS application in street view mode with the comgooglemaps URL Scheme by setting the mapmode parameter to streetview.

    Objective c

     if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"comgooglemaps://"]]) {
    
           [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"comgooglemaps://?center=46.414382,10.013988&mapmode=streetview"]]];    
      }
    

    Swift 4

    if UIApplication.shared.canOpenURL(URL(string: "comgooglemaps://")!) {
    
    
       guard let url = URL(string: "comgooglemaps://?center=46.414382,10.013988&mapmode=streetview") else {
                return //be safe
            }
    
        if #available(iOS 10.0, *) {
            UIApplication.shared.open(url, options: [:], completionHandler: nil)
        } else {
            UIApplication.shared.openURL(url)
        }
    
     }
    

    & more details here on Google Streetview.

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