Android: How to draw route directions google maps API V2 from current location to destination

This works great for me: It’s not my code, I took it from a great answer at stackoverflow but I can’t find this answer now, so here is the code: Add this class to your project: package …; import java.io.InputStream; import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import … Read more

mapFragment.getMapAsync(this) – NullPointerException

My comment in maps with fragment , first you should refrenece your view as you will call something from it , this is why I inflate my view first View view = inflater.inflate(R.layout.activity_maps, null, false); Second call child fragment manager this.getChildFragmentManager() instead of getActivity().getSupportFragmentManager() Here is the full example to view map import android.os.Bundle; import … Read more

custom info window adapter with custom data in map v2

Try this windowlayout.xml <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:orientation=”vertical”> <TextView android:id=”@+id/tv_lat” android:layout_width=”wrap_content” android:layout_height=”wrap_content” /> <TextView android:id=”@+id/tv_lng” android:layout_width=”wrap_content” android:layout_height=”wrap_content” /> </LinearLayout> MainActivity.java public class MainActivity extends FragmentActivity { GoogleMap googleMap; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Getting reference to the SupportMapFragment of activity_main.xml SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); // Getting GoogleMap … Read more