How to use Google Maps API with Flash AS3 – part 2
This time I am going to show you how to add to your Flash Google Map the controls you are used to see in all maps, such as map type, zoom and overview.
You will find, looking at this example and next ones, Google Maps can be customized in a wide range of ways.
Read How to use Google Maps API with Flash AS3 if you are new to Google Maps API for Flash.
This time the code is six lines longer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | package { import flash.display.Sprite; import flash.events.Event; import flash.geom.Point; 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.MapTypeControl; import com.google.maps.controls.ZoomControl; import com.google.maps.controls.OverviewMapControl; public class googlemap extends Sprite { var map:Map = new Map(); public function googlemap() { map.key="ABQIAAAAF5GHwa7hgxz5etSP-jJVwhSK_rP-_Usta8fEpiVtC50gLzF69hQ6_VK0zgpArekpmdsRCJK2Vnp60A"; map.setSize(new Point(stage.stageWidth, stage.stageHeight)); map.addEventListener(MapEvent.MAP_READY, onMapReady); this.addChild(map); function onMapReady(event:Event):void { map.setCenter(new LatLng(45.436319770227,12.33638048172), 13, MapType.SATELLITE_MAP_TYPE); map.addControl(new ZoomControl()); map.addControl(new OverviewMapControl()); map.addControl(new MapTypeControl()); } } } } |
Line 9: MapTypeControl provides a control for selecting and switching between supported map types via buttons. The classic Map, Satellite, Hybrid, Terrain menu.
Line 10: ZoomControl contains buttons for zooming the map in and out and a zoom slider.
Line 11: OverviewMapControl shows a small map in the corner of the containing map and displays a rectangle representing the containing map viewport. The rectangle can be dragged, or the overview map can be dragged to update the viewport.
Line 21: Adding the zoom control
Line 22: Adding the overview control
Line 23: Adding the map type control
And the map now looks like this one:
Next time we’ll see how to change the look of buttons and other visual tricks
They can be easily customized to meet the unique requirements of your project.
3 Responses to “How to use Google Maps API with Flash AS3 – part 2”
Leave a Reply
Trackbacks
-
Weekly Shared Items - 20. March, 2009 | toxin 2.0 - weblog of a german design student from wuerzburg on
March 20th, 2009 7:30 am
[...] How to use Google Maps API with Flash AS3 – part 2 [...]
- Citrus Engine released for free for learning
- My epic fail with ClickBank
- Get up to $100,000 for your next Flash game with Mochi GAME Developer Fund
- Create a dynamic content animated footer ad for your site in just 9 jQuery lines – 17 lines version
- Sell sitelocked version of your Flash games and even .fla sources to Free Online Games
- Protect your work from ActionScript code theft with SWF Protector
- Create a dynamic content animated footer ad for your site in just 9 jQuery lines
- Understanding Box2D’s one-way platforms, aka CLOUDS
- Triqui MochiAds Arcade plugin for WordPress upgraded to 1.2
- Box2D Flash game creation tutorial – part 2
- Create a Lightbox effect only with CSS - no javascript needed
- Flash game creation tutorial - part 1
- Create a Flash Racing Game Tutorial
- Flash game creation tutorial - part 2
- Make a Flash game like Flash Element Tower Defense - Part 2
- Flash game creation tutorial - part 3
- Make a Flash game like Flash Element Tower Defense - Part 1
- Create a flash draw game like Line Rider or others - part 1
- Triqui MochiAds Arcade plugin for WordPress official page
- Create a flash artillery game - step 1
- Flash game creation tutorial – part 5.2 (4.88/5)
- Create a flash artillery game – step 1 (4.79/5)
- Create a Flash Racing Game Tutorial (4.76/5)
- Create a survival horror game in Flash tutorial – part 1 (4.74/5)
- Create a flash artillery game – step 2 (4.74/5)
- Creation of a Flash arcade site using WordPress – step 2 (4.73/5)
- Flash game creation tutorial – part 1 (4.71/5)
- Flash game creation tutorial – part 2 (4.71/5)
- Create a flash draw game like Line Rider or others – part 1 (4.69/5)
- Creation of a platform game with Flash – step 2 (4.68/5)

(4 votes, average: 4.00 out of 5)



thank you for this tutorial but i have some problem with Google Map and Adobe AIR, when i create a file .air file with same code the map don’t load
Hi, awesome tutorial, i managed to create a flash swf with a google map. However i was wondering if i could add in a marker and zoom in to the location which is my LatLng . Thank you