Android GPS & Location service help
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 lo开发者_JAVA百科cation 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?
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.
精彩评论