muchas gracias.
// importamos las clases necesarias, están son las básicas para este ejemplo alcanzan. Al final del tutorial les dejo el link de las referencias para que puedan ver cada clase en particular.
import com.google.maps.LatLng;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapType;
import com.google.maps.controls.*;
import com.google.maps.LatLng;
//seteamos el ancho y alto de nuestra película
var ANCHO:int = stage.stageWidth;
var ALTO:int = stage.stageHeight;
//creamos nuevo objeto Map
var map:Map = new Map();
//aquí pegamos el código de la llave que sacamos en el primer paso
map.key = "ABQIAAAAco19XDqjzSl05LYPt6_fiBSIFCgsnuhPF9mJQjc-utfnmDYMNhSLDVzWYmrfQGMVO8sFKgYeaEe6TA";
//seteamos el alto y ancho del mapa
map.setSize(new Point(ANCHO, ALTO));
//agregamos un detector de evento para cuando se completo la carga
map.addEventListener(MapEvent.MAP_READY, onMapReady);
//cargamos el mapa a nuestra lista de visualización
this.addChild(map);
//este es un poniter que agregue yo, el que viene no me gusta
var pointer:Pointer = new Pointer();
this.addChild(pointer);
pointer.x = (ANCHO/2)-(pointer.width/2);
pointer.y = (ALTO/2)-(pointer.height/2);
pointer.alpha = 1;
//en este campo vamos a imprimir las coordenadas y zoom actuales, si comentan estas líneas pueden ocultar esta parte
var texto:TextField = new TextField();
var formatoTexto:TextFormat = new TextFormat();
this.addChild(texto);
formatoTexto.font = "Arial";
formatoTexto.size = 12;
formatoTexto.align = TextFormatAlign.LEFT;
formatoTexto.bold = true;
texto.multiline = true;
texto.background = true;
texto.autoSize = TextFieldAutoSize.LEFT;
texto.defaultTextFormat = formatoTexto;
//si se cargo todo bien ejecutamos!
function onMapReady(event:Event):void {
//centramos el mapa a las coordenadas deseadas (-31...,-64...) e indicamos el zoom (12) y tipo de mapa por defecto (MapType.NORMAL_MAP_TYPE)
map.setCenter(new LatLng(41.387917, 2.169919), 12, MapType.NORMAL_MAP_TYPE);
//mostramos el control de zoom
map.addControl(new ZoomControl());
//el control de posicion
map.addControl(new PositionControl());
//el selector de tipo de mapa
map.addControl(new MapTypeControl());
//el evento para reimprimir las coordenadas cuando desplazamos el mapa
map.addEventListener(Event.ENTER_FRAME,coordenadas);
}
//imprimimos las coordenadas en el campito de texto
function coordenadas(e:Event):void {
texto.text = "Lat/Lng: "+e.currentTarget.getCenter()+"\rZoom: "+e.currentTarget.getZoom() ;
texto.x = (ANCHO-texto.textWidth)-10;
texto.y = (ALTO-texto.textHeight)-10;
}
