如何在iPhone应用程序的UIWebView中加载谷歌街景?

发布于 2024-10-12 17:25:23 字数 159 浏览 4 评论 0原文

我正在尝试在我的应用程序中使用谷歌地图街景视图,因此我正在尝试在我的 Webview 中加载 html 文件。但需要Flash播放器才能显示街景。

需要 adobe flash 播放器吗?

有人知道如何在我们的 iPhone 应用程序中使用街景吗?

问候,

I am trying to use the google map street view in my app, so i am trying to load the html file in my Webview. but it is need the flash player to show the street view.

Is adobe flash player is required for this?

Anyone know how to use the street view in our iphone app?

Regards,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不弃不离 2024-10-19 17:25:23

是的,可以在 UIWebView 中加载 Google StreetView。这是加载 Google StreetView 的示例代码示例 -

let urlAddress = "http://maps.google.co.uk/maps?f=q&source=s_q&hl=en&geocode=&q=bran+castle&sll=44.439972,26.096894&sspn=0.000869,0.003664&ie=UTF8&hq=Bran+Castle&hnear=Bran+Castle,+Strada+General+Traian+Mo%C8%99oiu+nr.+28+E574,+Bran+507025,+Romania&t=k&layer=c&cbll=45.516381,25.368123&panoid=0d7jjq7vdWGTxFyonEKnBQ&cbp=12,209.81,,1,-18.52&ll=45.516381,25.368123&spn=0,0.008444&z=17";            
        
        let request = NSURLRequest(URL: NSURL(string: urlAddress)!)
        glWebView.loadRequest(request)

加载此街景后。 Google 会提醒您该 URL 仅属于 google 地图。要隐藏该警报消息,只需在您的 WebViewDidFinish 方法中添加以下 javascript 查询 -

webView.stringByEvaluatingJavaScriptFromString("document.getElementsByClassName('ml-unsupported-link-dialog-container')[0].style.display='none'")

Yes, it is possible to load Google StreetView in UIWebView. Here is a sample code example to load Google StreetView -

let urlAddress = "http://maps.google.co.uk/maps?f=q&source=s_q&hl=en&geocode=&q=bran+castle&sll=44.439972,26.096894&sspn=0.000869,0.003664&ie=UTF8&hq=Bran+Castle&hnear=Bran+Castle,+Strada+General+Traian+Mo%C8%99oiu+nr.+28+E574,+Bran+507025,+Romania&t=k&layer=c&cbll=45.516381,25.368123&panoid=0d7jjq7vdWGTxFyonEKnBQ&cbp=12,209.81,,1,-18.52&ll=45.516381,25.368123&spn=0,0.008444&z=17";            
        
        let request = NSURLRequest(URL: NSURL(string: urlAddress)!)
        glWebView.loadRequest(request)

After loading this streetView. Google will give you an alert that this URL is belongs to google map only. To hide that alert message just add this below javascript query in your WebViewDidFinish method -

webView.stringByEvaluatingJavaScriptFromString("document.getElementsByClassName('ml-unsupported-link-dialog-container')[0].style.display='none'")

Smile简单爱 2024-10-19 17:25:23

从技术上来说这是不可能的,但是如果您可以获得特定纬度和经度的全景图像 ID,那么这是可能的。在我之前的回答中,我说这是可能的,因为我知道该特定位置的全景图 ID。使用该代码,您可以在 UIWebview 中打开 steetview,但它会显示警告。通过触摸网络视图中的任何位置,该警告警报将会消失。

Google 引入了 SDK 来在您的 iOS 应用程序中加载街景,而不是离开您的应用程序。您需要做的就是使用 cocoa pods 添加“GoogleMaps”sdk,并运行下面的源代码来显示特定纬度和经度的谷歌街景。

let panoSvc = GMSPanoramaService()
            panoSvc.requestPanoramaNearCoordinate(CLLocationCoordinate2D(latitude: 32.847683, longitude: -96.771638), radius:100, callback: { (panorama, error) in
                if error == nil {
                    DispatchQueue.main.async(execute: {
                        let panoView = GMSPanoramaView(frame: .zero)
                        self.view = panoView
                        panoView.moveNearCoordinate((panorama?.coordinate)!, radius: 200)
                        print("Panorama ID: ", panorama?.panoramaID)
                        print("Panorama Co-ordinate: ", panorama?.coordinate)
                    })
                }
                else {
                    Utility.showCustomMsg(self.view, label: "Not Found", detailslbl:"Street View is not available for this location.", isSuccessImg: false, duration: 3)
                    {
                        self.navigationController?.popViewController(animated: true)
                    }
                }
            })

酷啊……感谢 Google 出色的员工。

Well technically it is not possible, but if you can get the panorama image id for that specific latitude and longitude, then it is possible. In my previous answer, I said it is possible as because I know the panorama id for that specific location. Using that code you can open steetview in your UIWebview, but it will show a warning. By touching anywhere in your webview will disappear that warning alert.

Bu Google introduce there SDK to load streetview in your iOS app, instead of leaving your app. All you need to do is add 'GoogleMaps' sdk using cocoa pods and run this below source code to display google Streetview for specific latitude and longitude.

let panoSvc = GMSPanoramaService()
            panoSvc.requestPanoramaNearCoordinate(CLLocationCoordinate2D(latitude: 32.847683, longitude: -96.771638), radius:100, callback: { (panorama, error) in
                if error == nil {
                    DispatchQueue.main.async(execute: {
                        let panoView = GMSPanoramaView(frame: .zero)
                        self.view = panoView
                        panoView.moveNearCoordinate((panorama?.coordinate)!, radius: 200)
                        print("Panorama ID: ", panorama?.panoramaID)
                        print("Panorama Co-ordinate: ", panorama?.coordinate)
                    })
                }
                else {
                    Utility.showCustomMsg(self.view, label: "Not Found", detailslbl:"Street View is not available for this location.", isSuccessImg: false, duration: 3)
                    {
                        self.navigationController?.popViewController(animated: true)
                    }
                }
            })

Cool huh...... Thanks goes to Google for their cool staff.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文