Hi we're using Google Maps JavaScript Library inside of an Apache AIR WindowedApplications with Flex 4.14.1 and AIR 18.
The Google Map lives inside a HTML Page that we integrate in our AIR Application with Flex StageWebView (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/StageWebView.html).
I've created a minimalistic working example to reproduce the problem.
Flex:
<?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-File included as file:\\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>
As you can see we're always using the current major release of google maps (version attribute v=3): <script src="https://maps.googleapis.com/maps/api/js?v=3&callback=initMap" async defer></script>
On 16th of may google released version 3.28 as major release. Since then we get the following error during map initialization inside the 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
Since we did not change the Flex maps integration for several years, the initialization process of the google Map version >= 3.28 must break the map to load inside of the StageWebView.
What we've tried so far:
- Directly open the HTML Page in different Browsers => worked (see example here)
- Update to the most recent Flex and AIR versions (4.16 and AIR 25) => no success
- Downgrade to Google Map v 3.27 (Frozen) => current solution, but will break as soon as v 3.29 becomes major release
- Check the release notes => no breaking changes
- Change Google Maps init code to use lat/lng Object => no success
- Write lat/lng attribute in google Maps init code as Strings => no success
Any ideas how to solve this issue?