List of usage examples for com.google.gwt.maps.client.services Geocoder newInstance
public static final Geocoder newInstance()
From source file:net.cbtltd.client.field.LocationField.java
/** * Sets the location name and invokes the geocoder to get its position. * * @param name the new location name./*from w w w . j a v a2 s . c o m*/ */ public void setName(String name) { if (name == null || name.isEmpty()) { return; } GeocoderRequest rq = GeocoderRequest.newInstance(); rq.setAddress(name); Geocoder geocoder = Geocoder.newInstance(); geocoder.geocode(rq, new GeocoderRequestHandler() { @Override public void onCallback(JsArray<GeocoderResult> rs, GeocoderStatus status) { if (status == GeocoderStatus.OK) { GeocoderResult location = rs.get(0); setValueAndFireChange(location.getGeometry().getLocation()); } else { addMessage(Level.ERROR, "Geocode failed: " + status.toString(), null); } } }); }
From source file:net.cbtltd.client.field.MapField.java
/** * Sets the location name and invokes the geocoder to get its position. * * @param name the new location name./* w w w.j a va2s . c o m*/ */ public void setName(String name) { if (name == null || name.isEmpty()) { return; } GeocoderRequest rq = GeocoderRequest.newInstance(); rq.setAddress(name); Geocoder geocoder = Geocoder.newInstance(); geocoder.geocode(rq, new GeocoderRequestHandler() { @Override public void onCallback(JsArray<GeocoderResult> rs, GeocoderStatus status) { if (status == GeocoderStatus.OK) { GeocoderResult location = rs.get(0); setValue(location.getGeometry().getLocation()); } else { addMessage(Level.ERROR, "Geocode failed: " + status.toString(), null); } } }); }
From source file:org.rebioma.client.maps.GeocoderControl.java
License:Apache License
public GeocoderControl(GeocoderRequestHandler requestHandler) { super();// w w w . java 2 s. c o m this.geocoderRequestHandler = requestHandler; this.geocoderRequest = GeocoderRequest.newInstance(); this.geocoder = Geocoder.newInstance(); final FormPanel form = new FormPanel(); form.setAction("#"); Panel formElements = new FlowPanel(); addressBox.setVisibleLength(26); addressBox.selectAll(); formElements.add(addressBox); submit = new Button("Find place"); formElements.add(submit); submit.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { String address = getAddress(); if (address == null || address.trim().length() == 0) { Window.alert("Please enter an address."); return; } form.submit(); } }); // formElements.add(new HTML(" ")); form.add(formElements); form.addSubmitHandler(new SubmitHandler() { public void onSubmit(SubmitEvent event) { lookupAddress(addressBox.getText()); event.cancel(); } }); add(form); }