gpt4 book ai didi

javascript - 当我尝试使用 StageWebView 在 AIR Android 应用程序中实现 Google Maps JavaScript API 时,为什么会收到 "InvalidValueError"错误?

转载 作者:行者123 更新时间:2023-12-03 07:27:21 25 4
gpt4 key购买 nike

我正在开发一个 AIR Android 应用程序,我需要在其中实现 map 。环顾四周后,我决定使用 StageWebView 类的 Google Maps API for Javascript。当我运行该项目时,出现以下错误:

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 经验。我确实尝试过谷歌搜索,但这也无济于事。非常感谢任何帮助

最佳答案

如果您尝试在脚本异步应答器之前调用map.js。

一定会成功的

谢谢。

关于javascript - 当我尝试使用 StageWebView 在 AIR Android 应用程序中实现 Google Maps JavaScript API 时,为什么会收到 "InvalidValueError"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35946449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com