Search in sources :

Example 16 with CircleOptions

use of com.google.android.gms.maps.model.CircleOptions in project xDrip by NightscoutFoundation.

the class MapsActivity method redrawmap.

private static void redrawmap() {
    Log.d(TAG, "Attempting to redraw map: " + lastGeoLocation);
    if (mMap == null)
        return;
    mMap.clear();
    String[] splits = lastGeoLocation.split(",");
    // sanity check goes here
    LatLng mylocation;
    try {
        mylocation = new LatLng(Double.parseDouble(splits[0]), Double.parseDouble(splits[1]));
    } catch (NumberFormatException e) {
        Log.e(TAG, "Mylocation number exception: '" + lastGeoLocation + "'");
        return;
    } catch (ArrayIndexOutOfBoundsException e) {
        Log.e(TAG, "Mylocation array index exception: '" + lastGeoLocation + "'");
        return;
    }
    CircleOptions circleOptions = new CircleOptions().center(mylocation).strokeWidth(2).strokeColor(Color.GRAY).radius(1500);
    String title = "";
    if (lastGeoLocation.equals(defaultLocation)) {
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mylocation, 16));
        title = "No location data yet";
    } else {
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mylocation, 13));
    }
    if (lats.size() > 0) {
        PolylineOptions mylines = new PolylineOptions();
        for (int c = 0; c < lats.size(); c++) {
            mylines.add(new LatLng(lats.get(c), longs.get(c)));
        }
        mylines.width(1);
        mylines.color(Color.parseColor("#2ba367"));
        mMap.addPolyline(mylines);
    }
    mMap.addCircle(circleOptions);
    mMap.addMarker(new MarkerOptions().position(mylocation).title(title).alpha(0.9f).icon(BitmapDescriptorFactory.fromResource(R.drawable.jamorham_parakeet_marker)));
    mMap.getUiSettings().setMapToolbarEnabled(false);
    mMap.getUiSettings().setMyLocationButtonEnabled(true);
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) CircleOptions(com.google.android.gms.maps.model.CircleOptions) LatLng(com.google.android.gms.maps.model.LatLng) PolylineOptions(com.google.android.gms.maps.model.PolylineOptions)

Aggregations

CircleOptions (com.google.android.gms.maps.model.CircleOptions)16 LatLng (com.google.android.gms.maps.model.LatLng)8 MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)8 PolylineOptions (com.google.android.gms.maps.model.PolylineOptions)4 GoogleMap (com.google.android.gms.maps.GoogleMap)3 OnMapReadyCallback (com.google.android.gms.maps.OnMapReadyCallback)3 CameraPosition (com.google.android.gms.maps.model.CameraPosition)3 SuppressLint (android.annotation.SuppressLint)2 Circle (com.google.android.gms.maps.model.Circle)2 Cursor (android.database.Cursor)1 Handler (android.os.Handler)1 Message (android.os.Message)1 RelativeLayout (android.widget.RelativeLayout)1 TextView (android.widget.TextView)1 OnBind (com.facebook.litho.annotations.OnBind)1 MapView (com.google.android.gms.maps.MapView)1 Dot (com.google.android.gms.maps.model.Dot)1 Gap (com.google.android.gms.maps.model.Gap)1 GroundOverlayOptions (com.google.android.gms.maps.model.GroundOverlayOptions)1 LatLngBounds (com.google.android.gms.maps.model.LatLngBounds)1