???????????????????????MIT????Joe Pasqua??????е???????δ????????????????λ?????????????????????????????????γ???

????public static Float[] performGeoCoding(String location) {
????if (location == null)
????return null;
????Geocoder geocoder = new Geocoder();
????GeocoderRequest geocoderRequest
????= new GeocoderRequestBuilder()
????.setAddress(location) // location
????.setLanguage("en") // language
????.getGeocoderRequest();
????GeocodeResponse geocoderResponse;
????try {
????geocoderResponse = geocoder.geocode(geocoderRequest);
????if (geocoderResponse.getStatus() == GeocoderStatus.OK
????& !geocoderResponse.getResults().isEmpty()) {
????GeocoderResult geocoderResult =
????geocoderResponse.getResults().iterator().next();
????LatLng latitudeLongitude =
????geocoderResult.getGeometry().getLocation();
????Float[] coords = new Float[2];
????coords[0] = latitudeLongitude.getLat().floatValue();
????coords[1] = latitudeLongitude.getLng().floatValue();
????return coords;
????}
????} catch (IOException ex) {
????ex.printStackTrace();
????}
????return null;
????}

???????????????????????????λ?????
????????????????????????????????λ???????????????
????public static void main(String[] args) {
????String location = "Troia?? Foggia?? Italy";
????Float[] coords = performGeoCoding(location);
????System.out.println(location + ": "
????+ coords[0] + "?? " + coords[1]);
????}
????$ Troia?? Foggia?? Italy: 41.35978?? 15.308114
???????????
????????????????IDE????????????????????

????import com.google.code.geocoder.Geocoder;
????import com.google.code.geocoder.GeocoderRequestBuilder;
????import com.google.code.geocoder.model.GeocodeResponse;
????import com.google.code.geocoder.model.GeocoderRequest;
????import com.google.code.geocoder.model.GeocoderResult;
????import com.google.code.geocoder.model.GeocoderStatus;
????import com.google.code.geocoder.model.LatLng;
????import java.io.IOException;

???????磬??NetBeans?????“Ctrl+Alt+I”??????????
???????????????????????????????????????????????
????——Robert