Check if a latitude and longitude is within a circle

What you basically need, is the distance between two points on the map: float[] results = new float[1]; Location.distanceBetween(centerLatitude, centerLongitude, testLatitude, testLongitude, results); float distanceInMeters = results[0]; boolean isWithin10km = distanceInMeters < 10000; If you have already Location objects: Location center; Location test; float distanceInMeters = center.distanceTo(test); boolean isWithin10km = distanceInMeters < 10000; Here is … Read more

How to update TileOverlay without a flicker?

Would it be possible to load the upcoming tile image however have the visibility set to false? Tile.setVisible(false); Then when you want to change (after the upcoming tile has loaded), set the upcoming tile to be visible and the current tile to be invisible? CurrentTile.setVisible(false); NewTile.setVisible(true); This way the change all occurs within the same … Read more

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

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. OLD DEPRECATED ANSWER BELOW In … Read more

Android app is crashing due to V/GoogleSignatureVerifier: Signature not valid

This logcat warning is caused by a bug introduced in Google Play Services 9.x. It can be safely ignored, I don’t believe it causes a crash, so your crash may be caused by a different issue. The message should go away with a future update to play services. This issue has been acknowledged by an … Read more

How to get current Location in GoogleMap using FusedLocationProviderClient

This is similar to my other answer here, updated to use the recently introduced FusedLocationProviderClient class. In order to use a FusedLocationProviderClient in conjunction with a Google Map: Wait until the Google Map is ready Request the Location permission at runtime if needed Request location updates once the permission is granted Update the Google Map … Read more

Android map marker color?

Here is a method I am using to generate dynamic Hue colors for markers based on given String color. May be useful for someone 🙂 Marker melbourne = mMap.addMarker(new MarkerOptions().position(MELBOURNE) .icon(getMarkerIcon(“#ff2299”))); // method definition public BitmapDescriptor getMarkerIcon(String color) { float[] hsv = new float[3]; Color.colorToHSV(Color.parseColor(color), hsv); return BitmapDescriptorFactory.defaultMarker(hsv[0]); }

How to remove all the polylines from a map

Keep track of the Polyline as you add it to the map: Polyline polyline = this.mMap.addPolyline(new PolylineOptions()…..); Then when you want to remove it: polyline.remove(); If you have lots of Polylines, just add them to a List as they are put on the map: List<Polyline> polylines = new ArrayList<Polyline>(); for(….) { polylines.add(this.mMap.addPolyline(new PolylineOptions()….)); } And … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)