Created
January 31, 2013 05:33
-
-
Save sivakumarbdu/4680530 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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