0

私は AIR Android アプリケーションに取り組んでおり、マップを実装する必要がありました。いろいろ調べた結果、Google Maps API for Javascript を StageWebView クラスを使用して使用することにしました。プロジェクトを実行すると、次のエラーが発生します。

InvalidValueError: initMap is not a function
    at https://maps.googleapis.com/maps/api/js?     key=XXXXXXXXXX%20%20%20%20%20%20%20%20&libraries=visualization&callback=initMap : 87
 at https://maps.googleapis.com/maps/api/js?key=XXXXXXXXXX%20%20%20%20%20%20%20%20&libraries=visualization&callback=initMap : 123
 at https://maps.googleapis.com/maps/api/js?key=XXXXXXXXXX%20%20%20%20%20%20%20%20&libraries=visualization&callback=initMap : 21
 at https://maps.googleapis.com/maps/api/js?key=XXXXXXXXXX%20%20%20%20%20%20%20%20&libraries=visualization&callback=initMap : 123

HTMLは次のとおりです。

<!DOCTYPE html>
<html>
  <head>
    <style type="text/css">
      html, body { height: 100%; margin: 0; padding: 0; }
      #map { height: 100%; }
    </style>
  </head>
  <body>
    <div id="map"> </div>
    <script async defer
        src="https://maps.googleapis.com/maps/api/js?key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        &libraries=visualization&callback=initMap">
    </script>
    <script src="map.js"> </script>
  </body>
</html>

JS:

function initMap() {
  var map = new google.maps.Map(document.getElementById('map'), {
    center: {lat: 0, lng: 0},
    zoom: .3,
    styles: [{
      featureType: 'poi',
      stylers: [{ visibility: 'off' }]  // Turn off points of interest.
    }, {
      featureType: 'transit.station',
      stylers: [{ visibility: 'off' }]  // Turn off bus stations, train stations, etc.
    }],
    disableDoubleClickZoom: true
  });

     map.addListener('click', function(e) {
  var marker = new google.maps.Marker({
    position: {lat: e.latLng.lat(), lng: e.latLng.lng()},
    map: map
  });
console.log(e.latLng.lat(), e.latLng.lng());
});
}

AS3:

var webView:StageWebView;
var file:File = File.applicationDirectory.resolvePath("gmaps/gmaps.html");
var mapURL:String = file.nativePath;

webView = new StageWebView();
webView.stage = stage;
webView.viewPort = new Rectange(0, 0, stage.stageWidth, stage.stageHeight);
webView.loadURL(mapURL);

注: Chrome で gmaps.html ファイルを実行すると、問題なく動作します。

それで、問題は何ですか?JS/HTML の経験がないので、よくわかりません。私はグーグルを試みましたが、それもどこにも行きませんでした。どんな助けでも大歓迎です

4

1 に答える 1