Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. GeoPoint lnglat=getLocationFromAddress(keyword);
  2. System.out.println(lnglat);
  3. Log.d("Location Point",lnglat.toString() );
  4.  
  5. public GeoPoint getLocationFromAddress(String strAddress){
  6.  
  7. Geocoder coder = new Geocoder(this);
  8. List<Address> address;
  9. GeoPoint p1 = null;
  10.  
  11. try {
  12. address = coder.getFromLocationName(strAddress,5);
  13. if (address == null) {
  14. return null;
  15. }
  16. Address location = address.get(0);
  17. location.getLatitude();
  18. location.getLongitude();
  19.  
  20. p1 = new GeoPoint((int) (location.getLatitude() * 1E6),
  21. (int) (location.getLongitude() * 1E6));
  22.  
  23. return p1;
  24. }
  25. catch(Exception e){
  26. e.printStackTrace();
  27. }
  28. return p1;
  29. }
  30.  
  31. double lat = lnglat.getLatitude();
  32.  
  33. double lon = lnglat.getLongitude();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement