<bdo id='gmefP'></bdo><ul id='gmefP'></ul>

        <legend id='gmefP'><style id='gmefP'><dir id='gmefP'><q id='gmefP'></q></dir></style></legend>
      1. <tfoot id='gmefP'></tfoot>
        <i id='gmefP'><tr id='gmefP'><dt id='gmefP'><q id='gmefP'><span id='gmefP'><b id='gmefP'><form id='gmefP'><ins id='gmefP'></ins><ul id='gmefP'></ul><sub id='gmefP'></sub></form><legend id='gmefP'></legend><bdo id='gmefP'><pre id='gmefP'><center id='gmefP'></center></pre></bdo></b><th id='gmefP'></th></span></q></dt></tr></i><div id='gmefP'><tfoot id='gmefP'></tfoot><dl id='gmefP'><fieldset id='gmefP'></fieldset></dl></div>

        <small id='gmefP'></small><noframes id='gmefP'>

      2. 将从应用程序获取的地理位置传递给 UIWebView

        时间:2023-09-01

            <legend id='39irp'><style id='39irp'><dir id='39irp'><q id='39irp'></q></dir></style></legend>
              • <bdo id='39irp'></bdo><ul id='39irp'></ul>
                <tfoot id='39irp'></tfoot>
                • <i id='39irp'><tr id='39irp'><dt id='39irp'><q id='39irp'><span id='39irp'><b id='39irp'><form id='39irp'><ins id='39irp'></ins><ul id='39irp'></ul><sub id='39irp'></sub></form><legend id='39irp'></legend><bdo id='39irp'><pre id='39irp'><center id='39irp'></center></pre></bdo></b><th id='39irp'></th></span></q></dt></tr></i><div id='39irp'><tfoot id='39irp'></tfoot><dl id='39irp'><fieldset id='39irp'></fieldset></dl></div>
                    <tbody id='39irp'></tbody>

                • <small id='39irp'></small><noframes id='39irp'>

                  本文介绍了将从应用程序获取的地理位置传递给 UIWebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在开发 iOS 应用程序,我想在其中一个视图中包含 UIWebView 和包含地图的页面(地址是:https://carsharing.mvg-mobil.de).该网站需要位置许可,因此一旦用户看到此视图,就会出现一条警报:https://carsharing.mvg-mobil.de/ 想使用您当前的位置.OK/不允许".

                  I'm developing the iOS app and in one of the views I would like to include UIWebView with a page that contains a map (the address is: https://carsharing.mvg-mobil.de). The website requires location permission so as soon as the user is presented with this view, an alert appears: "https://carsharing.mvg-mobil.de/ would like to use your current location. OK/Don't allow".

                  在我的应用程序中,我从 CoreLocation 框架中获取了用户的位置.有没有办法将此位置传递给此 web 视图以避免此警报视图?是否可以通过注入一些 JavaScript 代码或者以某种方式在 URL 中包含地理位置?

                  In my app I have the location of the user fetched from the CoreLocation framework. Is there a way to pass this location to this webview to avoid this alert view? Would it be somehow possible by injecting some JavaScript code or maybe somehow including geolocation in the URL?

                  推荐答案

                  好的,我在PhoneGap 如何使用从 CoreLocation 获取的位置将 JavaScript 代码注入标准 webview:

                  OK, I found the solution in the source code of PhoneGap how to inject JavaScript code to a standrad webview with the location fetched from CoreLocation:

                  int epoch = [newLocation.timestamp timeIntervalSince1970];
                  float course = -1.0f;
                  float speed  = -1.0f;
                  NSString* coords =  [NSString stringWithFormat:@"coords: { latitude: %f, longitude: %f, altitude: %f, heading: %f, speed: %f, accuracy: %f, altitudeAccuracy: %f }",
                                          newLocation.coordinate.latitude,
                                          newLocation.coordinate.longitude,
                                          newLocation.altitude,
                                          course,
                                          speed,
                                          newLocation.horizontalAccuracy,
                                          newLocation.verticalAccuracy
                                       ];
                  
                  NSString * jsCallBack = [NSString stringWithFormat:@"navigator.geolocation.setLocation({ timestamp: %d, %@ });", epoch, coords];
                  
                  [webView stringByEvaluatingJavaScriptFromString:jsCallBack];
                  

                  希望其他人也可以从这段代码中获利.

                  Hopefully somebody else can profit from this code as well.

                  这篇关于将从应用程序获取的地理位置传递给 UIWebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:iOS 6 自动暂停不起作用 下一篇:如何在 Android 中获取位置管理器的最后一个已知

                  相关文章

                  最新文章

                    • <bdo id='rLnPV'></bdo><ul id='rLnPV'></ul>

                    <tfoot id='rLnPV'></tfoot>

                      <i id='rLnPV'><tr id='rLnPV'><dt id='rLnPV'><q id='rLnPV'><span id='rLnPV'><b id='rLnPV'><form id='rLnPV'><ins id='rLnPV'></ins><ul id='rLnPV'></ul><sub id='rLnPV'></sub></form><legend id='rLnPV'></legend><bdo id='rLnPV'><pre id='rLnPV'><center id='rLnPV'></center></pre></bdo></b><th id='rLnPV'></th></span></q></dt></tr></i><div id='rLnPV'><tfoot id='rLnPV'></tfoot><dl id='rLnPV'><fieldset id='rLnPV'></fieldset></dl></div>

                      <small id='rLnPV'></small><noframes id='rLnPV'>

                    1. <legend id='rLnPV'><style id='rLnPV'><dir id='rLnPV'><q id='rLnPV'></q></dir></style></legend>