// Import google maps,overlays, and controls.
import com.google.maps.*;
import com.google.maps.overlays.*;
import com.google.maps.controls.*;
// Declare a google maps variable. I called it gomap.
// You can name it whatever you want consitantly.
var gomap:Map = new Map()
gomap.key = "Insert your API Key between these quotation marks";
//Set map size.
gomap.setSize(new Point(400,280))
// Set map location.
gomap.x = 300
gomap.y = 60
// Add listener to trigger the MapEvent function.
gomap.addEventListener(MapEvent.MAP_READY, onMapReady);
// Add a child to populate the map to the stage when you publish out(F12).
this.addChild(gomap);
// Make the map run though a function.
function onMapReady(e:Event):void
{
/* next bring in control options. Further below is code for
navigation which has pan and last position as well as zoom. */
// To add the default simple ZoomControl...
//gomap.addControl(new ZoomControl());
/* or set the position of the zoom to specific coordinates.
There are four(4) anchor points of reference.
ANCHOR _TOP_LEFT,ANCHOR _TOP_RIGHT,ANCHOR _BOTOM_LEFT,and ANCHOR _BOTTOM_RIGHT. */
//var zoom_position:ControlPosition = new ControlPosition(ControlPosition.ANCHOR_TOP_LEFT, 420,100);
//var myZoomPos:ZoomControl = new ZoomControl();
//myZoomPos.setControlPosition(zoom_position);
//gomap.addControl(myZoomPos);
// Scroll zoom is disabled by default, but you can enabled it like this...
gomap.enableScrollWheelZoom();
// To add the default navigation control at default position...
//gomap.addControl(new NavigationControl());
// or position the navigation control to coordinates.
var nav_position:ControlPosition = new ControlPosition(ControlPosition.ANCHOR_TOP_LEFT, -60,40);
var myNavPos:NavigationControl = new NavigationControl();
myNavPos.setControlPosition(nav_position);
gomap.addControl(myNavPos);
// To add the default map view control buttons at default positions...
//gomap.addControl(new MapTypeControl());
// or set the position of the map view control buttons...
var view_position:ControlPosition = new ControlPosition(ControlPosition.ANCHOR_TOP_LEFT, 10,290);
var myViewPos:MapTypeControl = new MapTypeControl();
myViewPos.setControlPosition(view_position);
gomap.addControl(myViewPos);
/* Set the map center coordinates and starting view type to one of four(4)
basic map types... map(NORMAL),satellite(SATELLITE),hyrid(HYBRID),terrain(PHYSICAL)
Set the zoom with an integer placed between the coordinates and maptype. In this example
the zoom is set to 6 */
gomap.setCenter(new LatLng(51.144571,2.901592),14,MapType.PHYSICAL_MAP_TYPE);
/* To find exact LatLng... use google maps... zoom in, right click the spot you want and
select "What's here?" Latitude, Longitude will appear in the maps search bar */
// You can remove map view control buttons. In this example, the terrain map is removed
gomap.removeMapType(MapType.PHYSICAL_MAP_TYPE);
// Add a marker variable at specific Latititude and Longitude.
// This can be at the same or different coordinates than the setCenter LatLng.
var myMarker :Marker = new Marker(new LatLng(51.144571,2.901592),
/*
You can delete my marker from the Library and replace it with a custom movie clip.
Right click your graphic and Convert to Symbol. Make it a Movieclip.
Name it marker1. Open the library.(Ctrl L or F11)
In the Linkage section, select Export for Action Script and Export to Frame 1.
Select OK. An ActionScript Class Warning will appear: "A definition for this class..."
Select OK.
(You can also check it by selecting yor marker in the library list.(Ctrl L)
Right click in the list. Select properties. This opens the Symbol Properties.)
Important! Make sure that your marker points to the registry point!
(You can reopen it in the library(Ctrl L), click on the icon to make it editable and then
reposition it to point at the crosshairs which are the exact coordinates
for the LatLng.) This ensures it will be pointing to the right spot when you zoom.
*/
new MarkerOptions({icon:new marker1(),
// Turn marker shadow on and off with true or false values.
hasShadow: false}));
gomap.addOverlay(myMarker);
}
|