001    package com.google.gwt.maps.client.services;
002    
003    import com.google.gwt.core.client.JavaScriptObject;
004    import com.google.gwt.core.client.JsArray;
005    import com.google.gwt.maps.client.base.LatLng;
006    import com.google.gwt.maps.client.workaround.WorkAroundUtils;
007    
008    /**
009     * A directions query to be sent to the DirectionsService.
010     * <br><br>
011     * See <a href="https://developers.google.com/maps/documentation/javascript/reference#DirectionsRequest">DirectionsRequest API Doc</a>
012     */
013    public class DirectionsRequest extends JavaScriptObject {
014    
015      /**
016       * use newInstance();
017       */
018      protected DirectionsRequest() {}
019      
020      /**
021       * A directions query to be sent to the DirectionsService.
022       */
023      public static final DirectionsRequest newInstance() {
024        JavaScriptObject jso = JavaScriptObject.createObject();
025        WorkAroundUtils.removeGwtObjectId(jso);
026        return jso.cast();
027      }
028      
029    //  public final native void test() /*-{
030    //    this.origin = "Arlington, WA";
031    //    this.destination = "Seattle, WA";
032    //    this.travelMode = $wnd.google.maps.TravelMode.DRIVING;
033    //  }-*/;
034      
035      
036      /**
037       * If true, instructs the Directions service to avoid highways where possible. Optional.
038       * @param avoidHighways
039       */
040      public final native void setAvoidHighways(boolean avoidHighways) /*-{
041        this.avoidHighways = avoidHighways;
042      }-*/;
043      
044      /**
045       * If true, instructs the Directions service to avoid highways where possible. Optional.
046       */
047      public final native boolean getAvoidHighways() /*-{
048        return this.avoidHighways;
049      }-*/;
050      
051      /**
052       * If true, instructs the Directions service to avoid toll roads where possible. Optional.
053       * @param avoidTolls
054       */
055      public final native void setAvoidTolls(boolean avoidTolls) /*-{
056        this.avoidTolls = avoidTolls;
057      }-*/;
058      
059      /**
060       * If true, instructs the Directions service to avoid toll roads where possible. Optional.
061       */
062      public final native boolean getAvoidTolls() /*-{
063        return this.avoidTolls;
064      }-*/;
065    
066      /**
067       * Location of destination. This can be specified as either a string to be geocoded or a LatLng. Required.
068       * @param destination
069       */
070      public final native void setDestination(String destination) /*-{
071        this.destination = destination;
072      }-*/;
073      
074      /**
075       * Location of destination. This can be specified as either a string to be geocoded or a LatLng.
076       */
077      public final native String getDestination_String() /*-{
078        return this.destination;
079      }-*/;
080      
081      /**
082       * Location of destination. This can be specified as either a string to be geocoded or a LatLng. Required.
083       * @param destination
084       */
085      public final native void setDestination(LatLng destination) /*-{
086        this.destination = destination;
087      }-*/;
088      
089      /**
090       * Location of destination. This can be specified as either a string to be geocoded or a LatLng.
091       */
092      public final native LatLng getDestination_LatLng() /*-{
093        return this.destination;
094      }-*/;
095      
096      /**
097       * If set to true, the DirectionService will attempt to re-order the supplied intermediate waypoints to minimize overall cost of the route. If waypoints are optimized, inspect DirectionsRoute.waypoint_order in the response to determine the new ordering.
098       * @param optimizeWaypoints
099       */
100      public final native void setOptimizeWaypoints(boolean optimizeWaypoints) /*-{
101        this.optimizeWaypoints = optimizeWaypoints;
102      }-*/;
103      
104      /**
105       * If set to true, the DirectionService will attempt to re-order the supplied intermediate waypoints to minimize overall cost of the route. If waypoints are optimized, inspect DirectionsRoute.waypoint_order in the response to determine the new ordering.
106       */
107      public final native boolean getOptimizeWaypoints() /*-{
108        return this.optimizeWaypoints;
109      }-*/;
110      
111      /**
112       * Location of origin. This can be specified as either a string to be geocoded or a LatLng. Required.
113       * @param origin
114       */
115      public final native void setOrigin(String origin) /*-{
116        this.origin = origin;
117      }-*/;
118      
119      /**
120       * Location of origin. This can be specified as either a string to be geocoded or a LatLng.
121       */
122      public final native String getOrigin_String() /*-{
123        return this.origin;
124      }-*/;
125      
126      /**
127       * Location of origin. This can be specified as either a string to be geocoded or a LatLng. Required.
128       * @param origin
129       */
130      public final native void setOrigin(LatLng origin) /*-{
131        this.origin = origin;
132      }-*/;
133      
134      /**
135       * Location of origin. This can be specified as either a string to be geocoded or a LatLng.
136       */
137      public final native LatLng getOrigin_LatLng() /*-{
138        return this.origin;
139      }-*/;
140      
141      /**
142       * Whether or not route alternatives should be provided. Optional.
143       * @param provideRouteAlternatives
144       */
145      public final native void setProvideRouteAlternatives(boolean provideRouteAlternatives) /*-{
146        this.provideRouteAlternatives = provideRouteAlternatives;
147      }-*/;
148      
149      /**
150       * Whether or not route alternatives should be provided. Optional.
151       */
152      public final native boolean getProvideRouteAlternatives() /*-{
153        return this.provideRouteAlternatives;
154      }-*/;
155      
156      /**
157       * Region code used as a bias for geocoding requests. Optional.
158       * @param region
159       */
160      public final native void setRegion(String region) /*-{
161        this.region = region;
162      }-*/;
163      
164      /**
165       * Region code used as a bias for geocoding requests. Optional.
166       */
167      public final native String getRegion() /*-{
168        return this.region;
169      }-*/;
170      
171      /**
172       * Type of routing requested. Required.
173       * @param travelMode
174       */
175      public final void setTravelMode(TravelMode travelMode) {
176        setTravelModeImpl(travelMode.value());
177      }
178    
179      private final native void setTravelModeImpl(String travelMode) /*-{
180        this.travelMode = "DRIVING";
181      }-*/;
182      
183      /**
184       * Type of routing requested. Required.
185       */
186      public final TravelMode getTravelMode() {
187        return TravelMode.fromValue(getTravelModeImpl());
188      }
189    
190      private final native String getTravelModeImpl() /*-{
191        return this.travelMode;
192      }-*/;
193      
194      /**
195       * Preferred unit system to use when displaying distance. Defaults to the unit system used in the country of origin.
196       * @param unitSystem
197       */
198      public final void setUnitSystem(UnitSystem unitSystem) {
199        setUnitSystemImpl(unitSystem.value());
200      }
201      
202      private final native void setUnitSystemImpl(int unitSystem) /*-{
203        this.unitSystem = unitSystem;
204      }-*/;
205      
206      /**
207       * Preferred unit system to use when displaying distance. Defaults to the unit system used in the country of origin.
208       */
209      public final UnitSystem getUnitSystem() {
210        return UnitSystem.fromValue(getUnitSystemImpl());
211      }
212      
213      private final native int getUnitSystemImpl() /*-{
214        return this.unitSystem;
215      }-*/;
216      
217      /**
218       * Array of intermediate waypoints. Directions will be calculated from the origin to the destination by way of each waypoint in this array. Optional.
219       * @param waypoints
220       */
221      public final native void setWaypoints(JsArray<DirectionsWaypoint> waypoints) /*-{
222        this.waypoints = waypoints;
223      }-*/; 
224      
225      /**
226       * Array of intermediate waypoints. Directions will be calculated from the origin to the destination by way of each waypoint in this array. Optional.
227       */
228      public final native JsArray<DirectionsWaypoint> getWaypoints() /*-{
229        return this.waypoints;
230      }-*/;
231      
232    }