使用StageWebView.loadString()来显示谷歌地图上的AIR for iOS的 [英] Using StageWebView.loadString() to display Google Maps on AIR for iOS

查看:757
本文介绍了使用StageWebView.loadString()来显示谷歌地图上的AIR for iOS的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用的StageWebView 显示使用JavaScript API生成一个谷歌地图的地图。还有一个原因,为什么它不会呈现在iOS?它适用于Android和在AIR模拟器,但不能在iOS设备上。我可以看到在Safari中产生的,太HTML,这使得它更奇怪。

I'm trying to use a StageWebView to display a Google Maps map generated using the Javascript API. Is there a reason why it won't render on iOS? It works on Android and in the AIR simulator, but not on iOS devices. I can view the HTML generated in Safari, too, which makes it even odder.

例如HTML(我是动态生成这种在应用程序,而不是它的问题):

Example HTML (I am dynamically generating this in-app, not that it matters):

<!DOCTYPE HTML>
<html style="width:100%; height:100%; margin: 0; padding: 0;">
    <head>
<title></title>
        <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script type="text/javascript">
        $(document).ready(function(e){
            var myLatlng = new google.maps.LatLng( 0,0);
            var mapOptions = {
                zoom: 18,
                center: myLatlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP,
                mapTypeControl: true,
                zoomControl: true,
                zoomControlOptions: {
                    style: google.maps.ZoomControlStyle.DEFAULT
                }
            }
            var map = new google.maps.Map(document.getElementById("maps") , mapOptions);
            geocoder = new google.maps.Geocoder();
            geocoder.geocode( { "address": "90 South Kyrene, Chandler, AZ 85226" }, function(results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    map.setCenter(results[0].geometry.location);
                    var marker = new google.maps.Marker({
                      map: map,
                      position: results[0].geometry.location
                    });
                }
            });
       });
    </script>
    </head>
    <body style="width:100%; height:100%; margin: 0; padding: 0;">
        <div id="maps" style="width:100%; height:100%;  margin: 0; padding: 0;"></div>
    </body>
</html>

我用 StageWebView.loadString(HTML,text / html的)加载; 。任何想法,为什么它没有呈现?加载网址似乎工作(所以我会尽量保存HTML到磁盘和装载,与其旁边)的罚款,只是没有使用loadString。

I'm loading it using StageWebView.loadString( html, "text/html" );. Any idea why it doesn't render? Loading URLs seems to work (so I will try saving the HTML to disk and loading that instead, next) fine, just not loadString.

在测试了这两种的iOS 6和iOS 7和AIR 3.8和3.9

Tested on both iOS 6 and iOS 7 and with AIR 3.8 and 3.9

编辑: 作为后续行动,保存HTML文件到磁盘,然后加载它通过 StageWebView.loadURL()工作得很好。不过好奇,为什么通过使用loadString加载()不工作,虽然。

As a follow up, saving the HTML file to disk and then loading that via StageWebView.loadURL() works just fine. Still curious why loading it via loadString() doesn't work, though.

推荐答案

我觉得已经去做与iOS的JavaScript沙箱和路的StageWebView API的工作。前一段时间我试图做与Twitter服务跳过销AUTH类似的东西,但似乎IOS不会让你从你的应用程序执行的JavaScript。

I think that has go to do with iOS javascript sandboxing and the way the StageWebView API works. A while ago i tried to do something similar with the twitter service to skip the pin auth, but it seems that ios won't let you execute javascript from your app.

您可以尝试使用本机的WebView扩展解决这个问题。 stagewebviewbridge 都有一个应与JavaScript的使用loadString方法。

You can try using a native webview extension to remedy this. stagewebviewbridge has a loadString method that should work with javascript.

您可以使用本机扩展做你的地图浏览。如果你的应用程序是IOS排他性的,你可以看看:空中地图 - 烷或者您可以使用 MapQuest的API 。我已经使用了安卓​​/ iOS应用程序和工作得很好。

You could use a native extension to do your map browsing. if your app is ios exclusive, you can check out: air-maps-ane or you can use the MapQuest API. i have used in a android/ios app and works very well.

这篇关于使用StageWebView.loadString()来显示谷歌地图上的AIR for iOS的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