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.LatLngBounds;
007
008 /**
009 * The options that can be set on an Autocomplete.
010 * <br><br>
011 * See <a href="https://developers.google.com/maps/documentation/javascript/reference#AutocompleteOptions">AutocompleteOptions API Doc</a>
012 */
013 public class AutocompleteOptions extends JavaScriptObject {
014
015 /**
016 * use newInstance();
017 */
018 protected AutocompleteOptions() {}
019
020 /**
021 * Create new {@link AutocompleteOptions} instance.
022 */
023 public static final AutocompleteOptions newInstance() {
024 return JavaScriptObject.createObject().cast();
025 }
026
027 /**
028 * The area in which to search for Places. Results are biased towards, but not restricted to, Places contained within these bounds.
029 * @param bounds
030 */
031 public final native void setBounds(LatLngBounds bounds) /*-{
032 this.bounds = bounds;
033 }-*/;
034
035 /**
036 * The area in which to search for Places. Results are biased towards, but not restricted to, Places contained within these bounds.
037 */
038 public final native LatLngBounds getBounds() /*-{
039 return this.bounds;
040 }-*/;
041
042 /**
043 * Sets the types of predictions to be returned. Supported types are 'establishment' for businesses and 'geocode' for addresses. If no type is specified, both types will be returned.
044 * @param types
045 */
046 public final void setTypes(AutocompleteType... types) {
047 if (types == null) {
048 return;
049 }
050 String[] stypes = new String[types.length];
051 for (int i=0; i < types.length; i++) {
052 stypes[i] = types[i].value();
053 }
054 JsArrayString a = ArrayHelper.toJsArrayString(stypes);
055 setTypesImpl(a);
056 }
057
058 private final native void setTypesImpl(JsArrayString types) /*-{
059 this.types = types;
060 }-*/;
061
062 /**
063 * gets The types of predictions to be returned. Supported types are 'establishment' for businesses and 'geocode' for addresses. If neither is specified, both types are returned.
064 */
065 public final AutocompleteType[] getTypes() {
066 JsArrayString at = getTypesImpl();
067 if (at == null) {
068 return null;
069 }
070 AutocompleteType[] types = new AutocompleteType[at.length()];
071 for (int i=0; i < at.length(); i++) {
072 types[i] = AutocompleteType.fromValue(at.get(i));
073 }
074 return types;
075 }
076
077 private final native JsArrayString getTypesImpl() /*-{
078 return this.types;
079 }-*/;
080
081 }