Example usage for com.google.gwt.maps.client.controls ControlPosition RIGHT_CENTER

List of usage examples for com.google.gwt.maps.client.controls ControlPosition RIGHT_CENTER

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.controls ControlPosition RIGHT_CENTER.

Prototype

ControlPosition RIGHT_CENTER

To view the source code for com.google.gwt.maps.client.controls ControlPosition RIGHT_CENTER.

Click Source Link

Document

Elements are positioned in the center of the right side.

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   w  w  w.ja  va2 s. c  om
    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.google.gwt.maps.testing.client.maps.AdvancedLayersWidget.java

License:Apache License

/**
 * Buttons for toggling layers//from  ww  w  .j  ava 2  s . c o  m
 */
private void drawLayerControls() {

    final TrafficLayer trafficLayer = TrafficLayer.newInstance();
    final Button button = new Button("Traffic");
    button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (trafficLayer.getMap() == null) {
                trafficLayer.setMap(mapWidget);
                button.getElement().getStyle().setColor("red");
            } else {
                trafficLayer.setMap(null);
                button.getElement().getStyle().setColor("black");
            }
        }
    });

    final TransitLayer transitLayer = TransitLayer.newInstance();
    final Button button2 = new Button("Transit");
    button2.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (transitLayer.getMap() == null) {
                transitLayer.setMap(mapWidget);
                button2.getElement().getStyle().setColor("red");
            } else {
                transitLayer.setMap(null);
                button2.getElement().getStyle().setColor("black");
            }
        }
    });

    final BicyclingLayer bikeLayer = BicyclingLayer.newInstance();
    final Button button3 = new Button("Bicycle");
    button3.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (bikeLayer.getMap() == null) {
                bikeLayer.setMap(mapWidget);
                button3.getElement().getStyle().setColor("red");
            } else {
                bikeLayer.setMap(null);
                button3.getElement().getStyle().setColor("black");
            }
        }
    });

    FlowPanel widget = new FlowPanel();
    widget.add(button);
    widget.add(new HTML("Advanced Layers"));
    widget.add(button);
    widget.add(button2);
    widget.add(button3);

    DOM.setStyleAttribute(widget.getElement(), "background", "white");
    DOM.setStyleAttribute(widget.getElement(), "padding", "5px");
    DOM.setStyleAttribute(widget.getElement(), "margin", "3px");
    DOM.setStyleAttribute(widget.getElement(), "border", "3px solid darkgray");

    mapWidget.setControls(ControlPosition.RIGHT_CENTER, widget);

    // apply button so people can see more interesting map
    trafficLayer.setMap(mapWidget);
    button.getElement().getStyle().setColor("red");
}

From source file:com.google.gwt.maps.testing.client.maps.BasicMapWidget.java

License:Apache License

private void drawMapAds() {
    AdUnitOptions options = AdUnitOptions.newInstance();
    options.setFormat(AdFormat.HALF_BANNER);
    options.setPosition(ControlPosition.RIGHT_CENTER);
    options.setMap(mapWidget);/*from   ww  w.  ja  v  a 2 s  .c o m*/
    options.setPublisherId("pub-0032065764310410");
    options.setChannelNumber("4000893900");

    AdUnitWidget adUnit = new AdUnitWidget(options);

    adUnit.addChannelNumberChangeHandler(new ChannelNumberChangeMapHandler() {
        @Override
        public void onEvent(ChannelNumberChangeMapEvent event) {
        }
    });

    adUnit.addFormatChangeHandler(new FormatChangeMapHandler() {
        @Override
        public void onEvent(FormatChangeMapEvent event) {
        }
    });

    adUnit.addMapChangeHandler(new MapChangeMapHandler() {
        @Override
        public void onEvent(MapChangeMapEvent event) {
        }
    });

    adUnit.addPositionChangeHandler(new PositionChangeMapHandler() {
        @Override
        public void onEvent(PositionChangeMapEvent event) {
        }
    });
}

From source file:com.google.gwt.maps.testing.client.maps.ControlsMapWidget.java

License:Apache License

private void drawMap() {

    MapTypeControlOptions controlOptions = MapTypeControlOptions.newInstance();
    controlOptions.setMapTypeIds(MapTypeId.values()); // use all of them
    controlOptions.setPosition(ControlPosition.RIGHT_CENTER);

    LatLng center = LatLng.newInstance(49.496675, -102.65625);
    MapOptions options = MapOptions.newInstance();
    options.setZoom(4);/*from w ww .ja v  a 2s.  co m*/
    options.setCenter(center);
    options.setMapTypeId(MapTypeId.HYBRID);
    options.setMapTypeControlOptions(controlOptions);

    mapWidget = new MapWidget(options);
    pWidget.add(mapWidget);
    mapWidget.setSize("750px", "500px");

    mapWidget.addClickHandler(new ClickMapHandler() {
        public void onEvent(ClickMapEvent event) {
            // TODO fix the event getting, getting ....
            GWT.log("clicked on latlng=" + event.getMouseEvent().getLatLng());
        }
    });
}

