All- I am trying to get the user's current location than display that on the map with an overlay item. My problem is the user's location is coming in as a location and the overlay array only accepts GeoPoints. Here is what I have tried:
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
GeoPoint point = new GeoPoint.valueOf(location);
OverlayItem overlayitem4 = new OverlayItem(point, "You Are Here", "Boulder, CO");
}
But I am getting an error on GeoPoint.valueOf(location);
, specifically:
GeoPoint.valueOf cannot be resolved to a type`
So my question is How can I convert from location to GeoPoint? Thank you all for your time.
try this
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
int lat = (int) (location.getLatitude() * 1E6);
int lng = (int) (location.getLongitude() * 1E6);
GeoPoint point = new GeoPoint(lat, lng);
OverlayItem overlayitem4 = new OverlayItem(point, "You Are Here", "Boulder, CO");
}
}
This worked for me and it seems much easier:
GeoPoint geoPoint = new GeoPoint(location);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With