How can I handle map move end using Google Maps for Android V2?

Check out new maps api. @Override public void onMapReady(GoogleMap map) { mMap = map; mMap.setOnCameraIdleListener(this); mMap.setOnCameraMoveStartedListener(this); mMap.setOnCameraMoveListener(this); mMap.setOnCameraMoveCanceledListener(this); // Show Sydney on the map. mMap.moveCamera(CameraUpdateFactory .newLatLngZoom(new LatLng(-33.87365, 151.20689), 10)); } @Override public void onCameraMoveStarted(int reason) { if (reason == OnCameraMoveStartedListener.REASON_GESTURE) { Toast.makeText(this, “The user gestured on the map.”, Toast.LENGTH_SHORT).show(); } else if (reason == OnCameraMoveStartedListener … Read more

How to Draw Route in Google Maps API V2 from my location [duplicate]

Assuming you have at least 2 location objects you can draw a polyline. This method draws a semi-transparent blue line on the map given a list of locations. This code is taken from an application currently on the Android Play store (Simply Walking). private void drawPrimaryLinePath( ArrayList<Location> listLocsToDraw ) { if ( map == null … Read more

Google Maps v2 Marker zOrdering – Set to top

Aiden Fry’s answer works if you do actually display an InfoWindow. If you don’t, the marker won’t come to the front. Here is a hack to make it come to the front anyway: Create a custom InfoWindowAdapter that displays a 0dp info window: public class MapWindowAdapter implements GoogleMap.InfoWindowAdapter { private Context context = null; public … Read more

Google map for android my location custom button

See below xml file to custom button: <?xml version=”1.0″ encoding=”utf-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical” > <fragment android:id=”@+id/maps” android:name=”pl.mg6.android.maps.extensions.SupportMapFragment” android:layout_width=”match_parent” android:layout_height=”match_parent” /> <LinearLayout android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:layout_marginLeft=”10dp” android:layout_marginRight=”10dp” android:layout_marginTop=”5dp” > <ImageView android:id=”@+id/imgMyLocation” android:layout_width=”40dp” android:layout_height=”40dp” android:scaleType=”fitXY” android:src=”https://stackoverflow.com/questions/23883235/@drawable/track_my_location” /> </LinearLayout> </RelativeLayout> Then in java class, declare your location button: private ImageView imgMyLocation; imgMyLocation = (ImageView) findViewById(R.id.imgMyLocation); Click Event: … Read more

Google Maps Android API v2 – Sample Code crashes

Follow the crib sheet very, very carefully: https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw In particular, I think you need to: Import the actual source for the “google-play-services_lib” project and link it as an Android library. Do this through Project -> Properties -> Android -> Library, Add -> google-play-services_lib (you can right click on your project and choose Properties, then select … Read more

How to hide “Navigation” and “GPS Pointer” buttons when I click the marker on the android google map

For the button group you have outlined in red, you can disable it using the setMapToolbarEnabled() method in UISettings. From the documentation: Sets the preference for whether the Map Toolbar should be enabled or disabled. If enabled, users will see a bar with various context-dependent actions, including ‘open this map in the Google Maps app’ … Read more

SupportMapFragment does not support AndroidX Fragment

This issue has already been reported to Google in the public issue tracker: https://issuetracker.google.com/issues/110573930 I would suggest starring the feature request in the public issue tracker to add your vote and subscribe to further notifications from Google. Hopefully, Google will implement it in next versions of Android Maps SDK. Update Google has provided the following … 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

SupportMapFragment.getmap() returns null

map takes some time to load, so you need to run your code in handler –> Handler handler = new Handler(); handler.postDelayed(new Runnable() @Override public void run() { GoogleMap googleMap = SupportMapFragment.newInstance(new GoogleMapOptions().zOrderOnTop(true)).getMap(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.map_content, fragment); ft.commit(); if(googleMap != null) { googleMap.addMarker(new MarkerOptions().position(result)).setVisible(true); // Move the camera instantly to location with a … Read more