Has some sample using Google Maps API

14 views
Skip to first unread message

RiverValadao

unread,
Sep 10, 2012, 5:16:11 PM9/10/12
to jsint...@googlegroups.com
I used Google Maps API for Flash it was discontinued, I would use JSInterface with Google Maps Javascript API V3 but am not having success. See my code below, after running the application with chromium 18.0.x( for linux) no map is displayed. In the javascript console is displayed the following message: Uncaught TypeError: Can not call method 'addDomListener' of undefined. Does anyone have any tips

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               minWidth="900" minHeight="600" creationComplete="creationCompleteHandler(event)"
               >
    <fx:Metadata>
        [SWF(width="700", height="500", backgroundColor="#F0F0F0")]
    </fx:Metadata>
    <fx:Script>
        <![CDATA[
            import aw.external.JSInterface;
            import aw.external.jsinterface.objects.JSDocument;
            import aw.external.jsinterface.objects.JSElement;                    

            protected const JS_GMAPS_API:String = "http://maps.google.com/maps/api/js?sensor=false&key=AIzaSyBaN8dAYRxMAQmdQvbc_eai9dpyOzTsB0k";
            protected const JS_FUNCTION:String = "functions.js";   
            protected const CSS_FILE:String = "main.css";
           

            protected function creationCompleteHandler(event:Event):void{
                JSInterface.initialize(this.systemManager.stage);           
                var document:JSDocument = JSInterface.document;
                var body:JSElement = document.body;
               
                var map_div:JSElement = document.createElement("div");
                map_div.id = "map_canvas";           
                body.appendChild(map_div);
                           
                JSInterface.loadCSS(CSS_FILE);               
                JSInterface.loadJavaScript(JS_GMAPS_API);
                JSInterface.loadJavaScript(JS_FUNCTION);                   
            }

        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
   
</s:Application>

--- javascript functions.js

var map = null;
function initialize() {
  var mapOptions = {
    zoom: 8,
    center: new google.maps.LatLng(-34.397, 150.644),
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  map = new google.maps.Map(document.getElementById('map_canvas'),
      mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
Reply all
Reply to author
Forward
0 new messages