Google Maps Collaboration Using Google's New ActionScript API, Flex, and BlazeDS


Google recently released the Google Maps API for Flash. I took the opportunity to create a Google version of the MapRooms sample application I posted recently. MapRooms works like Chat Rooms. You can create a room, or join an existing one. In addition to chatting, MapRooms allows you to collaborate on a map: the application leverages the real time capabilities of BlazeDS or LCDS to provide map synchronization between users in the room, and allow you to “whiteboard” on top of a map.

Testing the hosted version

Disclaimer: I’m currently hosting the application on the server I use to host this blog (basic PHP and Tomcat hosting plan). I don’t know much about the characteristics of my server, but I’m probably sharing it with a few dozens of other domains and the resources allocated to me are obviously limited in that shared environment. This is clearly not the ideal environment to host a potentially large scale real time application and I’m investigating other hosting solutions. In the meantime, if you experience difficulties running the app, you can install it locally using the instructions provided below (in “Local installation instructions”). The hosted version tries to connect using RTMP by default (available only as part of LCDS) and falls back to “long AMF polling” or regular AMF polling if the RTMP connection fails.

  1. Access http://coenraets.org/apps/gmaprooms/gmaprooms.html on two different machines or in two browser windows on the same machine.
  2. Make sure you logon with two different user names and the same room name.
  3. Move the map in one browser and notice that the position of the map is synchronized in the other browser.
  4. You can also search an address in one browser and the resulting map position will appear in the two browsers.
  5. The zoom level and the map type are also synchronized between users.
  6. Click the “Whiteboard” button in one browser, pick a color to draw on the map (upper left corner), and start drawing.

Note: you can right-click the application and select View Source or click here to see the source code of the application.

Local installation instructions:

  1. Install BlazeDS. You can download the BlazeDS turnkey server (a version of Tomcat with BlazeDS preinstalled) here.
  2. Open {blazeds-install-dir}/tomcat/webapps/samples/WEB-INF/flex/services-config.xml and add an AMF long polling channel defined as follows:

    <channel-definition id="my-longpolling-amf" class="mx.messaging.channels.AMFChannel">
    	<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amflongpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
    	<properties>
    		<polling-enabled>true</polling-enabled>
    		<polling-interval-seconds>5</polling-interval-seconds>
    		<wait-interval-millis>60000</wait-interval-millis>
    		<client-wait-interval-millis>1</client-wait-interval-millis>
    		<max-waiting-poll-requests>200</max-waiting-poll-requests>
    	</properties>
    </channel-definition>
    

  3. Open WEB-INF/messaging-config.xml and add the following destination:

    <destination id="gmaprooms">
    	<properties>
    		<server>
    			<allow-subtopics>true</allow-subtopics>
    			<subtopic-separator>.</subtopic-separator>
    		</server>
    	</properties>
    	<channels>
    		<channel ref="my-longpolling-amf"/>
    		<channel ref="my-polling-amf"/>
    	</channels>
    </destination>
    

  4. (Re)start the BlazeDS turnkey server.
  5. Download the source code of the Google Maps Application here.
  6. Create a Flex Builder project for the Flex application (gmaprooms). Make sure you configure your Flex Builder project to work with BlazeDS. To read instructions on how to set up a Flex Builder project that works with BlazeDS, make sure your BlazeDS turnkey server is started, and click here.
  7. Download the Google Maps ActionScript 3 API here, and add the swc file in the libs folder of your project.
  8. Get a Google Maps API key and assign it to map.key in the initMap() function in MapArea.mxml.
  9. Compile the application.
  10. Open the Flex application in two browser windows (to simulate two users in different locations) and test the application as described above (in “Testing the hosted version”).



