?????Java????????λ????ó???
???????????? ???????[ 2014/12/25 13:45:02 ] ????????Java ????λ????ó???
???????????????????????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
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11