Skip to content

Instantly share code, notes, and snippets.

@sivakumarbdu
Created January 31, 2013 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sivakumarbdu/4680530 to your computer and use it in GitHub Desktop.
Save sivakumarbdu/4680530 to your computer and use it in GitHub Desktop.
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