Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
void setupMapView() {
setContentView(R.layout.activity_main);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}
Location getCurrentLocation() {
Location location;
locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
this);
location = locManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location == null) {
location = locManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
}
return location;
}
void drawRoute(double s_lat,slon,dlat,dlon) {
selected_lat = Double.parseDouble(intent.getStringExtra("lat"));
selected_lon = Double.parseDouble(intent.getStringExtra("lon"));
String geoUriString = "http://maps.google.com/maps?saddr="
+ slat + "," + slon
+ "&daddr=" + dlat + "," + dlon;
Intent navigation = new Intent(Intent.ACTION_VIEW,
Uri.parse(geoUriString));
navigation.setClassName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity");
startActivity(navigation);
}
void drawLocation(GeoPoint current_location) {
String geoUriString = "http://maps.google.com/maps?q="
+ current_location.getLatitudeE6() / 1E6 + ","
+ current_location.getLongitudeE6() / 1E6;
Intent navigation = new Intent(Intent.ACTION_VIEW,
Uri.parse(geoUriString));
navigation.setClassName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity");
startActivity(navigation);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.