Example usage for com.google.gwt.maps.client.overlay Polygon addPolygonCancelLineHandler

List of usage examples for com.google.gwt.maps.client.overlay Polygon addPolygonCancelLineHandler

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.overlay Polygon addPolygonCancelLineHandler.

Prototype

public void addPolygonCancelLineHandler(final PolygonCancelLineHandler handler) 

Source Link

Document

This event is fired when the polygon is being edited and the edit is canceled.

Usage

From source file:com.google.gwt.maps.sample.hellomaps.client.DrawingOverlayDemo.java

License:Apache License

private void createPolygon() {
    PolyStyleOptions style = PolyStyleOptions.newInstance(color, weight, opacity);

    final Polygon poly = new Polygon(new LatLng[0], color, weight, opacity, color, fillFlag ? .7 : 0.0);
    lastPolygon = poly;//from  w ww . jav a  2s. c  o  m
    map.addOverlay(poly);
    poly.setDrawingEnabled();
    poly.setStrokeStyle(style);
    message2.setText("");
    poly.addPolygonLineUpdatedHandler(new PolygonLineUpdatedHandler() {

        public void onUpdate(PolygonLineUpdatedEvent event) {
            message2.setText(message2.getText() + " : Polygon Updated");
        }
    });

    poly.addPolygonCancelLineHandler(new PolygonCancelLineHandler() {

        public void onCancel(PolygonCancelLineEvent event) {
            message2.setText(message2.getText() + " : Polygon Cancelled");
        }
    });

    poly.addPolygonEndLineHandler(new PolygonEndLineHandler() {

        public void onEnd(PolygonEndLineEvent event) {
            message2.setText(message2.getText() + " : Polygon End at " + event.getLatLng() + ".  Bounds="
                    + poly.getBounds().getNorthEast() + "," + poly.getBounds().getSouthWest() + " area="
                    + poly.getArea() + "m");
        }
    });
}