Example usage for com.google.gwt.maps.client.event GroundOverlayVisibilityChangedHandler GroundOverlayVisibilityChangedHandler

List of usage examples for com.google.gwt.maps.client.event GroundOverlayVisibilityChangedHandler GroundOverlayVisibilityChangedHandler

Introduction

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

Prototype

GroundOverlayVisibilityChangedHandler

Source Link

Usage

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

License:Apache License

@Override
public void onShow() {
    // The map's bounds are meaningless until the map has been added to the DOM
    // and sized appropriately
    if (firstTime) {
        firstTime = false;/*from ww  w.  jav  a 2  s  . c  o  m*/
        LatLngBounds bounds = map.getBounds();
        LatLng southWest = bounds.getSouthWest();
        LatLng northEast = bounds.getNorthEast();
        double lngDelta = (northEast.getLongitude() - southWest.getLongitude()) / 4;
        double latDelta = (northEast.getLatitude() - southWest.getLatitude()) / 4;

        // generate bounds that covers center map with half the width and height
        LatLngBounds rectBounds = LatLngBounds.newInstance(
                LatLng.newInstance(southWest.getLatitude() + latDelta, southWest.getLongitude() + lngDelta),
                LatLng.newInstance(northEast.getLatitude() - latDelta, northEast.getLongitude() - lngDelta));
        groundOverlay = new GroundOverlay("boot.jpg", rectBounds);
        groundOverlay.addGroundOverlayVisibilityChangedHandler(new GroundOverlayVisibilityChangedHandler() {

            public void onVisibilityChanged(GroundOverlayVisibilityChangedEvent event) {
                if (event.isVisible()) {
                    hideButton.setText("Hide Overlay");
                } else {
                    hideButton.setText("Show Overlay");
                }
            }

        });
        map.addOverlay(groundOverlay);
    }
}