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

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

Introduction

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

Prototype

ControlPosition TOP_CENTER

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

Click Source Link

Document

Elements are positioned in the center of the top row.

Usage

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

License:Apache License

private void drawDrawing() {

    DrawingControlOptions drawingControlOptions = DrawingControlOptions.newInstance();
    drawingControlOptions.setPosition(ControlPosition.TOP_CENTER);
    drawingControlOptions.setDrawingModes(OverlayType.values());

    CircleOptions circleOptions = CircleOptions.newInstance();
    // circleOptions.setFillColor("FF6633");

    DrawingManagerOptions options = DrawingManagerOptions.newInstance();
    options.setMap(mapWidget);//from  w w w .ja va2 s.co m
    options.setDrawingMode(OverlayType.CIRCLE);
    options.setCircleOptions(circleOptions);

    options.setDrawingControlOptions(drawingControlOptions);

    DrawingManager o = DrawingManager.newInstance(options);

    o.addCircleCompleteHandler(new CircleCompleteMapHandler() {
        @Override
        public void onEvent(CircleCompleteMapEvent event) {
            Circle circle = event.getCircle();
            GWT.log("circle completed radius=" + circle.getRadius());
        }
    });

    o.addMarkerCompleteHandler(new MarkerCompleteMapHandler() {
        @Override
        public void onEvent(MarkerCompleteMapEvent event) {
            Marker marker = event.getMarker();
            GWT.log("marker completed position=" + marker.getPosition());
        }
    });

    o.addOverlayCompleteHandler(new OverlayCompleteMapHandler() {
        @Override
        public void onEvent(OverlayCompleteMapEvent event) {
            OverlayType ot = event.getOverlayType();
            GWT.log("marker completed OverlayType=" + ot.toString());

            if (ot == OverlayType.CIRCLE) {
                Circle circle = event.getCircle();
                GWT.log("radius=" + circle.getRadius());
                GWT.log("center=" + circle.getBounds().getCenter());
            }

            if (ot == OverlayType.MARKER) {
                Marker marker = event.getMarker();
                GWT.log("position=" + marker.getPosition());
                GWT.log("center=" + marker.getPosition());
            }

            if (ot == OverlayType.POLYGON) {
                Polygon polygon = event.getPolygon();
                GWT.log("paths=" + polygon.getPaths().toString());

                // print path points
                MVCArray<LatLng> points = polygon.getPath();
                for (int g = 0; g < points.getLength(); g++) {
                    LatLng p = points.get(g);
                    GWT.log("[" + p.getLatitude() + "," + p.getLongitude() + "]");
                }

                GWT.log("center=" + polygon.getPath());
            }

            if (ot == OverlayType.POLYLINE) {
                Polyline polyline = event.getPolyline();
                GWT.log("paths=" + polyline.getPath().toString());
                GWT.log("center=" + polyline.getPath());
            }

            if (ot == OverlayType.RECTANGLE) {
                Rectangle rectangle = event.getRectangle();
                GWT.log("bounds=" + rectangle.getBounds());
                GWT.log("center=" + rectangle.getBounds().getCenter());
            }

            GWT.log("marker completed OverlayType=" + ot.toString());
        }
    });

    o.addPolygonCompleteHandler(new PolygonCompleteMapHandler() {
        @Override
        public void onEvent(PolygonCompleteMapEvent event) {
            Polygon polygon = event.getPolygon();
            GWT.log("Polygon completed paths=" + polygon.getPath().toString());
        }
    });

    o.addPolylineCompleteHandler(new PolylineCompleteMapHandler() {
        @Override
        public void onEvent(PolylineCompleteMapEvent event) {
            Polyline polyline = event.getPolyline();
            GWT.log("Polyline completed paths=" + polyline.getPath().toString());
        }
    });

    o.addRectangleCompleteHandler(new RectangleCompleteMapHandler() {
        @Override
        public void onEvent(RectangleCompleteMapEvent event) {
            Rectangle rectangle = event.getRectangle();
            GWT.log("Rectangle completed bounds=" + rectangle.getBounds().getToString());
        }
    });

}

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

License:Apache License

private void drawMapAds() {

    AdUnitOptions options = AdUnitOptions.newInstance();
    options.setFormat(AdFormat.LEADERBOARD);
    options.setPosition(ControlPosition.TOP_CENTER);
    options.setMap(mapWidget);//  w w  w .j  a  v a2 s .  co m
    options.setPublisherId("pub-0032065764310410");
    options.setChannelNumber("4000893900");

    AdUnitWidget adUnit = new AdUnitWidget(options);

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

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

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

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

}

From source file:org.rebioma.client.MapView.java

License:Apache License

private void initMap() {
    MapOptions mapOptions = MapOptions.newInstance();
    mapOptions.setCenter(HistoryState.DEFAULT_CENTER);
    mapOptions.setZoom(DEFAULT_ZOOM);/*from  w  w  w  .ja  v  a2  s .c o m*/
    mapOptions.setDraggableCursor("crosshair");
    mapOptions.setDraggingCursor("move");
    mapOptions.setMapTypeId(DEFAULT_MAP_TYPE);
    mapOptions.setScaleControl(true);
    MapTypeControlOptions mapTypeControlOptions = MapTypeControlOptions.newInstance();
    mapTypeControlOptions.setMapTypeIds(MapTypeId.values());
    mapTypesMap.put(MapTypeId.TERRAIN.toString(), MapTypeId.TERRAIN);
    mapTypesMap.put(MapTypeId.ROADMAP.toString(), MapTypeId.ROADMAP);
    mapTypesMap.put(MapTypeId.SATELLITE.toString(), MapTypeId.SATELLITE);
    mapOptions.setMapTypeControlOptions(mapTypeControlOptions);
    mapOptions.setMapTypeControl(true);
    map = new MapWidget(mapOptions);
    map.setWidth("100%");
    map.setHeight("100%");
    final MapView mapView = this;
    // map.addControl(getModelControl());
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override
        public void execute() {
            HideControl hideControl = new HideControl();
            map.setControls(ControlPosition.TOP_RIGHT, hideControl);
            controlsGroup.setMap(map, ControlPosition.RIGHT_TOP);
            //          map.setControls(ControlPosition.TOP_RIGHT, geocoder);
            /*ScaleControl scaleControl = new ScaleControl();
            LargeMapControl largeMapControl = new LargeMapControl();
            MenuMapTypeControl mapTypeControl = new MenuMapTypeControl();
                    
            map.addControl(scaleControl);
            map.addControl(largeMapControl);
            map.addControl(mapTypeControl);
                    
            ControlPosition hideControlPosition = new ControlPosition(
               ControlAnchor.TOP_RIGHT, 100, 10);*/
            //           envLayerSelector.setMap(map, ControlPosition.TOP_RIGHT);
            hideControl.addControlWidgetToHide(geocoder);
            hideControl.addControlWidgetToHide(envLayerSelector);

            CoordinatesControl coordinatesControl = new CoordinatesControl(map);

            MapDrawingControl mapDrawingControl = new MapDrawingControl(map, ControlPosition.TOP_CENTER);
            mapDrawingControl.addListener(mapView);
            ClearMapDrawingControl clearMapDrawingControl = new ClearMapDrawingControl(mapDrawingControl);
            map.setControls(ControlPosition.TOP_LEFT, clearMapDrawingControl);
        }
    });
    map.addClickHandler(mapClickHandler);
    map.addZoomChangeHandler(mapZoomHandler);
    map.addMapTypeIdChangeHandler(mapTypeHandler);
    //    map.checkResizeAndCenter();
}