You can mix DHTML and Flex in one page without too much effort. Here is how you do this:
- Add a DIV for the DHTML element that you wish to include after the embed Flash tags.
- Include the Google Map JavaScript as before in your HTML
- Add JavaScript methods that you wish to call from Flex
- In your Flex application, you can call these JavaScripts using the
navigateToURLmethod. For example, as you move the mouse over the chart, thechartToolTipmethod is called which in turn updates the map.private function chartToolTip(e:HitData) : String { var s:String; s = "'" + LineSeries(e.element).displayName + "\n"; s += "Time: " + e.item.x + " decimal hours\n"; s += "Elevation: " + e.item.y + " meters\n"; s += "Latitude: " + e.item.lat + " degrees\n"; s += "Longitude: " + e.item.lon + " degrees\n"; var u:URLRequest = new URLRequest("javascript:centerMap('" + e.item.lat + "','" + e.item.lon + "')"); navigateToURL(u,"_self"); return s; }
My Route Player is no where near complete yet, but now at least I have some of the answers on how I will use Flex and Google maps to create this player. The code for this player is here. See also this article which may give you clues on how you could “embed” Google Map in a Flex control.
You can also overlay a Flex control on top of DHTML based Google map. Click here for details. Here is an example of a Flex overlay.
November 22, 2007 at 5:28 am |
[...] The code for this example is here. Click here to see this Flex/HTML integration in action. See also this blog [...]
January 8, 2008 at 8:47 pm |
[...] Elevation Chart in Flex with Google Maps [...]
February 15, 2008 at 3:38 pm |
Very slick example.. the only two times I have been to the Monterey area were on bicycle… the route profile takes on a whole new meaning when you are pedaling or hiking it. I am also interested in the code, will digest this in a bit. Thanks.
April 17, 2011 at 2:19 am |
Dear,
Occurs a error this line :
private function chartToolTip(e:HitData) : String {
Error : Type Was Not found or was not a compile-time constant:HitData
Best Regards
December 1, 2011 at 11:16 pm |
Fake Hermes handbag…
[...]Elevation Chart in Flex with Google Maps « n o t e 1 9 . c o m[...]…
November 24, 2012 at 3:43 pm |
Hi, I try to integrate your example with my map (link at: http://www.ugobike.net/map/animate.html?gpx=Giro-del-Garda-Orario.gpx&title=giro ) but the elevation chart is empty. What’s am I wrong?
Thanks for reply.
Stefano
November 24, 2012 at 6:13 pm |
Hi. Thank you for your comment. I’ve not looked at the code for a long time. So I’m afraid I won’t be able to help debug your issue. At the time using Flash was the only option. I wouldn’t use Flash now. There is now much better HTML options for drawing a graph. For example, highcharts. I suggest, that you rewrite the program in HTML or use on of the free versions, e.g. Runkeeper or Map My Ride. Good luck.