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

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

Introduction

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

Prototype

public final native void setScrollWheel(boolean scrollWheel) ;

Source Link

Document

set If false, disables scrollwheel zooming on the map.

Usage

From source file:com.arcbees.website.client.application.contact.ContactView.java

License:Apache License

private void onMapsLoaded() {
    // -- HOW TO STYLE A GOOGLE MAP
    // -> First, we create the style. To help : http://software.stadtwerk.org/google_maps_colorizr/
    MapTypeStyle style1 = MapTypeStyle.newInstance();
    style1.setElementType(MapTypeStyleElementType.GEOMETRY);
    style1.setFeatureType(MapTypeStyleFeatureType.ROAD);
    style1.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#FFF"),
            MapTypeStyler.newSaturationStyler(-100), MapTypeStyler.newLightnessStyler(100) });

    MapTypeStyle style2 = MapTypeStyle.newInstance();
    style2.setElementType(MapTypeStyleElementType.ALL);
    style2.setFeatureType(MapTypeStyleFeatureType.LANDSCAPE);
    style2.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#cccccc"),
            MapTypeStyler.newSaturationStyler(-100), MapTypeStyler.newLightnessStyler(-10) });

    MapTypeStyle style3 = MapTypeStyle.newInstance();
    style3.setElementType(MapTypeStyleElementType.ALL);
    style3.setFeatureType(MapTypeStyleFeatureType.POI);
    style3.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#f00"),
            MapTypeStyler.newSaturationStyler(-100), MapTypeStyler.newLightnessStyler(9), });

    MapTypeStyle style4 = MapTypeStyle.newInstance();
    style4.setElementType(MapTypeStyleElementType.ALL);
    style4.setFeatureType(MapTypeStyleFeatureType.WATER);
    style4.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#1c1c1c"),
            MapTypeStyler.newSaturationStyler(-100), MapTypeStyler.newLightnessStyler(86), });

    MapTypeStyle[] array = { style1, style2, style3, style4 };

    JsArray<MapTypeStyle> styles = ArrayHelper.toJsArray(array);

    // -> Then we tell the map to use our new style by default
    MapTypeControlOptions controlOptions = MapTypeControlOptions.newInstance();
    controlOptions.setMapTypeIds(new String[] {});
    controlOptions.setPosition(ControlPosition.TOP_RIGHT);

    // -> And tell the map what our custom style is
    StyledMapTypeOptions styledMapTypeOptions = StyledMapTypeOptions.newInstance();
    styledMapTypeOptions.setName("Arcbees");
    StyledMapType customMapType = StyledMapType.newInstance(styles, styledMapTypeOptions);

    // -> Then we define our Lat and Long
    LatLng arcbeesCoord = LatLng.newInstance(46.792097, -71.285362);

    // -> Then goes the map options
    MapOptions options = MapOptions.newInstance();
    options.setCenter(arcbeesCoord);//from ww w. j a  va  2s.  co  m
    options.setZoom(16);
    options.setScrollWheel(false);
    options.setMapTypeControlOptions(controlOptions);
    options.setMapTypeId(ARCBEES_MAPTYPE);
    options.setPanControl(false);
    options.setDraggable(Window.getClientWidth() > 649);

    ZoomControlOptions zoomControlOptions = ZoomControlOptions.newInstance();
    zoomControlOptions.setPosition(ControlPosition.RIGHT_CENTER);
    options.setZoomControlOptions(zoomControlOptions);

    // -> We create the map with our options
    MapWidget mapWidget = new MapWidget(options);
    mapWidget.addStyleName(page.style().map());
    mapWidget.setCustomMapType(ARCBEES_MAPTYPE, customMapType);

    // -> We define the marker
    MarkerOptions markerOptions = MarkerOptions.newInstance();
    markerOptions.setIcon(pageContactResources.marker().getSafeUri().asString());
    markerOptions.setMap(mapWidget);
    markerOptions.setPosition(arcbeesCoord);

    Marker.newInstance(markerOptions);

    // -> And finally, add it to its container
    container.add(mapWidget);
}

From source file:com.mashery.examples.api.client.PopupMapWidget.java

License:Open Source License

public PopupMapWidget() {
    mapPanel = new PopupPanel(true);
    mapPanel.setAutoHideOnHistoryEventsEnabled(true);
    mapPanel.setAnimationEnabled(true);/*  w w w. j  av a 2  s. c o m*/

    MapOptions options = new MapOptions();
    options.setZoom(1);
    options.setCenter(new LatLng(0d, 0d));
    options.setMapTypeId(new MapTypeId().getRoadmap());
    options.setDraggable(true);
    options.setScrollwheel(true);
    options.setNavigationControl(true);
    options.setMapTypeControl(true);
    mapWidget = new MapWidget(options);
    mapWidget.setSize("512px", "512px");

    FlowPanel mapContainer = new FlowPanel();
    mapPanel.setWidget(mapContainer);
    mapContainer.add(mapWidget);

    Anchor clearMarkersLink = new Anchor("Clear Markers", "#");
    mapContainer.add(clearMarkersLink);
    clearMarkersLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            event.preventDefault();
            // there's no way to setMap(null) on a marker
            // instead, assign it to a dummy map
            MapWidget garbage = new MapWidget(new MapOptions());
            HasMap map = garbage.getMap();
            for (HasMarker marker : markers.values())
                marker.setMap(map);

            markers.clear();
        }
    });

    mapButton = new ToggleButton("Map");
    mapPanel.addAutoHidePartner(mapButton.getElement());
    mapButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (mapButton.isDown())
                mapPanel.showRelativeTo(mapButton);
            else
                mapPanel.hide();
        }
    });

    mapPanel.addCloseHandler(new CloseHandler<PopupPanel>() {
        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            mapButton.setDown(false);
        }
    });

    initWidget(mapButton);
}

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

/**
 * Instantiates a new map field.//  w  ww .  j a va  2 s. c  om
 *
 * @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);
}

From source file:org.wannatrak.client.MainWidget.java

License:Apache License

private MapWidget createMap() {
    final LatLng tsu = LatLng.newInstance(53.5, 49.4);

    MapOptions mapOptions = MapOptions.newInstance();
    mapOptions.setCenter(tsu);// ww  w. j  a  va 2  s .c o  m
    mapOptions.setZoom(13);
    mapOptions.setScrollWheel(true);
    mapOptions.setZoomControl(true);
    final MapWidget map = new MapWidget(mapOptions);
    //map.setContinuousZoom(true);
    //map.setScrollWheelZoomEnabled(true);
    map.setStylePrimaryName("map");

    //map.addControl(new LargeMapControl());

    //map.addControl(new HierarchicalMapTypeControl());

    return map;
}