001 package com.google.gwt.maps.client.placeslib;
002
003 import com.google.gwt.ajaxloader.client.ArrayHelper;
004 import com.google.gwt.core.client.JavaScriptObject;
005 import com.google.gwt.core.client.JsArrayString;
006 import com.google.gwt.maps.client.base.LatLng;
007 import com.google.gwt.maps.client.base.LatLngBounds;
008
009 /**
010 * A Place search query to be sent to the PlacesService.
011 * <br><br>
012 * See <a href="https://developers.google.com/maps/documentation/javascript/reference#PlaceSearchRequest">PlaceSearchRequest API Doc</a>
013 */
014 public class PlaceSearchRequest extends JavaScriptObject {
015
016 /**
017 * use newInstance();
018 */
019 protected PlaceSearchRequest() {}
020
021 /**
022 * A Place search query to be sent to the PlacesService.
023 */
024 public static final PlaceSearchRequest newInstance() {
025 return JavaScriptObject.createObject().cast();
026 }
027
028 /**
029 * The bounds within which to search for Places. Both location and radius will be ignored if bounds is set.
030 * @param bounds
031 */
032 public final native void setBounds(LatLngBounds bounds) /*-{
033 this.bounds = bounds;
034 }-*/;
035
036 /**
037 * The bounds within which to search for Places. Both location and radius will be ignored if bounds is set.
038 */
039 public final native LatLngBounds getBounds() /*-{
040 return this.bounds;
041 }-*/;
042
043 /**
044 * A term to be matched against all available fields, including but not limited to name, type, and address, as well as customer reviews and other third-party content.
045 * @param keyword
046 */
047 public final native void setKeyword(String keyword) /*-{
048 this.keyword = keyword;
049 }-*/;
050
051 /**
052 * A term to be matched against all available fields, including but not limited to name, type, and address, as well as customer reviews and other third-party content.
053 */
054 public final native String getKeyword() /*-{
055 return this.keyword;
056 }-*/;
057
058 /**
059 * The location around which to search for Places.
060 * @param location
061 */
062 public final native void setLocation(LatLng location) /*-{
063 this.location = location;
064 }-*/;
065
066 /**
067 * The location around which to search for Places.
068 */
069 public final native LatLng getLocation() /*-{
070 return this.location;
071 }-*/;
072
073 /**
074 * Restricts the Place search results to Places that include this text in the name.
075 * @param name
076 */
077 public final native void setName(String name) /*-{
078 this.name = name;
079 }-*/;
080
081 /**
082 * Restricts the Place search results to Places that include this text in the name.
083 */
084 public final native String getName() /*-{
085 return this.name;
086 }-*/;
087
088 /**
089 * The distance from the given location within which to search for Places, in meters. The maximum allowed value is 50000
090 * @param radius
091 */
092 public final native void setRaidus(double radius) /*-{
093 this.radius = radius;
094 }-*/;
095
096 /**
097 * The distance from the given location within which to search for Places, in meters. The maximum allowed value is 50000
098 */
099 public final native double getRaidus() /*-{
100 return this.radius;
101 }-*/;
102
103 /**
104 * Restricts the Place search results to Places with a type matching at least one of the specified types in this array. Valid types are given <a href="https://developers.google.com/maps/documentation/places/supported_types">here</a>.
105 * @param types
106 */
107 public final void setTypes(AutocompleteType... types) {
108 if (types == null) {
109 return;
110 }
111 String[] stypes = new String[types.length];
112 for (int i=0; i < types.length; i++) {
113 stypes[i] = types[i].value();
114 }
115 JsArrayString a = ArrayHelper.toJsArrayString(stypes);
116 setTypesImpl(a);
117 }
118
119 private final native void setTypesImpl(JsArrayString types) /*-{
120 this.types = types;
121 }-*/;
122
123 /**
124 * Restricts the Place search results to Places with a type matching at least one of the specified types in this array. Valid types are given <a href="https://developers.google.com/maps/documentation/places/supported_types">here</a>.
125 */
126 public final AutocompleteType[] getTypes() {
127 JsArrayString at = getTypesImpl();
128 if (at == null) {
129 return null;
130 }
131 AutocompleteType[] types = new AutocompleteType[at.length()];
132 for (int i=0; i < at.length(); i++) {
133 types[i] = AutocompleteType.fromValue(at.get(i));
134 }
135 return types;
136 }
137
138 private final native JsArrayString getTypesImpl() /*-{
139 return this.types;
140 }-*/;
141
142 }