Adding Google Play services version to your app’s manifest?

It is probably that your library is not linked to project properly or that you have older google-play-services library version so conflict appears and Eclipse got stupid.. :S No you don’t need to add anything in integers.xml. When you link properly Google-play-services library to your project reference android:value=”@integer/google_play_services_version” will be found and you are ready … Read more

moveCamera with CameraUpdateFactory.newLatLngBounds crashes

You can use simple newLatLngBounds method in OnCameraChangeListener. All will be working perfectly and you don’t need to calculate screen size. This event occurs after map size calculation (as I understand). Example: map.setOnCameraChangeListener(new OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition arg0) { // Move camera. map.moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 10)); // Remove listener to prevent position reset on camera … Read more

java.lang.noclassdeffounderror: com.google.android.gms.R$styleable

If you are using Intellij Idea, Select your project from project panel Hit F4 in order to open the project structure window Select Modules from left panel, then hit + button then select “import module” and navigate to “ANDROID-SDK“/extras/google/google_play_services/libproject/google-play-services_lib. By doing this this project will be added to Modules alongside with your project Select your … Read more

Google Maps API v2: How to make markers clickable?

All markers in Google Android Maps Api v2 are clickable. You don’t need to set any additional properties to your marker. What you need to do – is to register marker click callback to your googleMap and handle click within callback: public class MarkerDemoActivity extends android.support.v4.app.FragmentActivity implements OnMarkerClickListener { private Marker myMarker; private void setUpMap() … Read more

Animating markers on Google Maps v2

Some Google engineers have provided a nice demo video with some elegant sample code about how to animate markers from a starting point to an ending point, for all various versions of Android: The relevant code is here: https://gist.github.com/broady/6314689 And a nice demo video of all of it in action. http://youtu.be/WKfZsCKSXVQ OLD DEPRECATED ANSWER BELOW … Read more

How do I know the map is ready to get used when using the SupportMapFragment?

EDIT: getMap is deprecated now The problem is when the call to getMap is null, when can I try again? That depends upon the nature of the problem. If you set up the SupportMapFragment via the <fragment> element in the layout, you can call getMap() successfully in onCreate(). But, if you create the SupportMapFragment via … Read more

Blue dot and circle is not shown on MyLocation using android fused location api

For targeting api-23 or higher See this answer…. For targeting api-22 and lower: This code works for me, it has the MyLocation blue dot/circle, and it also places a Marker on the current location using the Fused Location Provider. Here is the entire Activity code I used: import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.SupportMapFragment; … Read more

Android map v2 zoom to show all the markers

You should use the CameraUpdate class to do (probably) all programmatic map movements. To do this, first calculate the bounds of all the markers like so: LatLngBounds.Builder builder = new LatLngBounds.Builder(); for (Marker marker : markers) { builder.include(marker.getPosition()); } LatLngBounds bounds = builder.build(); Then obtain a movement description object by using the factory: CameraUpdateFactory: int … Read more

How to draw interactive Polyline on route google maps v2 android

Instead of creating too many short Polylines just create one like here: PolylineOptions options = new PolylineOptions().width(5).color(Color.BLUE).geodesic(true); for (int z = 0; z < list.size(); z++) { LatLng point = list.get(z); options.add(point); } line = myMap.addPolyline(options); I’m also not sure you should use geodesic when your points are so close to each other.