Replace getMap with getMapAsync

as in the official doc, get map async requires a callback; it’s there your “main entry point” for google maps stuff! public class MapPane extends Activity implements OnMapReadyCallback { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map_activity); MapFragment mapFragment = (MapFragment) getFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); } @Override public void onMapReady(GoogleMap map) { // DO WHATEVER YOU … Read more

Capture screen shot of GoogleMap Android API V2

Update – Google has added a snapshot method**!: The feature request for a method to take a screen shot of the Android Google Map API V2 OpenGL layer has been fulfilled. To take a screenshot, simply implement the following interface: public abstract void onSnapshotReady (Bitmap snapshot) and call: public final void snapshot (GoogleMap.SnapshotReadyCallback callback) Example … Read more

Google Maps Android API v2 Authorization failure

Steps: to ensure that device has Google Play services APK to install Google Play Service rev. more than 2 to create project at https://code.google.com/apis/console/ to enable “Google Maps Android API v2” to register of SHA1 in project (NOW, YOU NEED WRITE SHA1;your.app.package.name) at APIs console and get API KEY to copy directory ANDROID_SDK_DIR/extras/google/google_play_services/libproject/google-play-services_lib to root … Read more

Draw path between two points using Google Maps Android API v2

First of all we will get source and destination points between which we have to draw route. Then we will pass these attribute to below function. public String makeURL (double sourcelat, double sourcelog, double destlat, double destlog ){ StringBuilder urlString = new StringBuilder(); urlString.append(“http://maps.googleapis.com/maps/api/directions/json”); urlString.append(“?origin=”);// from urlString.append(Double.toString(sourcelat)); urlString.append(“,”); urlString.append(Double.toString( sourcelog)); urlString.append(“&destination=”);// to urlString.append(Double.toString( destlat)); urlString.append(“,”); … Read more

How to create a custom-shaped bitmap marker with Android map API v2 [duplicate]

In the Google Maps API v2 Demo there is a MarkerDemoActivity class in which you can see how a custom Image is set to a GoogleMap. // Uses a custom icon. mSydney = mMap.addMarker(new MarkerOptions() .position(SYDNEY) .title(“Sydney”) .snippet(“Population: 4,627,300”) .icon(BitmapDescriptorFactory.fromResource(R.drawable.arrow))); As this just replaces the marker with an image you might want to use a … Read more

How can I show current location on a Google Map on Android Marshmallow?

For using FusedLocationProviderClient with Google Play Services 11 and higher: see here: How to get current Location in GoogleMap using FusedLocationProviderClient For using (now deprecated) FusedLocationProviderApi: If your project uses Google Play Services 10 or lower, using the FusedLocationProviderApi is the optimal choice. The FusedLocationProviderApi offers less battery drain than the old open source LocationManager … Read more