topical media & game development

talk show tell print

actionscript-map-google-map.mx

actionscript-map-google-map.mx [swf] flex


  <?xml version="1.0" encoding="utf-8"?>
  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
     creationComplete="onCreationComplete(event)" width="100%">
     <mx:Script>
     <![CDATA[
     
     import com.afcomponents.umap.gui.*;
     import com.afcomponents.umap.core.UMap;
     import com.afcomponents.umap.types.LatLng;
     import com.afcomponents.umap.providers.google.GoogleProvider; // not documented yet!
     import mx.core.UIComponent;
     
     private var map:UMap;
     
     public function onCreationComplete(event:Event) : void
     {
        var ref:UIComponent = new UIComponent();
         
        map = new UMap();
        map.setCenter(new LatLng(52.33313628963941, 4.865913391113281), 12);
        map.setZoom(14); // explicit
        map.setSize(this.width, this.height);
        
         
        ref.addChild(map);
        mapCanvas.addChild(ref);
  
  // define GoogleProvider with custom paths
  var settings:URLRequest = new URLRequest("http://umap.s3.amazonaws.com/assets/xml/GoogleSettings.xml?rand=" + Math.random());
  var language:URLRequest = new URLRequest("http://maps.google.com/maps?file=api&v=2")
  var copyright:URLRequest = new URLRequest("http://www.afcomponents.com/proxy/g_map_as3/copyright.php");
  map.setProvider (new GoogleProvider(false, settings, language, copyright));
  
        ref.focusManager.deactivate();
         
           map.addControl(new MapTypeControl());
           map.addControl(new ZoomControl());
           map.addControl(new PositionControl());
     }
     ]]>
     </mx:Script>
     
     <mx:VBox>
        <mx:Canvas id="mapCanvas" width="100%" height="100%" backgroundColor="#352D69" x="6" y="10"/>
     </mx:VBox>
  </mx:Application>
  


(C) Æliens 27/08/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.