Archive for July, 2010

Envato Birthday Bundle 2010, 400$ worth of files for just 20$

envato birthday bundle 2010

How to get GPS coordinates from Google Maps

In previous tutorial we made a simple google map in Flash. But how do we get desired coordinates of our location? You probably would like to show location of your company and set it as default map location. Getting coordinates is actually pretty simple.

Go to Google Maps and find the desired location. Now use right click and then select “center map here”. Now paste following code into browser URL:

javascript:void(prompt('',gApplication.getMap().getCenter()));

A pop up window with coordinates will appear. Just copy this coordinates and paste them to flash code:

map.setCenter(new LatLng(37.77114, -122.40159), 18, MapType.SATELLITE_MAP_TYPE);
var m:Marker = new Marker(new LatLng(37.77114, -122.40159),

coordinates for marker define exactly where marker of your location is placed.
And we’re done. Good luck using it in your projects.

Reading Google Maps API to Flash AS3

The use of google maps in flash AS3 is simple and straightforward.
First go to Google Maps API for Flash and download the zip file. Now extract the files and copy flash component file under lib directory to where you have flash installed (under component dir). Usually path is: C:\Program Files\Adobe\Adobe Flash CS4\language\Configuration\Components.
Now open Flash and go to components (window/components). You will see GoogleMapsLibrary under Google Maps API. Drag it to your library on stage.

Next you have to import neccessary classes:

import com.google.maps.*;
import com.google.maps.overlays.*;
import com.google.maps.controls.*;

Next step is definition of variables needed for map creation:

var map:Map = new Map();
map.key =
"ABQIAAAAqHHCopGV2FznT8V5ph6ELxShFIAhFb89IoGWiehHpBPf2E8vHxQ2wvPhcSdLLuc
6JxXYONuPAmqLRA";
map.setSize(new Point(stage.stageWidth, stage.stageHeight));
map.x = 0;
map.y = 0;
map.addEventListener(MapEvent.MAP_READY, onMapReady);

map.key defines the starting location of the map and can be found on google pages.
map.setSize defines the size of the map (in our case it is the size of the stage).
map.x and map.y define the position of map on stage.
Finally we add an event listener that will start a function to draw a map when map is ready.
In the end we add following code:

function onMapReady(e:Event):void
{
map.addControl(new ZoomControl());
map.addControl(new MapTypeControl());
map.setCenter(new LatLng(37.77114, -122.40159), 18, MapType.SATELLITE_MAP_TYPE);
var m:Marker = new Marker(new LatLng(37.77114, -122.40159),
new MarkerOptions({icon:new marker()}));
map.addOverlay(m);

}

All we have to do now is add map to the stage:

this.addChild(map);

Save and export movie and map with marker on Adobe location should appear.

Donation

Found information on this webpage useful? Donate a symbolic fee to keep this page runing:


Thank you!

Return top

Flash applications and animations is Digg proof thanks to caching by WP Super Cache