This library contains extern classes that allow static type checking and compilation for various Google javascript API's. Currently, it contains the base google loader class, which is documented here, as well as a full specification for the Google Earth API. It is currently in a very early stage of development.

There is currently some minimal documentation of the API here.

Namespaces and google.loader()

Many of Google's javascript types and methods are given "nice" namespaces. However, in many cases, they differ from how Haxe handles class and instance naming. The first issue is with the base loader functionality, given by google.load(). "google" in this case behaves like a class containing a few static methods, one of which is a load method. Later on, the "google" namespace is introduced, with sub packages like google.maps, and This confuses completion for packages in Haxe.

Using some initialization magic, the "google" instance variable gets assigned to "Google", which fits with the standard Haxe method of naming classes and handling static methods.

The "google.setOnLoadCallback" function fires when the entire page is loaded. It is also overloaded at runtime so that api classes can have their namespaces automatically fixed if the original google api is loaded asynchronously.

Note: There is another callback function option which fires when just the javascript is loaded. This function is not overridden.

Enums and Initialization Objects

Javascript enums (simple constrained sets of integers or strings) are not currently possible for Haxe to support as an extern. They are typed as simple base types such as String or Ints.

Javascript initialization objects are anonymous objects of string keys and values. They are typed as simple Dynamic<Dynamic> objects in the extern.

Google Earth

Google earth does not currently have a well behaved namespace, so unfortunately most classes exist in the base package. Once again, the instance and functions are mapped to the Earth class as "google.Earth".
More details about the API itself are given on the Google Earth API page.

The main instance creation function becomes:

google.Earth.createInstance('map3d', initCallback, failureCallback);


Try out the demo below, and compare to the tutorials by Google. (it's necessary to install the google earth plugin, of course. This page should present an install option when you visit it.)
import Google;

import google.loader.ClientLocation;

class Demo {

    public static function main(){
        var js:Bar;

        var onLoad = function(){
            var ge = null;
            var initCallback = function(object:Dynamic) {
                ge = object;

            var failureCallback = function() {
            google.Earth.createInstance('map3d', initCallback, failureCallback);



version #8892, modified 2010-07-15 07:29:50 by jjdonald