Example usage for com.google.gwt.maps.client.overlays CircleOptions newInstance

List of usage examples for com.google.gwt.maps.client.overlays CircleOptions newInstance

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.overlays CircleOptions newInstance.

Prototype

public final static CircleOptions newInstance() 

Source Link

Document

creates Circle options

Usage

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

License:Apache License

private void drawShapes() {
    // add some draw shapes for folks
    CircleOptions cOpts = CircleOptions.newInstance();
    cOpts.setCenter(LatLng.newInstance(52.62d, -119.95d));
    cOpts.setFillColor("#FF0000");
    cOpts.setStrokeColor("CCFF44");
    cOpts.setFillOpacity(0.5d);/*from w w  w.  ja v  a2s .  c  o  m*/
    cOpts.setStrokeOpacity(0.9d);
    cOpts.setStrokeWeight(3);
    cOpts.setRadius(1000000d);
    cOpts.setMap(mapWidget);
    @SuppressWarnings("unused")
    Circle circle = Circle.newInstance(cOpts);

    cOpts = CircleOptions.newInstance();
    cOpts.setCenter(LatLng.newInstance(40.569d, -82.7929d));
    cOpts.setFillColor("#00FF00");
    cOpts.setStrokeColor("FFCCFF");
    cOpts.setFillOpacity(0.7d);
    cOpts.setStrokeOpacity(0.9d);
    cOpts.setStrokeWeight(10);
    cOpts.setRadius(300000d);
    cOpts.setMap(mapWidget);
    @SuppressWarnings("unused")
    Circle circle2 = Circle.newInstance(cOpts);

    LatLng[] a = new LatLng[18];
    a[0] = LatLng.newInstance(49.02824580511537, -104.0899658203125);
    a[1] = LatLng.newInstance(43.009982694835784, -104.0679931640625);
    a[2] = LatLng.newInstance(43.026047765621, -98.5528564453125);
    a[3] = LatLng.newInstance(42.73623356449312, -98.0255126953125);
    a[4] = LatLng.newInstance(42.89740952345494, -97.9156494140625);
    a[5] = LatLng.newInstance(42.83298955227273, -97.3883056640625);
    a[6] = LatLng.newInstance(42.52607693975099, -96.5753173828125);
    a[7] = LatLng.newInstance(43.20248609768505, -96.4654541015625);
    a[8] = LatLng.newInstance(43.521979415112206, -96.6192626953125);
    a[9] = LatLng.newInstance(43.69698341176971, -96.5093994140625);
    a[10] = LatLng.newInstance(45.32638440880054, -96.4215087890625);
    a[11] = LatLng.newInstance(45.54224714353031, -96.9708251953125);
    a[12] = LatLng.newInstance(45.757284242039375, -96.6851806640625);
    a[13] = LatLng.newInstance(46.23050041945144, -96.5533447265625);
    a[14] = LatLng.newInstance(46.714738770992284, -96.9049072265625);
    a[15] = LatLng.newInstance(47.67030090972658, -96.8170166015625);
    a[16] = LatLng.newInstance(47.98009843932673, -97.1466064453125);
    a[17] = LatLng.newInstance(48.97058369834937, -97.2125244140625);
    JsArray<LatLng> paths = ArrayHelper.toJsArray(a);

    PolygonOptions pOpts = PolygonOptions.newInstance();
    pOpts.setFillColor("#0000FF");
    pOpts.setStrokeColor("FFFFFF");
    pOpts.setFillOpacity(0.4d);
    pOpts.setStrokeOpacity(0.9d);
    pOpts.setStrokeWeight(6);
    pOpts.setPaths(paths);
    pOpts.setMap(mapWidget);
    @SuppressWarnings("unused")
    Polygon polygon = Polygon.newInstance(pOpts);
}

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  ww  w.ja v a2s  . c  o 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:gov.wa.wsdot.mobile.client.activities.ferries.vesselwatch.VesselWatchMapViewGwtImpl.java

License:Open Source License

@Override
public void addMapMarker(Position position) {
    if (myLocationMarker != null) {
        myLocationMarker.setMap((MapWidget) null);
    }/*from  w w  w. jav a  2  s .  c  o  m*/

    if (myLocationError != null) {
        myLocationError.setMap(null);
    }

    LatLng center = LatLng.newInstance(position.getCoordinates().getLatitude(),
            position.getCoordinates().getLongitude());
    MarkerOptions options = MarkerOptions.newInstance();
    options.setPosition(center);
    MarkerImage icon = MarkerImage.newInstance(AppBundle.INSTANCE.myLocationPNG().getSafeUri().asString());
    icon.setAnchor(Point.newInstance(11, 11));
    options.setOptimized(true);
    options.setIcon(icon);
    myLocationMarker = Marker.newInstance(options);
    myLocationMarker.setMap(mapWidget);

    // create a circle the size of the error
    CircleOptions circleOptions = CircleOptions.newInstance();
    circleOptions.setFillOpacity(0.1);
    circleOptions.setFillColor("#1a75ff");
    circleOptions.setStrokeOpacity(0.12);
    circleOptions.setStrokeWeight(1);
    circleOptions.setStrokeColor("#1a75ff");
    myLocationError = Circle.newInstance(circleOptions);
    myLocationError.setCenter(center);
    myLocationError.setRadius(position.getCoordinates().getAccuracy());
    myLocationError.setMap(mapWidget);
}

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

License:Open Source License

@Override
public void addMapMarker(Position position) {

    if (myLocationMarker != null) {
        myLocationMarker.setMap((MapWidget) null);
    }/*  www.j  a  va  2s .  c  om*/

    if (myLocationError != null) {
        myLocationError.setMap(null);
    }

    LatLng center = LatLng.newInstance(position.getCoordinates().getLatitude(),
            position.getCoordinates().getLongitude());
    MarkerOptions options = MarkerOptions.newInstance();
    options.setPosition(center);
    MarkerImage icon = MarkerImage.newInstance(AppBundle.INSTANCE.myLocationPNG().getSafeUri().asString());
    icon.setAnchor(Point.newInstance(11, 11));
    options.setOptimized(true);
    options.setIcon(icon);
    myLocationMarker = Marker.newInstance(options);
    myLocationMarker.setMap(mapWidget);

    // create a circle the size of the error
    CircleOptions circleOptions = CircleOptions.newInstance();
    circleOptions.setFillOpacity(0.1);
    circleOptions.setFillColor("#1a75ff");
    circleOptions.setStrokeOpacity(0.12);
    circleOptions.setStrokeWeight(1);
    circleOptions.setStrokeColor("#1a75ff");
    myLocationError = Circle.newInstance(circleOptions);
    myLocationError.setCenter(center);
    myLocationError.setRadius(position.getCoordinates().getAccuracy());
    myLocationError.setMap(mapWidget);

}