List of usage examples for com.google.gwt.maps.client.geocode LatLngCallback LatLngCallback
LatLngCallback
From source file:com.apress.progwt.client.util.BulkGeoCoder.java
License:Apache License
@Override public void run() { final HasAddress school = schools.remove(0); if (school == null) { Log.debug("Finished"); cancel();/* w w w .j av a2 s.com*/ return; } final String full = school.getFullAddress(); Geocoder geocoder = new Geocoder(); geocoder.getLatLng("1600 pennsylvania avenue, washington dc", new LatLngCallback() { public void onFailure() { } public void onSuccess(LatLng point) { } }); geocoder.getLatLng(full, new LatLngCallback() { public void onFailure() { Log.debug("UPDATE " + tablename + " SET latitude = '-1',longitude = '-1' WHERE id =" + school.getId() + " LIMIT 1 ;"); run(); } public void onSuccess(LatLng point) { Log.debug("UPDATE " + tablename + " SET latitude = '" + point.getLatitude() + "',longitude = '" + point.getLongitude() + "' WHERE id =" + school.getId() + " LIMIT 1 ;"); run(); } }); }
From source file:com.google.gwt.maps.sample.hellomaps.client.GeocoderDemo.java
License:Apache License
private void showAddress(final String address) { final InfoWindow info = map.getInfoWindow(); geocoder.getLatLng(address, new LatLngCallback() { public void onFailure() { Window.alert(address + " not found"); }//from www . j av a 2 s .c o m public void onSuccess(LatLng point) { map.setCenter(point, 13); Marker marker = new Marker(point); map.addOverlay(marker); info.open(marker, new InfoWindowContent(address)); displayLatLng(point); } }); }
From source file:com.google.livingstories.client.contentmanager.ContentItemManager.java
License:Apache License
/** * Creates event handlers for the Locations UI. *//*from w w w.j av a2 s .c om*/ private void createLocationHandlers() { // first, set up interactions between the widgets: final ClickHandler radioHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { adjustLocationControls(); controlGeocodeButton(); } }; final KeyUpHandler textHandler = new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { controlGeocodeButton(); } }; useDisplayedLocation.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { radioHandler.onClick(event); locationDescriptionTextArea.setFocus(true); } }); useAlternateLocation.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { radioHandler.onClick(event); alternateTextBox.setFocus(true); } }); useManualLatLong.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { radioHandler.onClick(event); latitudeTextBox.setFocus(true); } }); locationDescriptionTextArea.addKeyUpHandler(textHandler); alternateTextBox.addKeyUpHandler(textHandler); latitudeTextBox.addKeyUpHandler(textHandler); longitudeTextBox.addKeyUpHandler(textHandler); // Actually handle the geocode button: geocodeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (useManualLatLong.getValue()) { // the latitude and longitude textboxes already have the right values in them recenterMap(); } else { String address = (useDisplayedLocation.getValue() ? locationDescriptionTextArea : alternateTextBox).getText(); geocoderStatus.setText(""); new Geocoder().getLatLng(address, new LatLngCallback() { @Override public void onFailure() { geocoderStatus.setText("geocoding failed!"); } @Override public void onSuccess(LatLng point) { geocoderStatus.setText("success"); latitudeTextBox.setText(String.valueOf(point.getLatitude())); longitudeTextBox.setText(String.valueOf(point.getLongitude())); recenterMap(); } }); } } }); map.addMapRightClickHandler(new MapRightClickHandler() { @Override public void onRightClick(MapRightClickEvent event) { LatLng clickedLatLng = map.convertContainerPixelToLatLng(event.getPoint()); latitudeTextBox.setText(String.valueOf(clickedLatLng.getLatitude())); longitudeTextBox.setText(String.valueOf(clickedLatLng.getLongitude())); useManualLatLong.setValue(true); useManualLatLong.fireEvent(new ClickEvent() { }); recenterMap(); } }); }
From source file:com.google.livingstories.plugins.wordpress.livingstorypropertymanager.client.ui.LocationInput.java
License:Apache License
/** * Creates event handlers for the Locations UI. *//* w w w . j a va2 s. c om*/ private void createLocationHandlers() { // first, set up interactions between the widgets: final ClickHandler radioHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { adjustLocationControls(); controlGeocodeButton(); } }; final KeyUpHandler textHandler = new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { controlGeocodeButton(); } }; useDisplayedLocation.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { radioHandler.onClick(event); locationDescriptionTextArea.setFocus(true); } }); useAlternateLocation.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { radioHandler.onClick(event); alternateTextBox.setFocus(true); } }); useManualLatLong.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { radioHandler.onClick(event); latitudeTextBox.setFocus(true); } }); locationDescriptionTextArea.addKeyUpHandler(textHandler); alternateTextBox.addKeyUpHandler(textHandler); latitudeTextBox.addKeyUpHandler(textHandler); longitudeTextBox.addKeyUpHandler(textHandler); // Actually handle the geocode button: geocodeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (useManualLatLong.getValue()) { // the latitude and longitude textboxes already have the right values in them recenterMap(); } else { String address = (useDisplayedLocation.getValue() ? locationDescriptionTextArea : alternateTextBox).getText(); geocoderStatus.setText(""); new Geocoder().getLatLng(address, new LatLngCallback() { @Override public void onFailure() { geocoderStatus.setText("geocoding failed!"); } @Override public void onSuccess(LatLng point) { geocoderStatus.setText("success"); latitudeTextBox.setText(String.valueOf(point.getLatitude())); longitudeTextBox.setText(String.valueOf(point.getLongitude())); updateHiddenFieldValues(); recenterMap(); } }); } } }); map.addMapRightClickHandler(new MapRightClickHandler() { @Override public void onRightClick(MapRightClickEvent event) { LatLng clickedLatLng = map.convertContainerPixelToLatLng(event.getPoint()); latitudeTextBox.setText(String.valueOf(clickedLatLng.getLatitude())); longitudeTextBox.setText(String.valueOf(clickedLatLng.getLongitude())); useManualLatLong.setValue(true); useManualLatLong.fireEvent(new ClickEvent() { }); updateHiddenFieldValues(); recenterMap(); } }); }
From source file:com.ui.gwt.mobile.client.components.DetailPanel.java
License:Apache License
public void buildMap(Contact data) { if (mapWidget == null) { map.addClassName(AppResources.INSTANCE.css().map()); mapWidget = new MapWidget(); mapWidget.setWidth("100%"); mapWidget.setHeight("400px"); geocoder = new Geocoder(); add(mapWidget);/*from w w w . j ava 2 s . c o m*/ } final InfoWindow info = mapWidget.getInfoWindow(); final String address = data.getAddr1() + " " + data.getAddr2(); geocoder.getLatLng(address, new LatLngCallback() { @Override public void onFailure() { } @Override public void onSuccess(LatLng point) { mapWidget.setCenter(point, 13); Marker marker = new Marker(point); mapWidget.clearOverlays(); mapWidget.addOverlay(marker); info.open(marker, new InfoWindowContent(address)); } }); }