How embed Google Maps in Flex?


Google create a special API for Flash platform to make possible use them. I will show how write a simple application to find a place or route. At first we need a special key from Google for use the map (http://code.google.com/intl/pl/apis/maps/signup.html ). When we have the key we can start.

  1. add xmlns:maps=”com.google.maps.*” to Application tag
  2. import appropriate classes
  3. add map instance
  4. <maps:Map id="myMap" width="100%" height="100%"  key="[key from the google site]" mapevent_mapready="onMapReady(event)" url="[url to our site]"/>
  5. add functions
private function onMapReady(event:MapEvent):void {
	myMap.addControl(new MapTypeControl());							//add type of map control
	myMap.addControl(new ZoomControl());							//add zoom control
	myMap.enableScrollWheelZoom();								//enable mouse scrolling
	geocoder=new ClientGeocoder();								//create geocoder
	geocoder.addEventListener(GeocodingEvent.GEOCODING_SUCCESS, handleGeocodingSuccess);	//add listeners for geocoder
	geocoder.addEventListener(GeocodingEvent.GEOCODING_FAILURE, handleGeocodingFailure);
	dirs=new Directions();									//create directions
	dirs.addEventListener(DirectionsEvent.DIRECTIONS_SUCCESS, handleDirLoad);		//add listeners for directions
	dirs.addEventListener(DirectionsEvent.DIRECTIONS_FAILURE, handleDirFail);

}

private function handleDirLoad(evt:DirectionsEvent):void{
	var dirs:Directions=evt.directions; 							//create directions from event
	var startM:Marker;
	var endM:Marker;
	startM = new Marker(dirs.getRoute(0).startGeocode.point, new MarkerOptions());		//create start marker from directions instance
	endM = new Marker(dirs.getRoute(0).endGeocode.point, new MarkerOptions());		//create end marker from directions instance
	myMap.clearOverlays();									//clear map
	myMap.addOverlay(dirs.createPolyline());						//draw route on map
	myMap.addOverlay(startM);								//add start marker
	myMap.addOverlay(endM);									//add end marker
	myMap.setZoom(myMap.getBoundsZoomLevel(dirs.bounds));					//set appropriate zoom
	myMap.setCenter(dirs.bounds.getCenter());						//show route
}

private function handleDirFail(evt:DirectionsEvent):void{					//directions failure handler
	Alert.show("Unable to found route");
}

private function handleGeocodingSuccess(evt:GeocodingEvent):void{				//geocoding success handler
	var result:Placemark = GeocodingResponse(evt.response).placemarks[0];			//create result object
	myMap.setCenter(result.point, 14);							//show finding place
}

private function handleGeocodingFailure(evt:GeocodingEvent):void{				//geocoding failure handler
	Alert.show("Unable to found: " + evt.name);
}

This is one out of many things we can do with GoogleMaps API, including e.g. adding information and photos in concrete places on the map.

  1. #1 by a at September 11th, 2019

    Hello, I think your blog might be having browser compatibility issues.
    When I look at your blog in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up!
    Other then that, amazing blog!

  2. #2 by nike homme sock dart cargo kakinoirrotin 819686 300 at September 11th, 2019

    My family members every time say that I am killing my time here at net, however I
    know I am getting familiarity everyday by reading thes pleasant articles.

  3. #3 by bandar bola online indonesia at September 12th, 2019

    Thank you, I’ve just been searching for information about this subject for a while and yours is the greatest I’ve came upon till now.
    But, what in regards to the conclusion? Are you certain in regards to the supply?

  4. #4 by viking rasenmäher roboter test at September 14th, 2019

    Ich bin gerade zufaellig auf Ihrer Page gelandet (war auf der Suche nach einer anderen Homepage).
    Ich moechte diese websiete nicht verlassen, ohne Dir ein Lob
    zu dieser klar strukturierten und schick designten Page zu hinterlassen!

  5. #5 by 임팩트게임 at September 14th, 2019

    17 Superstars We’d Love to Recruit for Our 바카라 Team http://www.ssuncasino.com

  6. #6 by daftar poker terbaik at September 16th, 2019

    That is a great tip particularly to those fresh to the blogosphere.
    Brief but very accurate info… Many thanks for sharing
    this one. A must read article!

  7. #7 by Situs poker terbaik at September 16th, 2019

    What a data of un-ambiguity and preserveness of valuable experience
    on the topic of unexpected feelings.

  8. #8 by bandar qq pkv at September 16th, 2019

    Great beat ! I would like to apprentice whilst you amend your site, how can i subscribe for a weblog
    website? The account helped me a applicable deal. I had been tiny bit acquainted of this your broadcast offered shiny transparent concept

  9. #9 by คาสิโนออนไลน์ at September 17th, 2019

    Incredible points. Solid arguments. Keep up the amazing work.

  10. #10 by 허니게임 at September 18th, 2019

    루비게임 so crazy 모바일바둑이 http://www.mofg3.com

  11. #11 by 바둑이본사 at September 21st, 2019

    플라이게임 so wow 실전바둑이 http://www.mofg3.com

  12. #12 by 몰디브게임 at September 21st, 2019

    The 10 Scariest Things About 온라인바카라 http://www.ssuncasino.com

  13. #13 by Waldo at September 21st, 2019

    Wow, that’s what I was seeking for, what a information! existing here at this weblog, thanks admin of this web page.

  14. #14 by 원탁게임 at September 24th, 2019

    땡큐게임 so wow 바둑이주소 http://www.mofg3.com

  15. #15 by 色情剪辑 at September 24th, 2019

    I enjoy, lead to I found exactly what I was looking for.
    You have ended my four day lengthy hunt! God Bless you man. Have a nice day.
    Bye

  16. #16 by Shawn Ellis at September 25th, 2019

    Wonderful site. A lot of helpful info here. I am sending it to some friends ans additionally sharing in delicious. And of course, thanks on your sweat!

  17. #17 by https://liganike.com at September 28th, 2019

    Hurrah, that’s what I was looking for, what a stuff! present here at this web site, thanks admin of this web page.

  18. #18 by rayapoker8.com at September 29th, 2019

    hello!,I like your writing so a lot! percentage we keep up a correspondence extra
    about your article on AOL? I require a specialist in this space to
    solve my problem. May be that is you! Looking
    forward to look you.

  19. #19 by betta fish secrets at October 3rd, 2019

    Betta fish, also known as Betta Splendens and Siamese
    fighting fish can be popular pets because they are friendly, interactive
    which enable it to have low costs for maintenance and care.

  20. #20 by cookware at October 4th, 2019

    The true goal of cooking would be to nourish these marvelous bodies we are now living in, so they can grow and
    express vitality and strength, to help keep them healthy and capable
    to overcome environmental germs and bacteria.
    Summarized in a single word, the principle function of cooking is heath.

  21. #21 by Peaks at October 6th, 2019

    It’s impressive that you are getting thoughts from this piece of writing as well as from our argument made at this place.

  22. #22 by Emiko Hosten at October 12th, 2019

    funny 바카라사이트 우리바카라 스마트폰바카라

  23. #23 by https://www.tvboxsets.top at October 13th, 2019

    I take pleasure in, cause I fouund exactly what I used to be having a look for.
    You have ended my 4 day long hunt! God Bless you man. Have a nice day.
    Bye

  24. #24 by Fortnite free vbucks at October 15th, 2019

    The Simpsons: Tapped Out appears to be like nice.

  25. #25 by คาสิโนออนไลน์ at October 16th, 2019

    Thanks very interesting blog!

  26. #26 by Luis Holsten at October 21st, 2019

    Watch Out: How 바카라사이트주소 Is Taking Over and What to Do About It http://www.ssuncasino.com

  27. #27 by akun Id pro at October 23rd, 2019

    Now I am going away to do my breakfast, after having my
    breakfast coming over again to read additional news.

  28. #28 by chord lagu at October 23rd, 2019

    i there every one, here every person is sharing these knowledge, therefore it’s pleasant to read this webpage, and
    I used to pay a quick visit this website everyday.

  29. #29 by chord lagu at October 23rd, 2019

    including e.g. adding information and photos in concrete places on the map.

1 6 7 8
(will not be published)