Example usage for com.google.gwt.maps.client MapOptions setOverviewMapControl

List of usage examples for com.google.gwt.maps.client MapOptions setOverviewMapControl

Introduction

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

Prototype

public final native void setOverviewMapControl(boolean overviewMapControl) ;

Source Link

Document

set The enabled/disabled state of the Overview Map control.

Usage

From source file:gov.wa.wsdot.mobile.client.activities.ferries.vesselwatch.VesselWatchMapViewGwtImpl.java

License:Open Source License

public VesselWatchMapViewGwtImpl() {

    initWidget(uiBinder.createAndBindUi(this));

    accessibilityPrepare();// www .j a va2  s.  c o  m

    if (MGWT.getOsDetection().isAndroid()) {
        leftFlexSpacer.setVisible(false);
    }

    if (localStorage != null) {
        storageMap = new StorageMap(localStorage);
        if (!storageMap.containsKey("KEY_SHOW_CAMERAS")) {
            localStorage.setItem("KEY_SHOW_CAMERAS", "true"); // Set initial default value
        }

        // Set initial default location and zoom to Seattle area.
        localStorage.setItem("KEY_MAP_LAT", "47.565125");
        localStorage.setItem("KEY_MAP_LON", "-122.480508");
        localStorage.setItem("KEY_MAP_ZOOM", "11");
    }

    final TrafficLayer trafficLayer = TrafficLayer.newInstance();

    LatLng center = LatLng.newInstance(Double.valueOf(localStorage.getItem("KEY_MAP_LAT")),
            Double.valueOf(localStorage.getItem("KEY_MAP_LON")));

    MapOptions opts = MapOptions.newInstance();
    opts.setMapTypeId(MapTypeId.ROADMAP);
    opts.setCenter(center);
    opts.setZoom(Integer.valueOf(localStorage.getItem("KEY_MAP_ZOOM"), 10));
    opts.setPanControl(false);
    opts.setZoomControl(false);
    opts.setMapTypeControl(false);
    opts.setScaleControl(false);
    opts.setStreetViewControl(false);
    opts.setOverviewMapControl(false);

    // Custom map style to remove all "Points of Interest" labels from map
    MapTypeStyle style1 = MapTypeStyle.newInstance();
    style1.setFeatureType(MapTypeStyleFeatureType.POI);
    style1.setElementType(MapTypeStyleElementType.LABELS);
    style1.setStylers(new MapTypeStyler[] { MapTypeStyler.newVisibilityStyler("off") });
    MapTypeStyle[] styles = { style1 };

    opts.setMapTypeStyles(styles);

    mapWidget = new MyMapWidget(opts);
    trafficLayer.setMap(mapWidget);
    flowPanel.add(mapWidget);

    mapWidget.setSize(Window.getClientWidth() + "px",
            (Window.getClientHeight() - ParserUtils.windowUI()) + "px");

    Window.addResizeHandler(new ResizeHandler() {
        @Override
        public void onResize(ResizeEvent event) {
            MapHandlerRegistration.trigger(mapWidget, MapEventType.RESIZE);

        }
    });

    mapWidget.addResizeHandler(new ResizeMapHandler() {
        @Override
        public void onEvent(ResizeMapEvent event) {
            mapWidget.setSize(Window.getClientWidth() + "px",
                    (Window.getClientHeight() - ParserUtils.windowUI()) + "px");
        }
    });

    mapWidget.addIdleHandler(new IdleMapHandler() {

        @Override
        public void onEvent(IdleMapEvent event) {
            localStorage.setItem("KEY_MAP_LAT", String.valueOf(mapWidget.getCenter().getLatitude()));
            localStorage.setItem("KEY_MAP_LON", String.valueOf(mapWidget.getCenter().getLongitude()));
            localStorage.setItem("KEY_MAP_ZOOM", String.valueOf(mapWidget.getZoom()));

            if (presenter != null) {
                presenter.onMapIsIdle();
            }
        }
    });

}

From source file:gov.wa.wsdot.mobile.client.activities.trafficmap.TrafficMapViewGwtImpl.java

License:Open Source License

