谷歌地图API的JS V3不会里面Flex移动的StageWebView加载加载、里面、地图、API

2023-09-09 21:51:04 作者:忘黎花落语樱尘

我试图加载一个Flex移动应用程序作为一种变通方法为Flash不工作在iOS上的谷歌地图API里的谷歌地图的JavaScript API一个的StageWebView。我现在用的是stageWebView.loadString()方法。下面是HTML.Jav​​ascript的相应和部分被加载。

I am trying to load a StageWebView with the Google Maps Javascript API inside a Flex Mobile application as a workaround for the Google Maps API for Flash not working on iOS. I am using the stageWebView.loadString() method. Below is the relevent portion of HTML.Javascript being loaded.

我的问题是,一切都完美的作品时,我认为这在浏览器(IE,Chrome和Safari)和Flash Builder的iPhone / iPad的模拟器。在实际设备中的地图永远不会加载,并通过一些在try..catch语句,我能够确定我得到类型错误:未定义不是构造函数的错误,这是由每个I列出里面的线甩初始化函数如下:

My issue is that everything works perfectly when I view this in a browser (IE, Chrome and Safari) and in the Flash Builder iPhone/iPad simulators. On the actual device the map never loads, and through some try..catch statements I was able to identify that I am getting "TypeError: 'undefined' is not a constructor" errors, which are thrown by each of the lines I listed inside the initialize function below.

什么可能会错误有什么想法?

Any thoughts on what may be going wrong?

  <!DOCTYPE html>
  <html>
    <head>
      <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
      <style type="text/css">
        html { height: 100% }
        body { height: 100%; margin: 0; padding: 0 }
        #map_canvas { height: 100% }
      </style>
      <script type="text/javascript"
        src="http://maps.googleapis.com/maps/api/js?v=3&key=MY_KEY&sensor=true">
      </script>
      <script type="text/javascript">
        /* a bunch of variables and functions */
        function initialize() {
          var myOptions = { center: new google.maps.LatLng(43.476302, -80.4816062), zoom: 12, mapTypeId: google.maps.MapTypeId.ROADMAP };
          map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
          geocoder = new google.maps.Geocoder();
          dirDisplay = new google.maps.DirectionsRenderer();
          /* some other stuff */
        }
        if(window.addEventListener) window.addEventListener("load", initialize, true); else window.onload = initialize;
      </script>
    </head>
    <body>
      <div id="map_canvas" style="width:100%; height:100%;" ></div>
      <div id="dirPanel" style="width:100%;" ></div>
    </body>
  </html>

编辑:我查了一下google.maps包含的对象,惊讶地发现,不同的对象出现在浏览器中,用地图折线标记地理codeR ,和许多其他子对象的,通过iOS设备psented的版本B $ P $是这样的:

I checked what the google.maps object contained and was surprised to find that unlike the object appearing on browsers, with Map, Polyline, Marker, Geocoder, and a host of other child objects, the version bpresented by the iOS device looks like this:

google.maps {
  modules:Object,
  Load:function (apiLoad) { delete google.maps.Load; apiLoad([/*lots of stuff I don't feel like copying out by hand*/], loadScriptTime); },
  _gjsload_:function (name, text) { modules[name] = text; }
}

有什么想法,为什么它是不同的?或者,我可以做些什么来获得地图API的工作?

Any thoughts as to why it is different? Or what I can do about it to get the Maps API to work?

推荐答案

通过亚历山大·法伯对this帖子,我决定使用的MapQuest的Flex /闪光灯移动的API ,该已被证明是非常有效的。

Through Alexander Farber's suggestion on this post, I decided to use MapQuest's Flex/Flash Mobile API, which has proven to be very effective.