<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright 2009 James Richards
  Licensed under the Creative Commons Attribution 3.0 United States License:
    http://creativecommons.org/licenses/by/3.0/legalcode
  Portions of this work are based on the design of Pamela Fox's Google Code sample:
    http://gmaps-samples-flash.googlecode.com/svn/trunk/demos/CustomMapRoadTrip/srcview/index.html
  And are Copyright 2008 Google Inc. and licensed under the Apache License, Version 2.0:
    http://www.apache.org/licenses/LICENSE-2.0
-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
    xmlns:gm="com.google.maps.*"
    backgroundGradientColors="[0xFFFFFF, 0xAAAAAA]"
    height="100%" width="100%" viewSourceURL="srcview/index.html">
    <gm:Map id="map"
        width="100%" 
        height="100%" 
        key="(Your API Key Here)"
        mapevent_mapready="map_mapReady(event)" />
    
    <mx:Script>
        <![CDATA[
            import com.ags.tools.TileLayer;
            import com.google.maps.LatLng;
            import com.google.maps.Map;
            import com.google.maps.MapType;        
            import com.google.maps.controls.MapTypeControl;
            import com.google.maps.controls.OverviewMapControl;
            import com.google.maps.controls.PositionControl;
            import com.google.maps.controls.ScaleControl;
            import com.google.maps.controls.ZoomControl;
            import com.google.maps.interfaces.IMapType;
            import com.google.maps.overlays.TileLayerOverlay;
            
            private function map_mapReady(event:Event):void { 
                
                // Create custom tile layer
                var baseUrl:String = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Portland/ESRI_LandBase_WebMercator/MapServer";
                var copyright:String = "Taxlots, Zoning © Oregon METRO RLIS; Buildings © City of Portland Planning";
                var tileLayer:TileLayer = new TileLayer(baseUrl, 0, 19, copyright);
            
                // Create custom map type and add to map
                var mapType:IMapType = new MapType([tileLayer], map.MERCATOR_PROJECTION, "Land Base");
                map.addMapType(mapType);
                                
                // Add map controls
                var mtc:MapTypeControl = new MapTypeControl();
                map.addControl(mtc);
                var pc:PositionControl = new PositionControl();
                map.addControl(pc);
                var zc:ZoomControl = new ZoomControl();
                map.addControl(zc);
                var sc:ScaleControl = new ScaleControl();
                map.addControl(sc);
                var omc:OverviewMapControl = new OverviewMapControl();
                map.addControl(omc);
                
                // Initialize map. Use custom tile layer for the initial map type            
                map.setCenter(new LatLng(45.520211, -122.65553), 17, mapType);
            }
        ]]>
    </mx:Script>
    
</mx:Application>