0

New to android development and trying to create map app that functions as such.

1) Launch mapview 2) Show an icon that represents the users current location 3) Show icon's that represent local landmarks (example: gyms, restaurant) 4) When users taps any given landmark icon a popup displays name, address, and option to start GPS (turn by turn) direction.

Can this be done in android? Do I have to programmatically enter the lat & lon?

user590690
  • 15
  • 2
  • 6

1 Answers1

1

Yes.This can be done in android.You can find the location through your gps or network(wi-fi or cellular network).But generally gps is pretty time consuming so you use a combination of both the gps and network to determine your location.This link will give you a better idea on how to get the user location http://developer.android.com/guide/topics/location/obtaining-user-location.html.

This is sample code on retrieveing the location.Remember to follow the above links and request for location updates.

 LocationManager locationManager= (LocationManager) getSystemService(context);
        Criteria criteria = new Criteria();
            criteria.setAccuracy(Criteria.ACCURACY_FINE);
            criteria.setAltitudeRequired(false);
            criteria.setBearingRequired(false);
            criteria.setCostAllowed(true);
            criteria.setPowerRequirement(Criteria.POWER_LOW);
            provider = locationManager.getBestProvider(criteria, true);
    Location location = locationManager.getLastKnownLocation(provider)

Here in the above code your latitude and longitude will be stored inside the variable location.Remember to add the location listener and request for location updates.

rogerstone
  • 7,541
  • 11
  • 53
  • 62
  • hi thanks for reply. so if the above code finds the users current location, how would go about displaying local gyms on the mapview? is there a book that provides a tutorial? – user590690 Apr 17 '11 at 19:51
  • I would suggest "Professional android development 2" by Reto Me if you ask me for a book. – rogerstone Apr 18 '11 at 01:38
  • See this post.This would get your started on displaying places of interest on the map.http://stackoverflow.com/questions/2631742/given-gps-coordinates-how-do-i-find-nearby-landmarks-or-points-of-interest. As for a book I would definitely recommend "Professional Android 2 Application Development" - Reto Meier.It may not have tutorials which explain what you want but it has many examples on which you can build on – rogerstone Apr 18 '11 at 01:45