Comments

  1. Craig says:

    Way to go!

  2. Kenneth says:

    This is so cool!

  3. Mingo says:

    WOW !!! I love you , Christophe , really great Applications !!!

  4. Mingo says:

    it seems slow,very slow, i don’t know why ?

  5. christophe says:

    Mingo, I’m currently hosting the application on the server I use to host this blog (basic PHP and Tomcat hosting plan). I don’t know much about the characteristics of my server, but I’m probably sharing it with a few dozens of other domains and the resources allocated to me are obviously limited in that shared environment. This is clearly not the ideal environment to host a potentially large scale real time application and I’m investigating other hosting solutions. In the meantime, if you experience difficulties running the app, you can install it locally using the instructions provided below (in “Local installation instructions”).

  6. Pamela Fox says:

    This is ridiculously cool. The one thing I would say is that it’s not clear the difference between the “Shared map” and the “whiteboard” map.

    Also noticed that if I geocode after drawing, the drawing travels with me.

  7. Abhijeet says:

    That’s really looking cool, need to try it asap. Most probably tomorrow, feeling sleepy now.

  8. Kevin says:

    Please keep us updated with regard to your search for a good hosting environment. I’ve done a little googling and found only one webhost that advertises BlazeDS… Isn’t that the reason Adobe released BlazeDS? So web hosts would offer it as part of hosting solutions? I mean developers already have LCDS ES for development… ya know…

  9. Hi Christophe,
    I’ve ported your app to run on FMS/Wowza/Red5: http://www.flashcomguru.com/index.cfm/2008/7/7/map-rooms-ported

    Best wishes,

    Stefan

  10. Jan says:

    Hi Christophe,

    can you please post tha Java-Files for the Backend of this Application? This would help me to understand the communication between front- and back-end.

    Thanks
    Jan

  11. Heath Brown says:

    I really love your application look and feel. Where can I go to learn how to do that with Flex and AIR?

    I’ve got my setting for chrome to “none” but I still get standard borders and title bars from a windows application. How do I make it borderless like your cool looking apps?

  12. Güzel bilgiler…Teşekkürler…

  13. Christina says:

    Hi Christophe,

    I am trying to set up blazeDS on a remote server, and I am not sure how to configure the compiler (-services) and server settings (root folder) to make it work. I would appreciate any pointers you can give me. Thanks a lot!

    Christina

  14. Hi Christophe,

    this sounds to be a awesome Application.
    Is it possible to release a “just click an run for stupid users like me” version?

  15. Thank you for great information.

  16. Sreekanth says:

    Hi Christhope,

    This is really nice application.

  17. Pamela Fox says:

    Hey there–

    This is awesome. Would you be amenable to having it linked from the Maps API documentation?

    - pamela

  18. Cornflake says:

    That’s funny… The area I live in looks almost exactly like that. Street name is Canal St. instead Channel. :)

  19. Asha says:

    This is a great application. We are exploring the possibility of building something like this for our business. Are you available for phone consultation to guide us with the architecture and technology.

  20. Bing says:

    Hi,Christophe

    This application can be sync now. Can you fixed it? Because I want to demo it for others. Thanks.

  21. Perfect application, I love google maps

  22. Gummistiefel says:

    I’m not a developer and some of the discussion I had with MapQuest was too technical for me to entirely understand the full range of advantages of the new API. But, as mentioned, it appears to permit a new, richer generation of mashups to be born on using Flash and other Adobe platform tools.

  23. Hi there,
    I found great ideas on your Web site.
    Well done !
    Thanks for that and keep on doing
    Greetings from germany
    Thomas

  24. Sriram says:

    Hi..

    I tried the local installation instructions. the front-end login page loaded, but after that the page did not load…i tried multiple times, but faced the same issue. Any solution?

  25. Laura W says:

    I’m very impressed by this application. Any thoughts on making the free hand drawing geo-referenced?

  26. Gummistiefel says:

    Here is a tutorial to show how to install and use the MaxMind Database with PHP scripts examples. And it also shows how to display it on a map (Yahoo! Map) (french):
    http://www.flex-tutorial.fr/2009/02/01/flex-yahoo-maps-api-geo-localisation-par-ip-dun-visiteur-exemple/

  27. Henike99@girlsandnylons says:

    That’s good information: Om said Om don’t know much about the characteristics of his or her server but I’m probably sharing it with a few dozens of other domains and the resources allocated to him or her are obviously limited in that shared environment.

  28. matifbutt says:

    Hi I dont know, my first client browser working okay with second one but when I reply from second client to first, its not working.

    Any idea

  29. matifbutt says:

    Client one get the reply but slowly from Client 2. Is there any reason?

  30. nice one! But I still have the problem, that the API-Key is not working with Subdomains! I have to register new Keys for each Sub! Anyone any solutions?

  31. Marco Pe says:

    Hi activetraffic: I think that you have to stick with registering each subdomain – unless there is some sort of script to automate the process? Regards, Marco

  32. Вопрос к автору сайта, а вот у вас время у каждой статьи и в комментах пишется… Это какое? Московское? Заранее спасибо за ответ.

  33. has anyone any more informations on this “subdomain-issue”? because I´m facing the same problem!

    Best Regards
    Nico

  34. This is so cool! woow great Idea

  35. Hi activetraffic: I think that you have to stick with registering each subdomain – unless there is some sort of script to automate the process? Regards, :)

  36. Don says:

    Communication between rooms does not seem to be working at the moment

  37. I found the idea Wunderfull! Its nice

  38. Mike says:

    wow great!

  39. Would you be able to having it linked from the Maps API documentation?

  40. sgd says:

    I am using G Maps with Ruby on Rails and it works fine, now I will try it with flash and flex.

  41. Zauberer says:

    I love google maps on the iphone – but no flash is possible on the iphone

  42. Flash will probably never go to the iphone.
    But its not needed anyway.
    Nice article and thanks for sharing :)
    Greetings, Außenwerbung

  43. I tried the tutorial, great help. Thanks!

  44. wow, the tutorial actually helped me alot.
    thank you :)

  45. Whow! i have to try this very soon. brilliant idea!

  46. thats awesome. thanks..

  47. Thank you for the helpfull apllication!

  48. Peet says:

    Nice article! Thanks

  49. Volker says:

    Ein Kompliment für diese tolle Seite.
    Eigentlich bin ich durch Zufall darauf gestoßen und dachte mir,
    einen netten Eintrag und viele Grüße zu hinterlassen.
    _____ \\\!!!///____
    ______( ô ô )_____
    ___ooO-(_)-Ooo___
    Vielleicht schauen sie mal auf meiner Homepage vorbei!

  50. Whow! i have to try this very soon. brilliant idea

  51. Nice article! Thank you.

  52. Hardware says:

    I use BlazeDS to create exceptional rich applications with Flex and Java BlazeDS is a popular, open source web application that can successfully be deployed into a Java application server, making it an ideal option for Flex and Java integration. With this comprehensive resource, you’ll walk through the process of creating Rich Internet Applications (RIA) using BlazeDS. After a look at BlazeDS basics, the book then moves on to explain how to configure, customize, and extend BlazeDS in order to integrate with new and existing Java data sources and applications with Flex-based RIA. * Explains how to install BlazeDS from source as well as its compiled distributions * Demonstrates ways to make user interfaces engaging and effective * Introduces techniques for intercepting for control and management

  53. Poonam says:

    Hello,

    I have followed the steps to create the sample application of Google Map whiteboard , but I am getting the following error message when I click in “Join Room”

    [MessagingError message='Destination 'gmaprooms' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']

    Can you please help me in sorting out this please?

    Thanks
    Poonam Jaju
    poonam.mantri@gmail.com

  54. Great article! Thank you for posting. Best Regards from Germany :-)

  55. Netyu says:

    Great article :-) Thank you for posting and best regards!!!

  56. Great site, very interesting. Thanks

  57. Very helpful website. Wish I would have found this good one earlier. Just bookmarked…
    Shiatsu Massagesessel

  58. Vinothek says:

    nicely explained. thanks for the mini-tutorial

  59. Apply Gift says:

    Powerful post.

  60. Poster says:

    good old google is taking over :D

  61. Wish I would have found this good one earlier, very nice

  62. Great article! Thank you for posting. Best Regards from Germany :-)

  63. I read your article and thank you very much. I like it!

  64. Great article, I like it. Thanks

  65. Thanks for all the advice. Google rules… Sad but true. We got to play by the rules of the game.

  66. Zaubershop says:

    Well well, that’s the way time goes. Great post.

  67. Fantastic and thank you very much

  68. Frieden says:

    Very interesting. Since there’s such a thing as maps from google, I only calculate distances with it. I don’t use any other tools anymore.

  69. Zauberer says:

    Good article! I like it and will pass on recommendations for it!

  70. Thank you very much for your energy, worg . I founf your article with google and i like it!

  71. ehliyet says:

    The information will be useful to us in a nice sharing.

  72. konteyner says:

    its very nice and amazing project.

  73. Thank you for the useful information and article!

  74. çiçek says:

    Thanks you very much! Wonderful newletter!

  75. Zauberer NRW says:

    Very nice article. I like it. thank you so much.

  76. Wish I would have found these article sooner. Very Nice!

  77. Great site, very interetsing for me.

  78. Great site, very interesting and useful for me.

  79. konteyner says:

    I like the helpful info you provide in your articles. I’ll bookmark your blog and check again here regularly. I am quite certain I’ll learn many new stuff right here! Good luck for the next!

  80. poyraz says:

    Güvenlik Hizmetleri Kamera Alarm Sistemleri

    Güvenlik Hizmetleri | Özel Güvenlik | Kamera ve Alarm Sistemleri

  81. thanks for the mini-tutorial

  82. thanks

  83. I would like to express my appreciation to the writer just for rescuing me from this type of challenge. Because of surfing around through the the web and coming across opinions which were not helpful, I believed my entire life was gone. Living without the solutions to the difficulties you have solved as a result of your good website is a crucial case, and the ones that would have badly damaged my career if I hadn’t encountered your web blog. Your personal ability and kindness in maneuvering all areas was precious. I’m not sure what I would’ve done if I had not come across such a solution like this. I am able to at this time relish my future. Thank you so much for this impressive and result oriented help. I won’t be reluctant to propose your web site to any individual who should get tips on this subject.

  84. Vitamine says:

    I got what I was looking for. Thank you for this amazing post.

  85. Great site, very interesting for me.

