Example usage for com.google.gwt.maps.client Maps isLoaded

List of usage examples for com.google.gwt.maps.client Maps isLoaded

Introduction

In this page you can find the example usage for com.google.gwt.maps.client Maps isLoaded.

Prototype

public static native boolean isLoaded() ;

Source Link

Document

Check for the availability of the Maps API.

Usage

From source file:com.google.gwt.maps.sample.hellomaps.client.HelloMaps.java

License:Apache License

public void onModuleLoad() {

    if (!Maps.isLoaded()) {
        Window.alert("The Maps API is not installed."
                + "  The <script> tag that loads the Maps API may be missing or your Maps key may be wrong.");
        return;// w  w w .j  a va 2s  .  c  om
    }

    if (!Maps.isBrowserCompatible()) {
        Window.alert("The Maps API is not compatible with this browser.");
        return;
    }

    // Load all the MapsDemos.
    loadMapsDemos();

    innerPanel.setStylePrimaryName("hm-mapinnerpanel");
    innerPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    HorizontalPanel horizPanel = new HorizontalPanel();
    list.setStylePrimaryName("hm-demolistbox");
    horizPanel.add(new Label("Select Demo: "));
    horizPanel.add(list);
    innerPanel.add(horizPanel);
    innerPanel.add(description);
    innerPanel.setSpacing(10);

    History.addHistoryListener(this);

    outerPanel.setStylePrimaryName("hm-outerpanel");
    outerPanel.insertRow(0);
    outerPanel.insertRow(0);
    outerPanel.insertRow(0);
    outerPanel.insertRow(0);
    outerPanel.insertRow(0);

    outerPanel.addCell(0);
    outerPanel.addCell(1);
    outerPanel.addCell(2);
    outerPanel.addCell(3);
    outerPanel.addCell(4);

    outerPanel.setWidget(0, 0,
            new HTML("This Maps-enabled application was built using the Google " + "API Library for GWT, "
                    + "<a href=\"http://code.google.com/p/gwt-google-apis/\">"
                    + "http://code.google.com/p/gwt-google-apis/</a>. "
                    + "The drop down list below allows you to select a scenario that "
                    + "demonstrates a particular capability of the Maps support."));

    outerPanel.setWidget(1, 0, innerPanel);

    DecoratorPanel decorator = new DecoratorPanel();
    decorator.add(outerPanel);

    RootPanel.get("hm-map").add(decorator);

    // Show the initial screen.
    String initToken = History.getToken();
    if (initToken.length() > 0) {
        onHistoryChanged(initToken);
    } else {
        showInfo();
    }
}

From source file:org.sigmah.client.map.MapApiLoader.java

License:Open Source License

public static void load(final AsyncMonitor monitor, final AsyncCallback<Void> callback) {
    if (Maps.isLoaded()) {
        if (monitor != null) {
            monitor.onCompleted();/*from   w w  w  .  j a  va  2s  .com*/
        }
        if (callback != null) {
            callback.onSuccess(null);
        }
    } else {
        if (!loadInProgress) {
            startLoad();
        }
        addListeners(monitor, callback);
    }
    load();
}

From source file:org.sigmah.client.map.MapApiLoader.java

License:Open Source License

public static void load() {
    Log.debug("MapApiLoader: load()");
    if (!Maps.isLoaded() && !loadInProgress) {
        startLoad();/*ww w.  ja  va  2 s . c  om*/
    }
}

From source file:org.sigmah.client.map.MapApiLoader.java

License:Open Source License

private static void startFailureTimer() {
    Timer timer = new Timer() {
        @Override//from  w w  w. j a v a  2 s  .com
        public void run() {
            if (!Maps.isLoaded()) {
                onApiLoadFailure();
            }
        }
    };
    timer.schedule(TIMEOUT);
}

From source file:org.sigmah.client.ui.map.MapApiLoader.java

License:Open Source License

public static void load(final AsyncCallback<Void> callback) {
    if (Maps.isLoaded()) {
        if (callback != null) {
            callback.onSuccess(null);//  w ww  .j a  va2s  .  c  o  m
        }
    } else {
        if (!loadInProgress) {
            startLoad();
        }
        addListener(callback);
    }
    load();
}

From source file:org.sigmah.client.ui.widget.map.GoogleWorldMap.java

License:Open Source License

@Override
protected void init() {
    MapApiLoader.load(new AsyncCallback<Void>() {

        @Override//from   w  w  w. ja  v  a2 s.c o  m
        public void onFailure(Throwable caught) {
            getRoot().add(new Label(I18N.CONSTANTS.connectionProblem()));
            setInitialized(true);
        }

        @Override
        public void onSuccess(Void result) {
            if (Maps.isLoaded()) {
                map = new MapWidget();
                map.setHeight("100%");
                getRoot().add(map);

                setInitialized(true);

            } else {
                N10N.errorNotif(I18N.CONSTANTS.googleMaps(), I18N.CONSTANTS.cannotLoadMap());
            }
        }
    });
}