您好,我们在带有 Flex 4.14.1 和 AIR 18 的 Apache AIR WindowedApplications 中使用 Google Maps JavaScript 库。
Google 地图位于一个 HTML 页面中,我们将它与 Flex StageWebView ( http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/StageWebView.html ) 集成到我们的 AIR 应用程序中。
我创建了一个简约的工作示例来重现该问题。
柔性:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
addedToStage="addedToStageHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected var stageWebView:StageWebView;
protected function addedToStageHandler(event:Event):void
{
stageWebView = new StageWebView();
stageWebView.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
stageWebView.stage = stage;
stageWebView.loadURL("file:\\C:/work/flex/MapTest/src/assets/googlemap.html");
stageWebView.addEventListener(ErrorEvent.ERROR, onWebViewError);
}
private static function onWebViewError(ev:Event):void
{
trace('Error' + ev);
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if (stageWebView)
stageWebView.viewPort = new Rectangle(0, 0, unscaledWidth, unscaledHeight);
}
]]>
</fx:Script>
</s:WindowedApplication>
包含为文件的 HTML 文件:\\C:/work/flex/MapTest/src/assets/googlemap.html:
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 8,
center: {lat: -34.397, lng: 150.644}
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?v=3&callback=initMap"
async defer></script>
</body>
</html>
如您所见,我们始终使用当前主要版本的谷歌地图(版本属性 v=3):<script src="https://maps.googleapis.com/maps/api/js?v=3&callback=initMap" async defer></script>
5 月 16 日,谷歌发布了 3.28 版作为主要版本。从那时起,我们在 StageWebView 内的地图初始化期间收到以下错误:
TypeError: Result of expression 'a.lat' [undefined] is not a function.
at https://maps.googleapis.com/maps/api/js?v=3&callback=initMap : 107
at https://maps.googleapis.com/maps/api/js?v=3&callback=initMap : 122
at https://maps.googleapis.com/maps/api/js?v=3&callback=initMap : 41
at https://maps.googleapis.com/maps/api/js?v=3&callback=initMap : 105
at https://maps.googleapis.com/maps-api-v3/api/js/28/18/intl/de_ALL/map.js : 61
at https://maps.googleapis.com/maps/api/js?v=3&callback=initMap : 93
at https://maps.googleapis.com/maps/api/js?v=3&callback=initMap : 107
at https://maps.googleapis.com/maps/api/js?v=3&callback=initMap : 53
at https://maps.googleapis.com/maps/api/js?v=3&callback=initMap : 107
at https://maps.googleapis.com/maps/api/js?v=3&callback=initMap : 55
at https://maps.googleapis.com/maps/api/js?v=3&callback=initMap : 107
at https://maps.googleapis.com/maps/api/js?v=3&callback=initMap : 32
由于我们几年来没有更改 Flex 地图集成,因此 google Map 版本 >= 3.28 的初始化过程必须打破地图才能加载到 StageWebView 内部。
到目前为止,我们已经尝试过:
- 直接在不同的浏览器中打开 HTML 页面 => 工作(见这里的例子)
- 更新到最新的 Flex 和 AIR 版本(4.16 和 AIR 25)=> 没有成功
- 降级到 Google Map v 3.27 (Frozen) => 当前解决方案,但一旦 v 3.29 成为主要版本就会中断
- 检查发行说明 => 没有重大更改
- 更改 Google Maps 初始化代码以使用 lat/lng 对象 => 不成功
- 在谷歌地图初始化代码中将 lat/lng 属性写为字符串 => 不成功
任何想法如何解决这个问题?