Getting Location from coordinates

NiVeR picture NiVeR · May 20, 2012 · Viewed 7.9k times · Source

I have given coordinates for latitude and longitude, and I want make a location object with those.There isn't a constructor that takes to doubles to make a location, so I tried like this:

 Location l = null;
 l.setLatitude(lat);
 l.setLongitude(lon);

but it crashes. Any different idea?

Answer

Jonathan picture Jonathan · May 20, 2012

Just create a new Location with new Location("reverseGeocoded"); like this

GeoPoint newCurrent = new GeoPoint(59529200, 18071400);
        Location current = new Location("reverseGeocoded");
        current.setLatitude(newCurrent.getLatitudeE6() / 1e6);
        current.setLongitude(newCurrent.getLongitudeE6() / 1e6);
        current.setAccuracy(3333);
        current.setBearing(333);