Code example for GoogleMap

Methods: getMyLocation

0
 
        return true; 
    } 
 
    public void updateMarkerDistance(Marker marker) {
        if (map.getMyLocation() == null) {
 
            marker.setSnippet("");
 
        } else { 
 
            float[] results = new float[1];
 
            Location.distanceBetween(map.getMyLocation().getLatitude(), map.getMyLocation().getLongitude(),
                    marker.getPosition().latitude, marker.getPosition().longitude, results);
 
            double distance = results[0];
 
            if (distance < 2000) {
                marker.setSnippet(String.format("Afstand: %.0f m", results[0]));
            } else {