branflake2267 / GWT-Maps-V3-Api

GWT Maps V3 Javascript Bindings
Other
144 stars 113 forks source link

Error in AutoComplete #243

Open vipul-mykaarma opened 4 years ago

vipul-mykaarma commented 4 years ago

Hi all, I am getting the error

places_impl.js:30 Uncaught TypeError: Cannot read property 'trim' of undefined at V9 (placesimpl.js:30) at O9..r.vm (places_impl.js:61)

`

    AutocompleteType[] types = new AutocompleteType[1];
    types[0] = AutocompleteType.LOCALITY;
    AutocompleteOptions options = AutocompleteOptions.newInstance();
    options.setTypes(types);
    final Autocomplete autoComplete = Autocomplete.newInstance(
            tb.getElement(), options);

     autoComplete.addPlaceChangeHandler(new PlaceChangeMapHandler() {
            public void onEvent(PlaceChangeMapEvent event) {
                PlaceResult result = autoComplete.getPlace();

                //result.getGeometry().getLocation().ge
                tb.setValue(result.getName());
            }
        });

     tb.addKeyDownHandler(new KeyDownHandler() {           
            @Override
            public void onKeyDown(KeyDownEvent event) {             
                if(event.getNativeKeyCode() == KeyCodes.KEY_ENTER){
                    GWT.log("Blocking form submit for autocomplete text box");
                    event.preventDefault();
                }
            }
        });`