Draw route in Google map for source and destination points
Here is an example for draw the route for the two points and it also provide the direction.example code is given below
Rootmapdemo1Activity.java
package a.b;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
public class Rootmapdemo1Activity extends MapActivity {
Uri uri;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uri =Uri.parse("http://maps.google.com/maps?&saddr=8.516017,76.919784&daddr=10.530325, 76.221353");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
finish();
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0vNjDM-9Hpz9W0naxngZObrxztXkFRH5LfyxboA"
/>
</RelativeLayout>
No comments:
Post a Comment