get latitude and longitude with geocoder and android Google Maps API v2

Try this solution using this example url: http://maps.google.com/maps/api/geocode/json?address=mumbai&sensor=false which returns data in json format with lat/lng of address. private class DataLongOperationAsynchTask extends AsyncTask<String, Void, String[]> { ProgressDialog dialog = new ProgressDialog(MainActivity.this); @Override protected void onPreExecute() { super.onPreExecute(); dialog.setMessage(“Please wait…”); dialog.setCanceledOnTouchOutside(false); dialog.show(); } @Override protected String[] doInBackground(String… params) { String response; try { response = getLatLongByURL(“http://maps.google.com/maps/api/geocode/json?address=mumbai&sensor=false”); … Read more

Replace default Android Maps API v2 Change MyLocation icon

my simple solution way is just disable “my location” of Google map and create ImageView on Map with my icon then capture ImageView with onClick and getMyLocation , animateCamera in onClick this.mGoogleMap.getUiSettings().setMyLocationButtonEnabled(false); this.mGoogleMap.setMyLocationEnabled(true); . @Override public void onClick(final View v) { Location location = this.mGoogleMap.getMyLocation(); if (location != null) { LatLng target = new LatLng(location.getLatitude(), … Read more

Change position of Google Maps API’s “My location” button

You can get the “My Location” button and move it, like : public class MapFragment extends SupportMapFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View mapView = super.onCreateView(inflater, container, savedInstanceState); // Get the button view View locationButton = ((View) mapView.findViewById(1).getParent()).findViewById(2); // and next place it, for exemple, on bottom right (as … Read more

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

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

Error opening SupportMapFragment for second time

Update: As an alternative solution (which I think is much better) you can use a MapView which is described: here I ran across a similar problem while working with a tabs implementation. With Google Maps V2, you are stuck with the SupportMapFragment, so using the MapView isn’t an option. Between juanmeanwhile’s post and comment #1 … Read more

GoogleService failed to initialize

[From Product Manager @ Google] You can fix this issue by downloading and copying the google-services.json file for your Android app by following the steps below: Select your app/project name and Android packagename from this link and click Continue to Choose and configure services. Click Continue to Generate Configuration files. Download google-services.json and copy the … Read more