Java tutorial
package com.google.gwt.maps.client.overlays; /* * #%L * GWT Maps API V3 - Core API * %% * Copyright (C) 2011 - 2012 GWT Maps API V3 * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.maps.client.MapImpl; import com.google.gwt.maps.client.MapWidget; import com.google.gwt.maps.client.base.LatLng; import com.google.gwt.maps.client.base.LatLngBounds; import com.google.gwt.maps.client.events.MapEventType; import com.google.gwt.maps.client.events.MapHandlerRegistration; import com.google.gwt.maps.client.events.center.CenterChangeEventFormatter; import com.google.gwt.maps.client.events.center.CenterChangeMapHandler; import com.google.gwt.maps.client.events.click.ClickEventFormatter; import com.google.gwt.maps.client.events.click.ClickMapHandler; import com.google.gwt.maps.client.events.dblclick.DblClickEventFormatter; import com.google.gwt.maps.client.events.dblclick.DblClickMapHandler; import com.google.gwt.maps.client.events.mousedown.MouseDownEventFormatter; import com.google.gwt.maps.client.events.mousedown.MouseDownMapHandler; import com.google.gwt.maps.client.events.mousemove.MouseMoveEventFormatter; import com.google.gwt.maps.client.events.mousemove.MouseMoveMapHandler; import com.google.gwt.maps.client.events.mouseout.MouseOutEventFormatter; import com.google.gwt.maps.client.events.mouseout.MouseOutMapHandler; import com.google.gwt.maps.client.events.mouseover.MouseOverEventFormatter; import com.google.gwt.maps.client.events.mouseover.MouseOverMapHandler; import com.google.gwt.maps.client.events.mouseup.MouseUpEventFormatter; import com.google.gwt.maps.client.events.mouseup.MouseUpMapHandler; import com.google.gwt.maps.client.events.radius.RadiusChangeEventFormatter; import com.google.gwt.maps.client.events.radius.RadiusChangeMapHandler; import com.google.gwt.maps.client.events.rightclick.RightClickEventFormatter; import com.google.gwt.maps.client.events.rightclick.RightClickMapHandler; import com.google.gwt.maps.client.mvc.MVCObject; /** * A circle overlay. This class extends MVCObject. <br> * <br> * See <a href= "https://developers.google.com/maps/documentation/javascript/reference#Circle" >Circle API Doc</a> */ public class Circle extends MVCObject<Circle> { /** * use newInstance(); */ protected Circle() { } /** * Create a circle using the passed CircleOptions, which specify the bounds and style. * * @param options */ public final static Circle newInstance(CircleOptions options) { return createJso(options).cast(); } private final static native JavaScriptObject createJso(CircleOptions options) /*-{ return new $wnd.google.maps.Circle(options); }-*/; /** * Returns the bounds of this circle. */ public final native LatLngBounds getBounds() /*-{ return this.getBounds(); }-*/; /** * set center. * * @param latlng */ public final native void setCenter(LatLng latlng) /*-{ this.setCenter(latlng); }-*/; /** * Returns the center of this circle. */ public final native LatLng getCenter() /*-{ return this.getCenter(); }-*/; /** * Returns whether this circle can be edited by the user. */ public final native boolean getEditable() /*-{ return this.getEditable(); }-*/; /** * Renders the circle on the specified map. If map is set to null, the circle will be removed. * * @param mapWidget */ public final void setMap(MapWidget mapWidget) { if (mapWidget == null) { setMapImpl(null); } else { setMapImpl(mapWidget.getJso()); } } private final native void setMapImpl(MapImpl map) /*-{ this.setMap(map); }-*/; /** * Returns the map on which this circle is displayed. */ public final MapWidget getMap() { return MapWidget.newInstance(getMapImpl()); } private final native MapImpl getMapImpl() /*-{ return this.getMap(); }-*/; /** * If set to true, the user can edit this circle by dragging the control points shown at the corners and on each edge. * * @param editable */ public final native void setEditable(boolean editable) /*-{ this.setEditable(editable); }-*/; /** * sets the Circle options * * @param options */ public final native void setOptions(CircleOptions options) /*-{ this.options = options; }-*/; /** * Sets the radius of this circle (in meters). * * @param radius */ public final native void setRadius(double radius) /*-{ this.setRadius(radius); }-*/; /** * Returns the radius of this circle (in meters). */ public final native double getRadius() /*-{ return this.getRadius(); }-*/; /** * add center change handler * * @param handler */ public final HandlerRegistration addCenterChangeHandler(CenterChangeMapHandler handler) { return MapHandlerRegistration.addHandler(this, MapEventType.CENTER_CHANGED, handler, new CenterChangeEventFormatter()); } /** * This event is fired when the DOM click event is fired on the Circle. * * @param handler */ public final HandlerRegistration addClickHandler(ClickMapHandler handler) { return MapHandlerRegistration.addHandler(this, MapEventType.CLICK, handler, new ClickEventFormatter()); } /** * This event is fired when the DOM dblclick event is fired on the Circle. * * @param handler */ public final HandlerRegistration addDblClickHandler(DblClickMapHandler handler) { return MapHandlerRegistration.addHandler(this, MapEventType.DBLCLICK, handler, new DblClickEventFormatter()); } /** * This event is fired when the DOM mousedown event is fired on the Circle. * * @param handler */ public final HandlerRegistration addMouseDownHandler(MouseDownMapHandler handler) { return MapHandlerRegistration.addHandler(this, MapEventType.MOUSEDOWN, handler, new MouseDownEventFormatter()); } /** * This event is fired when the DOM mousemove event is fired on the Circle. * * @param handler */ public final HandlerRegistration addMouseMoveHandler(MouseMoveMapHandler handler) { return MapHandlerRegistration.addHandler(this, MapEventType.MOUSEMOVE, handler, new MouseMoveEventFormatter()); } /** * This event is fired on Circle mouseout. * * @param handler */ public final HandlerRegistration addMouseOutMoveHandler(MouseOutMapHandler handler) { return MapHandlerRegistration.addHandler(this, MapEventType.MOUSEOUT, handler, new MouseOutEventFormatter()); } /** * This event is fired on Circle mouseover. * * @param handler */ public final HandlerRegistration addMouseOverHandler(MouseOverMapHandler handler) { return MapHandlerRegistration.addHandler(this, MapEventType.MOUSEOVER, handler, new MouseOverEventFormatter()); } /** * This event is fired when the DOM mouseup event is fired on the Circle. * * @param handler */ public final HandlerRegistration addMouseUpHandler(MouseUpMapHandler handler) { return MapHandlerRegistration.addHandler(this, MapEventType.MOUSEUP, handler, new MouseUpEventFormatter()); } /** * This event is fired when the circle's radius is changed. * * @param handler */ public final HandlerRegistration addRadiusChangeHandler(RadiusChangeMapHandler handler) { return MapHandlerRegistration.addHandler(this, MapEventType.RADIUS_CHANGED, handler, new RadiusChangeEventFormatter()); } /** * This event is fired when the Circle is right-clicked on. * * @param handler */ public final HandlerRegistration addRightClickHandler(RightClickMapHandler handler) { return MapHandlerRegistration.addHandler(this, MapEventType.RIGHTCLICK, handler, new RightClickEventFormatter()); } }