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.core.client.JsArrayString; 006 import com.google.gwt.maps.client.base.LatLng; 007 import com.google.gwt.maps.client.workaround.WorkAroundUtils; 008 009 /** 010 * A distance matrix query sent by the DistanceMatrixService containing arrays of origin and destination locations, and various options for computing metrics. 011 * <br><br> 012 * See <a href="https://developers.google.com/maps/documentation/javascript/reference#DistanceMatrixRequest">DistanceMatrixRequest API Doc</a> 013 */ 014 public class DistanceMatrixRequest extends JavaScriptObject { 015 016 /** 017 * use newInstance(); 018 */ 019 protected DistanceMatrixRequest() {} 020 021 /** 022 * A distance matrix query sent by the DistanceMatrixService containing arrays of origin and destination locations, and various options for computing metrics. 023 */ 024 public static final DistanceMatrixRequest newInstance() { 025 JavaScriptObject jso = JavaScriptObject.createObject(); 026 WorkAroundUtils.removeGwtObjectId(jso); 027 return jso.cast(); 028 } 029 030 /** 031 * If true, instructs the Distance Matrix service to avoid highways where possible. Optional. 032 * @param avoidHighways 033 */ 034 public final native void setAvoidHighways(boolean avoidHighways) /*-{ 035 this.avoidHighways = avoidHighways; 036 }-*/; 037 038 /** 039 * If true, instructs the Distance Matrix service to avoid highways where possible. Optional. 040 */ 041 public final native boolean getAvoidHighways() /*-{ 042 return this.avoidHighways; 043 }-*/; 044 045 /** 046 * If true, instructs the Distance Matrix service to avoid toll roads where possible. Optional. 047 * @param avoidTolls 048 */ 049 public final native void setAvoidTolls(boolean avoidTolls) /*-{ 050 this.avoidTolls = avoidTolls; 051 }-*/; 052 053 /** 054 * If true, instructs the Distance Matrix service to avoid toll roads where possible. Optional. 055 */ 056 public final native boolean getAvoidTolls() /*-{ 057 return this.avoidTolls; 058 }-*/; 059 060 /** 061 * An array containing destination address strings and/or LatLngs, to which to calculate distance and time. Required. 062 * @param destinations 063 */ 064 public final native void setDestinations(JsArray<LatLng> destinations) /*-{ 065 this.destinations = destinations; 066 }-*/; 067 068 /** 069 * An array containing destination address strings and/or LatLngs, to which to calculate distance and time. Required. 070 */ 071 public final native JsArray<LatLng> getDestinations() /*-{ 072 return this.destinations; 073 }-*/; 074 075 /** 076 * An array containing destination address strings and/or LatLngs, to which to calculate distance and time. Required. 077 * @param destinations 078 */ 079 public final native void setDestinations(JsArrayString destinations) /*-{ 080 this.destinations = destinations; 081 }-*/; 082 083 /** 084 * An array containing destination address strings and/or LatLngs, to which to calculate distance and time. Required. 085 */ 086 public final native JsArrayString getDestinations_Strings() /*-{ 087 return this.destinations; 088 }-*/; 089 090 /** 091 * An array containing origin address strings and/or LatLngs, from which to calculate distance and time. Required. 092 * @param origins 093 */ 094 public final native void setOrigins(JsArray<LatLng> origins) /*-{ 095 this.origins = origins; 096 }-*/; 097 098 /** 099 * An array containing origin address strings and/or LatLngs, from which to calculate distance and time. Required. 100 */ 101 public final native JsArray<LatLng> getOrigins() /*-{ 102 return this.origins; 103 }-*/; 104 105 /** 106 * An array containing origin address strings and/or LatLngs, from which to calculate distance and time. Required. 107 * @param origins 108 */ 109 public final native void setOrigins(JsArrayString origins) /*-{ 110 this.origins = origins; 111 }-*/; 112 113 /** 114 * An array containing origin address strings and/or LatLngs, from which to calculate distance and time. Required. 115 */ 116 public final native JsArrayString getOrigins_Strings() /*-{ 117 return this.origins; 118 }-*/; 119 120 /** 121 * Region code used as a bias for geocoding requests. Optional. 122 * @param region 123 */ 124 public final native void setRegion(String region) /*-{ 125 this.region = region; 126 }-*/; 127 128 /** 129 * Create new {@link DistanceMatrixRequest} instance 130 */ 131 public final native String getRegion() /*-{ 132 return this.region; 133 }-*/; 134 135 /** 136 * Region code used as a bias for geocoding requests. Optional. 137 * @param travelMode 138 */ 139 public final void setTravelMode(TravelMode travelMode) { 140 setTravelModeImpl(travelMode.value()); 141 } 142 143 private final native void setTravelModeImpl(String travelMode) /*-{ 144 this.travelMode = travelMode; 145 }-*/; 146 147 /** 148 * Type of routing requested. Required. 149 */ 150 public final TravelMode getTravelMode() { 151 return TravelMode.fromValue(getTravelModeImpl()); 152 } 153 154 private final native String getTravelModeImpl() /*-{ 155 return this.travelMode; 156 }-*/; 157 158 /** 159 * Type of routing requested. Required. 160 * @param unitSystem 161 */ 162 public final void setUnitSystem(UnitSystem unitSystem) { 163 setUnitSystemImpl(unitSystem.value()); 164 } 165 166 private final native void setUnitSystemImpl(int unitSystem) /*-{ 167 this.unitSystem = unitSystem; 168 }-*/; 169 170 /** 171 * Preferred unit system to use when displaying distance. Optional; defaults to metric. 172 */ 173 public final UnitSystem getUnitSystem() { 174 return UnitSystem.fromValue(getUnitSystemImpl()); 175 } 176 177 private final native int getUnitSystemImpl() /*-{ 178 return this.unitSystem; 179 }-*/; 180 181 }