public TrafficMapViewGwtImpl() {

    initWidget(uiBinder.createAndBindUi(this));

    accessibilityPrepare();/* w w w  .ja v a 2 s .  c om*/

    if (MGWT.getOsDetection().isAndroid()) {
        leftFlexSpacer.setVisible(false);
    }

    if (localStorage != null) {
        storageMap = new StorageMap(localStorage);
        if (!storageMap.containsKey("KEY_SHOW_CAMERAS")) {
            localStorage.setItem("KEY_SHOW_CAMERAS", "true"); // Set initial default value
        }
        if (!storageMap.containsKey("KEY_SHOW_RESTAREAS")) {
            localStorage.setItem("KEY_SHOW_RESTAREAS", "false"); // Set initial default value
        }

        // Set initial default location and zoom to Seattle area.
        if (!storageMap.containsKey("KEY_MAP_LAT")) {
            localStorage.setItem("KEY_MAP_LAT", "47.5990");
        }
        if (!storageMap.containsKey("KEY_MAP_LON")) {
            localStorage.setItem("KEY_MAP_LON", "-122.3350");
        }
        if (!storageMap.containsKey("KEY_MAP_ZOOM")) {
            localStorage.setItem("KEY_MAP_ZOOM", "12");
        }
    }

    final TrafficLayer trafficLayer = TrafficLayer.newInstance();

    LatLng center = LatLng.newInstance(Double.valueOf(localStorage.getItem("KEY_MAP_LAT")),
            Double.valueOf(localStorage.getItem("KEY_MAP_LON")));

    MapOptions opts = MapOptions.newInstance();
    opts.setMapTypeId(MapTypeId.ROADMAP);
    opts.setCenter(center);
    opts.setZoom(Integer.valueOf(localStorage.getItem("KEY_MAP_ZOOM"), 10));
    opts.setPanControl(false);
    opts.setZoomControl(false);
    opts.setMapTypeControl(false);
    opts.setScaleControl(false);
    opts.setStreetViewControl(false);
    opts.setOverviewMapControl(false);

    // Custom map style to remove all "Points of Interest" labels from map
    MapTypeStyle style1 = MapTypeStyle.newInstance();
    style1.setFeatureType(MapTypeStyleFeatureType.POI);
    style1.setElementType(MapTypeStyleElementType.LABELS);
    style1.setStylers(new MapTypeStyler[] { MapTypeStyler.newVisibilityStyler("off") });
    MapTypeStyle[] styles = { style1 };

    opts.setMapTypeStyles(styles);

    mapWidget = new MyMapWidget(opts);
    trafficLayer.setMap(mapWidget);
    flowPanel.add(mapWidget);

    mapWidget.setSize(Window.getClientWidth() + "px",
            (Window.getClientHeight() - ParserUtils.windowUI()) + "px");

    Window.addResizeHandler(new ResizeHandler() {
        @Override
        public void onResize(ResizeEvent event) {
            MapHandlerRegistration.trigger(mapWidget, MapEventType.RESIZE);

        }
    });

    mapWidget.addResizeHandler(new ResizeMapHandler() {
        @Override
        public void onEvent(ResizeMapEvent event) {
            mapWidget.setSize(Window.getClientWidth() + "px",
                    (Window.getClientHeight() - ParserUtils.windowUI()) + "px");
        }
    });

    mapWidget.addIdleHandler(new IdleMapHandler() {

        @Override
        public void onEvent(IdleMapEvent event) {
            localStorage.setItem("KEY_MAP_LAT", String.valueOf(mapWidget.getCenter().getLatitude()));
            localStorage.setItem("KEY_MAP_LON", String.valueOf(mapWidget.getCenter().getLongitude()));
            localStorage.setItem("KEY_MAP_ZOOM", String.valueOf(mapWidget.getZoom()));

            if (presenter != null) {
                presenter.onMapIsIdle();
            }
        }
    });
}

From source file:net.cbtltd.client.field.MapField.java

/**
 * Instantiates a new map field.//from   www. ja  v  a  2  s.  c  o  m
 *
 * @param form is the form or other HasComponents element that contains the field.
 * @param permission that controls the visibility of the field.
 * @param tab index of the field.
 */