From source file:com.google.gwt.maps.testing.client.maps.CustomControlsMapWidget.java

License:Apache License

private void drawControls() {
    Button button = new Button("B1");
    button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Button 1 Clicked");
        }//w  w  w  .  ja  va 2  s. c o  m
    });

    Button button2 = new Button("B2");
    button2.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Button 2 Clicked ");
        }
    });

    final CheckBox cb = new CheckBox();
    cb.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            GWT.log("Button 2 Clicked");
            Window.alert("CheckBox is " + cb.getValue());
        }
    });

    FlowPanel widget = new FlowPanel();
    widget.add(button);
    widget.add(new HTML("Custom Controls"));
    widget.add(button);
    widget.add(button2);
    widget.add(cb);
    widget.addStyleName("TestControls");

    // TODO I'm not able to get the stylesheet to work, but this works below
    DOM.setStyleAttribute(widget.getElement(), "background", "white");
    DOM.setStyleAttribute(widget.getElement(), "padding", "5px");
    DOM.setStyleAttribute(widget.getElement(), "margin", "3px");
    DOM.setStyleAttribute(widget.getElement(), "border", "3px solid #FF0000");

    mapWidget.setControls(ControlPosition.RIGHT_CENTER, widget);
}

From source file:com.google.gwt.maps.testing.client.maps.PanoramioMapWidget.java

License:Apache License

@SuppressWarnings("unused")
private void drawMapAds() {

    AdUnitOptions options = AdUnitOptions.newInstance();
    options.setFormat(AdFormat.HALF_BANNER);
    options.setPosition(ControlPosition.RIGHT_CENTER);
    options.setMap(mapWidget);//from  www. j  av  a2 s  .c  o m
    options.setPublisherId("pub-0032065764310410");
    options.setChannelNumber("4000893900");

    AdUnitWidget adUnit = new AdUnitWidget(options);

    adUnit.addChannelNumberChangeHandler(new ChannelNumberChangeMapHandler() {
        @Override
        public void onEvent(ChannelNumberChangeMapEvent event) {
        }
    });

    adUnit.addFormatChangeHandler(new FormatChangeMapHandler() {
        @Override
        public void onEvent(FormatChangeMapEvent event) {
        }
    });

    adUnit.addMapChangeHandler(new MapChangeMapHandler() {
        @Override
        public void onEvent(MapChangeMapEvent event) {
        }
    });

    adUnit.addPositionChangeHandler(new PositionChangeMapHandler() {
        @Override
        public void onEvent(PositionChangeMapEvent event) {
        }
    });

}

From source file:com.google.gwt.maps.testing.client.maps.WeatherLayersWidget.java

License:Apache License

/**
 * Buttons for toggling layers//from   w w  w. j a v a 2 s . c o m
 */
private void drawLayerControls() {

    final Button button = new Button("Clouds");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (cloudLayer.getMap() == null) {
                cloudLayer.setMap(mapWidget);
                button.getElement().getStyle().setColor("red");
            } else {
                cloudLayer.setMap(null);
                button.getElement().getStyle().setColor("black");
            }
        }
    });
    final Button button2 = new Button("Forecast");
    button2.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (weatherLayer.getMap() == null) {
                weatherLayer.setMap(mapWidget);
                button.getElement().getStyle().setColor("red");
            } else {
                weatherLayer.setMap(null);
                button.getElement().getStyle().setColor("black");
            }
        }
    });

    FlowPanel widget = new FlowPanel();
    widget.add(button);
    widget.add(new HTML("Weather Layers"));
    widget.add(button);
    widget.add(button2);

    DOM.setStyleAttribute(widget.getElement(), "background", "white");
    DOM.setStyleAttribute(widget.getElement(), "padding", "5px");
    DOM.setStyleAttribute(widget.getElement(), "margin", "3px");
    DOM.setStyleAttribute(widget.getElement(), "border", "3px solid darkgray");

    mapWidget.setControls(ControlPosition.RIGHT_CENTER, widget);

    button.getElement().getStyle().setColor("red");
    button2.getElement().getStyle().setColor("red");
}

From source file:com.saveland.ancestry.client.InfoWindowMapWidget.java

License:Apache License

private void drawControls() {
    Button button = new Button("+ Add New Person");
    button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            GWT.log("Clicked Add");
            cData.setCurrentPerson(null);
        }//from  w  ww  .  ja  v a2 s.com
    });

    FlowPanel widget = new FlowPanel();
    widget.add(button);
    // widget.add(new HTML("Custom Controls"));
    widget.addStyleName("map-controls");

    // TODO I'm not able to get the stylesheet to work, but this works below
    // DOM.setStyleAttribute(widget.getElement(), "background", "white");
    // DOM.setStyleAttribute(widget.getElement(), "padding", "5px");
    // DOM.setStyleAttribute(widget.getElement(), "margin", "3px");
    // DOM.setStyleAttribute(widget.getElement(), "border",
    // "3px solid #FF0000");

    mapWidget.setControls(ControlPosition.RIGHT_CENTER, widget);
}