Thursday 15 May 2008

Better KML rendering with Google Maps API for Flash?

Yesterday, Google launched their new Google Maps API for Flash. A Flash version will hopefully have better vector rendering capabilities than the JavaScript based API.

Most of the current map APIs quite cleverly use use the build-in vector support in Firefox and Internet Explorer (and others). Firefox supports Scalable Vector Graphics (SVG), while Microsoft use the obsolete Vector Markup Language (VML). The Google Maps API and OpenLayers API automatically check your browser and draws the vectors with the appropriate technology.

But the SVG/VML/DOM technology has some serious performance issues - if you add many complex polygons the browser will run terribly slow. While we wait for HTML 5 (and browsers to support it), Flash APIs might be a better solution.

I recommend Prince McLean's articles about the Flash Wars.

Guilhem has made a nice tutorial of how choropleth maps can be created with Google Maps Flash API. He uses the World borders dataset available on this site. The Flash API has currently no way to load geometries from a KML file, so Gulheim manually creates the country polygons through API calls. Try his application and see the benefits of using Flash compared to a SVG/VML/DOM approach an this site (using Google Maps API).

Hopefully, Google will include KML support in a future release of Google Maps Flash API. I also miss a JavaScript API, - so the Flash version could be used as the Google Maps API or the new Google Earth API. And what about encoded polyline support in KML?


Anonymous said...


We think this is a significant deal insofar as using the Flash engine is capable of much larger geometry sets and the manipulation of their appearance.

Enjoy the blog quite a bit and feel it fills an important gap the the geo-blogosphere.


Brian Timoney

Anonymous said...

Hi Bjorn,

Great blog and clever approaches to thematic mapping. If you are interested in more data for producing KML thematic maps we have a new tool at which has good bit of data in KML and shapefile format. We'll have some interesting thematic functionality coming up soon that should be relevant as well.


Anonymous said...

I don't think Google Maps uses the SVG/KML combination. The SVG/VML combo used by OpenLayers and Virtual Earth actually performs pretty well, and both render large vectors better than Google Maps. I did a quick test on the Google Maps Flex API and, unfortunately, performance with large vectors was still disappointing.

Anonymous said...

I meant to say SVG/VML both times instead of SVG/KML the first time.

Pamela Fox said...

Hey there-

I just created a KML parsing class for AS3, and made a demo of using it to display the Samples-in-Maps KML from the KML documentation. Check it out here:

You can right click and view source. Feel free to download it and try it with other KML files (and see what kind of optimization it needs).

- pamela

Bjørn Sandvik said...

Hi Pamela,

Thank you for sharing. I'm sure someone will try it. I would appreciate feedback about how it renders KML/KMZ files from this site. I think Google Maps API for Flash would be much more useful if it had a JavaScript API like the new Google Earth API.

T-BagXL7 said...

Does anyone know if there is are as3 classes out there that can parse KML documents and convert the KML to relevant as3 objects? I've seen Pamela Fox's example but there is no way to view her as3 in order to use it in other flash projects.