iOSで動作しないGoogle Maps API for Flashの回避策として、Flex Mobileアプリケーション内にGoogle Maps Javascript APIを搭載したStageWebViewをロードしようとしています。私はstageWebView.loadString()メソッドを使用しています。以下はHTML.Javascriptの関連部分です。Google Maps JS API v3がFlex Mobile内で読み込まれないStageWebView
私の問題は、これをブラウザ(IE、Chrome、Safari)とFlash Builder iPhone/iPadシミュレータで見るとすべてが完全に機能することです。実際のデバイスでは、マップはロードされませんし、いくつかのtry..catchステートメントでは、 "TypeError: '未定義'はコンストラクタではありません"というエラーが発生していることがわかりました。以下の初期化関数
何が間違っている可能性がありますか?
<!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が含まれるオブジェクトどのようにチェックしてMap
で、ブラウザに表示されたオブジェクトとは異なり、それを見つけて驚いた、Polyline
、Marker
、Geocoder
、そして他の子オブジェクトのホストiOS端末で表示されるバージョンは次のようになります。
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; }
}
なぜ異なるのですか? Maps APIを動作させるにはどうすればいいですか?
GoogleはFlash/Flex Maps APIをサポートしておらず、誰もがJS Maps APIを使用するように指示してくれたことは良い質問です。 –