Java GWT:UiBinder&x2B;输入元素

Java GWT:UiBinder&x2B;输入元素,java,google-maps,gwt,uibinder,Java,Google Maps,Gwt,Uibinder,我正在尝试在我的GWT web应用程序中添加一个搜索栏,它利用了InputElement和AutoComplete。搜索栏主要用于搜索谷歌地图上的位置。 以下是我迄今为止编写的代码: @UiField InputElement input; // // // final Autocomplete autocomplete = Autocomplete.create(input); final InfoWindow infowindow= InfoWindow.cre

我正在尝试在我的GWT web应用程序中添加一个搜索栏,它利用了InputElement和AutoComplete。搜索栏主要用于搜索谷歌地图上的位置。 以下是我迄今为止编写的代码:

@UiField
InputElement input;
//
//
//
final Autocomplete autocomplete = Autocomplete.create(input);       
        final InfoWindow infowindow= InfoWindow.create();
        autocomplete.addPlaceChangedListener(new PlaceChangedHandler(){
            public void handle(){
                PlaceResult place=autocomplete.getPlace();
                String address=place.getAddressComponents().get(0).getShortName();
                infowindow.setContent(place.getName()+", "+address);            
                addMarker(place.getGeometry().getLocation(),place,infowindow);  
                map.setCenter(place.getGeometry().getLocation());
                map.setZoom(17.0);       

            }
        });
//
//
//
<g:north size='5'>
            <g:HTMLPanel>
                <div>
                    <g:Label ui:field="label1">PublicFortress</g:Label> 
                </div>
                <div>
                    <g:Anchor ui:field="signin" href="#">SignIn</g:Anchor>
                    <g:Button ui:field="home">Home</g:Button>
                    <div>
                        <input type="text" name="Search" ui:field="input" class="custom" />
                    </div>

                </div>          

            </g:HTMLPanel>
        </g:north>
@UiField
输入元素输入;
//
//
//
最终自动完成自动完成=自动完成。创建(输入);
final InfoWindow=InfoWindow.create();
autocomplete.addPlaceChangedListener(新的PlaceChangedHandler(){
公共无效句柄(){
PlaceResult place=autocomplete.getPlace();
字符串地址=place.getAddressComponents().get(0.getShortName();
infowindow.setContent(place.getName()+“,”+地址);
addMarker(place.getGeometry().getLocation(),place,infowindow);
map.setCenter(place.getGeometry().getLocation());
map.setZoom(17.0);
}
});
//
//
//
公共要塞
签名
家
我知道这不是正确的工作方式,因此我得到以下错误:

com.google.gwt.core.client.JavaScriptException:(TypeError) @com.google.maps.gwt.client.places.Autocomplete::create(Lcom/google/gwt/dom/client/InputElement;)([JavaScript 对象(30)]:$wnd.google.maps.places未定义 位于com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:249)

请帮忙

我让它工作了。 守则的主要部分如下:

1) 在.html文件中:(这是我之前错过的部分)


你为什么不改用呢?我试过用g:TextBox,我也有同样的错误。我做的主要改变是:1)搜索2)@UiField文本框输入;3) final Autocomplete Autocomplete=Autocomplete.newInstance(input.getElement(),null);抱歉,错误不一样:com.google.gwt.core.client.JavaScriptException:(TypeError)@com.google.gwt.maps.client.placeslib.Autocomplete::createJso(Lcom/google/gwt/dom/client/Element;Lcom/google/gwt/maps/client/placeslib/AutocompleteOptions;)([JavaScript对象(36,null]):$wnd.google.maps.places未定义
<head>
.
.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
</head>
final AutocompleteOptions options = AutocompleteOptions.newInstance();
        final Autocomplete autocomplete = Autocomplete.newInstance(input.getElement(), options);    
        final InfoWindow infowindow= InfoWindow.create();
        autocomplete.addPlaceChangeHandler(new PlaceChangeMapHandler(){

            @Override
            public void onEvent(PlaceChangeMapEvent event) {
                PlaceResult place=autocomplete.getPlace();
                String address=place.getAddress_Components().get(0).getShort_Name();
                infowindow.setContent(place.getName()+", "+address);        
                LatLng latLng = LatLng.create(place.getGeometry().getLocation().getLatitude(), place.getGeometry().getLocation().getLongitude());
                addMarker(latLng,place,infowindow); 
                map.setCenter(latLng);
                map.setZoom(17.0);              
            }
        });