001 package com.google.gwt.maps.client.drawinglib; 002 003 import com.google.gwt.core.client.JavaScriptObject; 004 import com.google.gwt.maps.client.MapImpl; 005 import com.google.gwt.maps.client.MapWidget; 006 import com.google.gwt.maps.client.overlays.CircleOptions; 007 import com.google.gwt.maps.client.overlays.MarkerOptions; 008 import com.google.gwt.maps.client.overlays.PolygonOptions; 009 import com.google.gwt.maps.client.overlays.PolylineOptions; 010 import com.google.gwt.maps.client.overlays.RectangleOptions; 011 012 /** 013 * Options for the drawing manager. 014 * <br><br> 015 * See <a href="https://developers.google.com/maps/documentation/javascript/reference#DrawingManagerOptions">DrawingManagerOptions API Doc</a> 016 */ 017 public class DrawingManagerOptions extends JavaScriptObject { 018 019 /** 020 * use newInstance(); 021 */ 022 protected DrawingManagerOptions() {} 023 024 /** 025 * Options for the drawing manager. 026 */ 027 public static final DrawingManagerOptions newInstance() { 028 return JavaScriptObject.createObject().cast(); 029 } 030 031 /** 032 * Options to apply to any new circles created with this DrawingManager. The center and radius properties are ignored, and the map property of a new circle is always set to the DrawingManager's map. 033 * @param circleOptions 034 */ 035 public final native void setCircleOptions(CircleOptions circleOptions) /*-{ 036 this.circleOptions = circleOptions; 037 }-*/; 038 039 /** 040 * Options to apply to any new circles created with this DrawingManager. The center and radius properties are ignored, and the map property of a new circle is always set to the DrawingManager's map. 041 */ 042 public final native CircleOptions getCircleOptions() /*-{ 043 return this.circleOptions; 044 }-*/; 045 046 /** 047 * The enabled/disabled state of the drawing control. Defaults to true. 048 * @param drawingControl 049 */ 050 public final native void setDrawingControl(boolean drawingControl) /*-{ 051 this.drawingControl = drawingControl; 052 }-*/; 053 054 /** 055 * The enabled/disabled state of the drawing control. Defaults to true. 056 */ 057 public final native boolean getDrawingControl() /*-{ 058 return this.drawingControl; 059 }-*/; 060 061 /** 062 * The display options for the drawing control. 063 * @param drawingControlOptions 064 */ 065 public final native void setDrawingControlOptions(DrawingControlOptions drawingControlOptions) /*-{ 066 this.drawingControlOptions = drawingControlOptions; 067 }-*/; 068 069 /** 070 * The display options for the drawing control. 071 */ 072 public final native DrawingControlOptions getDrawingControlOptions() /*-{ 073 return this.drawingControlOptions; 074 }-*/; 075 076 /** 077 * The DrawingManager's drawing mode, which defines the type of overlay to be added on the map. Accepted values are MARKER, POLYGON, POLYLINE, RECTANGLE, CIRCLE, or null. A drawing mode of null means that the user can interact with the map as normal, and clicks do not draw anything. 078 * @param drawingMode 079 */ 080 public final void setDrawingMode(OverlayType drawingMode) { 081 setDrawingModeImpl(drawingMode.value()); 082 } 083 084 /** 085 * The DrawingManager's drawing mode, which defines the type of overlay to be added on the map. Accepted values are MARKER, POLYGON, POLYLINE, RECTANGLE, CIRCLE, or null. A drawing mode of null means that the user can interact with the map as normal, and clicks do not draw anything. 086 * @param drawingMode 087 */ 088 private native void setDrawingModeImpl(String drawingMode) /*-{ 089 this.drawingMode = drawingMode; 090 }-*/; 091 092 /** 093 * The Map to which the DrawingManager is attached, which is the Map on which the overlays created will be placed. 094 */ 095 public final MapWidget getMap() { 096 return MapWidget.newInstance(getMapImpl()); 097 } 098 099 private final native MapImpl getMapImpl() /*-{ 100 return this.map; 101 }-*/; 102 103 /** 104 * The Map to which the DrawingManager is attached, which is the Map on which the overlays created will be placed. 105 * @param mapWidget 106 */ 107 public final void setMap(MapWidget mapWidget) { 108 setMapImpl(mapWidget.getJso()); 109 } 110 111 private final native void setMapImpl(MapImpl map) /*-{ 112 this.map = map; 113 }-*/; 114 115 /** 116 * Options to apply to any new markers created with this DrawingManager. The position property is ignored, and the map property of a new marker is always set to the DrawingManager's map. 117 * @param markerOptions 118 */ 119 public final native void setMarkerOptions(MarkerOptions markerOptions) /*-{ 120 this.markerOptions = markerOptions; 121 }-*/; 122 123 /** 124 * Options to apply to any new markers created with this DrawingManager. The position property is ignored, and the map property of a new marker is always set to the DrawingManager's map. 125 */ 126 public final native MarkerOptions getMarkerOptions() /*-{ 127 return this.markerOptions; 128 }-*/; 129 130 /** 131 * Options to apply to any new polygons created with this DrawingManager. The paths property is ignored, and the map property of a new polygon is always set to the DrawingManager's map. 132 * @param polygonOptions 133 */ 134 public final native void setPolygonOptions(PolygonOptions polygonOptions) /*-{ 135 this.polygonOptions = polygonOptions; 136 }-*/; 137 138 /** 139 * Options to apply to any new polygons created with this DrawingManager. The paths property is ignored, and the map property of a new polygon is always set to the DrawingManager's map. 140 */ 141 public final native PolygonOptions getPolygonOptions() /*-{ 142 return this.polygonOptions; 143 }-*/; 144 145 /** 146 * Options to apply to any new polylines created with this DrawingManager. The path property is ignored, and the map property of a new polyline is always set to the DrawingManager's map. 147 * @param polylineOptions 148 */ 149 public final native void setPolylineOptions(PolylineOptions polylineOptions) /*-{ 150 this.polylineOptions = polylineOptions; 151 }-*/; 152 153 /** 154 * Options to apply to any new polylines created with this DrawingManager. The path property is ignored, and the map property of a new polyline is always set to the DrawingManager's map. 155 */ 156 public final native PolylineOptions getPolylineOptions() /*-{ 157 return this.polylineOptions; 158 }-*/; 159 160 /** 161 * Options to apply to any new rectangles created with this DrawingManager. The bounds property is ignored, and the map property of a new rectangle is always set to the DrawingManager's map. 162 * @param rectangleOptions 163 */ 164 public final native void setRectangleOptions(RectangleOptions rectangleOptions) /*-{ 165 this.rectangleOptions = rectangleOptions; 166 }-*/; 167 168 /** 169 * Options to apply to any new rectangles created with this DrawingManager. The bounds property is ignored, and the map property of a new rectangle is always set to the DrawingManager's map. 170 */ 171 public final native RectangleOptions getRectangleOptions() /*-{ 172 return this.rectangleOptions; 173 }-*/; 174 175 }