public MapField(HasComponents form, short[] permission, int tab) {
    initialize(panel, form, permission, CSS.cbtMapField());

    super.setDefaultValue(LatLng.newInstance(0.0, 0.0));

    addressLabel.addStyleName(CSS.cbtMapFieldLabel());
    addressBox.addStyleName(CSS.cbtLocationFieldField());
    addressBox.addBlurHandler(new BlurHandler() {
        @Override
        public void onBlur(BlurEvent event) {
            setName(addressBox.getText());
        }
    });

    addressBox.addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                setName(addressBox.getText());
            }
        }
    });

    latitudeLabel.addStyleName(CSS.cbtMapFieldLabel());
    latitudeBox.addStyleName(CSS.cbtMapFieldLatLng());
    latitudeBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            Double latitude = LF.parse(latitudeBox.getText());
            if (latitude < -90.0 || latitude > 90.0) {
                addMessage(Level.ERROR, CONSTANTS.errPositionLatitude(), latitudeBox);
            } else {
                setValue(LatLng.newInstance(latitude, marker.getPosition().getLongitude()));
            }
        }
    });

    longitudeLabel.addStyleName(CSS.cbtMapFieldLabel());
    longitudeBox.addStyleName(CSS.cbtMapFieldLatLng());
    longitudeBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            Double longitude = LF.parse(longitudeBox.getText());
            if (longitude < -180.0 || longitude > 180.0) {
                addMessage(Level.ERROR, CONSTANTS.errPositionLongitude(), longitudeBox);
            } else {
                setValue(LatLng.newInstance(marker.getPosition().getLatitude(), longitude));
            }
        }
    });

    position.addStyleName(CSS.cbtMapFieldTitle());
    position.add(addressLabel);
    position.add(addressBox);
    position.add(latitudeLabel);
    position.add(latitudeBox);
    position.add(longitudeLabel);
    position.add(longitudeBox);
    position.add(lock);

    panel.add(position);

    MapOptions mapOptions = MapOptions.newInstance();
    mapOptions.setDraggableCursor("crosshair");
    mapOptions.setDraggingCursor("text");
    mapOptions.setCenter(LatLng.newInstance(0.0, 0.0));
    mapOptions.setDraggable(true);
    mapOptions.setDisableDoubleClickZoom(true);
    //      mapOptions.setHeading(heading);
    mapOptions.setKeyboardShortcuts(false);
    mapOptions.setMapMaker(true);
    mapOptions.setMapTypeControl(true);
    mapOptions.setMapTypeId(mapTypeId);
    mapOptions.setNoClear(false);
    mapOptions.setOverviewMapControl(false);
    //      mapOptions.setMapTypeControlOptions(MapTypeControlOptions.)
    mapOptions.setPanControl(true);
    //      mapOptions.setPanControlOptions(panControlOptions);
    mapOptions.setRotateControl(false);
    //      mapOptions.setRotateControlOptions(rotateControlOptions)
    mapOptions.setScaleControl(true);
    //      mapOptions.setScaleControlOptions(scaleControlOptions)
    mapOptions.setScrollWheel(scrollWheel);
    //      StreetViewPanoramaImpl streetView = StreetViewPanoramaImpl.newInstance(field.getElement(), options);
    //      mapOptions.setStreetView(streetView);
    mapOptions.setStreetViewControl(streetView);
    //      mapOptions.setStreetViewControlOptions(streetViewControlOptions)
    //      mapOptions.setStyles(styles)
    mapOptions.setZoom(15);
    mapOptions.setZoomControl(true);

    map = MapWidget.newInstance(MapImpl.newInstance(field.getElement(), mapOptions));

    map.addClickHandler(new ClickMapHandler() {
        public void onEvent(ClickMapEvent event) {
            if (isEnabled()) {
                setValue(event.getMouseEvent().getLatLng());
                fireChange(MapField.this);
            }
        }
    });
    panel.add(field);

    emptyValue.addStyleName(CSS.cbtMapFieldEmpty());
    emptyValue.setVisible(false);
    panel.add(emptyValue);

    InfoWindowOptions infowindowOpts = InfoWindowOptions.newInstance();
    infowindowOpts.setMaxWidth(100);
    infowindowOpts.setPosition(defaultValue);
    infoWindow = InfoWindow.newInstance(infowindowOpts);
}