2013년 10월 1일 화요일

Android 주소에서 지도얻기


    public static GeoPoint getGeoPointFromLocationName(Context context, String locationName) {
     List<Address> addressList;
     GeoPoint pt = null;
     
     try {
      Geocoder geocoder = new Geocoder(context);
      addressList = geocoder.getFromLocationName(locationName, 5);
      if(addressList != null && addressList.size() > 0) {
       double lat = addressList.get(0).getLatitude();
       double lng = addressList.get(0).getLongitude();
       Log.v("Geocode", String.valueOf(lat) + ":" + String.valueOf(lng));
       pt = new GeoPoint(lat, lng);
      }
     } catch(IOException e) {
      e.printStackTrace();
     }
     return pt;
    }


댓글 없음:

댓글 쓰기