Trackbacks

  1. [...] Coenraets, Senior Technical Evangelist chez Adobe, a développé à l’aide de cette API un outil de “cartes collaboratives” qui permet de commenter à plusieurs dans une “chat room” une carte Google Maps en lui ajoutant [...]

  2. [...] mashup avec Google Maps API Flash MapRooms est un mashup créé par Christophe Coenraets à partir de Google Maps API Flash. Il propose des "Chat Rooms" accompagnées [...]

  3. [...] nouvel API de google maps dédié à Flash simplifie la vie du développeur et voici cette démonstration avec BlazeDS, le serveur Adobe Open source de Push Data – c’est le serveur qui pousse les [...]

  4. aarpprovideronline…

    incumbent!therewith parenthetical,sophomores …

  5. [...] Google Maps Collaboration Using Google’s New ActionScript API, Flex, and BlazeDSa> [...]

  6. SOG knives says:

    SOG knives…

    Interesting ideas… I wonder how the Hollywood media would portray this?…

  7. gratis internet texas holdem…

    beggary aerials abolishers?electrocuting mainframe Demeter …

  8. [...] Links: The Google Maps Flash API An Example Application [...]

  9. [...] this year Christophe Coenraets, a colleague on the Platform Evangelism team, created an example application which combined Google’s ActionScript API, Flex and BlazeDS to provide a real-time [...]

  10. [...] this year Christophe Coenraets, a colleague on the Platform Evangelism team, created an example application which combined Google’s ActionScript API, Flex and BlazeDS to provide a real-time [...]

Speak Your Mind

*