Search in sources :

Example 11 with CircleOptions

use of com.google.android.gms.maps.model.CircleOptions in project NavitiaSDKUX_android by CanalTP.

the class JourneyMapViewComponentSpec method onBind.

@OnBind
static void onBind(final ComponentContext context, final MapView mapView, @Prop Bundle savedInstanceState, @Prop final Journey journey) {
    mapView.onCreate(savedInstanceState);
    mapView.getMapAsync(new OnMapReadyCallback() {

        @SuppressWarnings("unchecked")
        @Override
        public void onMapReady(final GoogleMap googleMap) {
            mapView.onResume();
            googleMap.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() {

                @Override
                public void onCameraIdle() {
                    redrawIntermediatePointCircles(googleMap);
                }
            });
            googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {

                @Override
                public boolean onMarkerClick(Marker marker) {
                    return true;
                }
            });
            JourneyPathElements journeyPathElements = new JourneyPathElements(journey);
            for (SectionPolyline sectionPolyline : journeyPathElements.getSectionPolylines()) {
                PolylineOptions polylineOptions = new PolylineOptions().zIndex(1);
                if (sectionPolyline.getType().equalsIgnoreCase(SectionPolyline.TYPE_STREET_NETWORK) && sectionPolyline.getMode().equalsIgnoreCase(SectionPolyline.MODE_WALKING)) {
                    polylineOptions.pattern(Arrays.asList(new Dot(), new Gap(10)));
                }
                polylineOptions.width(sectionPolyline.getWidth()).color(sectionPolyline.getColor());
                polylineOptions.addAll(sectionPolyline.getSectionPathCoordinates());
                googleMap.addPolyline(polylineOptions);
            }
            intermediatePointsCircles.clear();
            for (LatLng centerCoord : journeyPathElements.getIntermediatePointsCirclesCoords()) {
                CircleOptions circleOptions = new CircleOptions().center(centerCoord).strokeColor(Color.BLACK).strokeWidth(8).fillColor(Color.WHITE).radius(getCircleRadiusDependingOnCurrentCameraZoom(googleMap.getCameraPosition().zoom)).zIndex(2);
                intermediatePointsCircles.add(googleMap.addCircle(circleOptions));
            }
            LatLng[] ridesharingCoordinates = getRidesharingJourneyCoordinates(journey);
            LatLng departureCoordinates = getJourneyDepartureCoordinates(journey);
            LatLng arrivalCoordinates = getJourneyArrivalCoordinates(journey);
            String departureLabel = context.getString(R.string.departure);
            String arrivalLabel = context.getString(R.string.arrival);
            if (departureCoordinates.equals(ridesharingCoordinates[0])) {
                MarkerOptions departureMarkerOptions = new MarkerOptions().position(ridesharingCoordinates[0]).icon(BitmapDescriptorFactory.fromBitmap(getPlaceMarkerIcon(context, departureLabel, Configuration.colors.getOrigin(), true)));
                googleMap.addMarker(departureMarkerOptions);
            } else {
                if (ridesharingCoordinates[0] != null) {
                    MarkerOptions ridesharingDepartureMarkerOptions = new MarkerOptions().position(ridesharingCoordinates[0]).icon(BitmapDescriptorFactory.fromBitmap(getPlaceMarkerIcon(context, null, null, true)));
                    googleMap.addMarker(ridesharingDepartureMarkerOptions);
                }
                MarkerOptions departureMarkerOptions = new MarkerOptions().position(departureCoordinates).icon(BitmapDescriptorFactory.fromBitmap(getPlaceMarkerIcon(context, departureLabel, Configuration.colors.getOrigin(), false)));
                googleMap.addMarker(departureMarkerOptions);
            }
            if (arrivalCoordinates.equals(ridesharingCoordinates[1])) {
                MarkerOptions arrivalMarkerOptions = new MarkerOptions().position(ridesharingCoordinates[1]).icon(BitmapDescriptorFactory.fromBitmap(getPlaceMarkerIcon(context, arrivalLabel, Configuration.colors.getDestination(), true)));
                googleMap.addMarker(arrivalMarkerOptions);
            } else {
                if (ridesharingCoordinates[1] != null) {
                    MarkerOptions ridesharingArrivalMarkerOptions = new MarkerOptions().position(ridesharingCoordinates[1]).icon(BitmapDescriptorFactory.fromBitmap(getPlaceMarkerIcon(context, null, null, true)));
                    googleMap.addMarker(ridesharingArrivalMarkerOptions);
                }
                MarkerOptions arrivalMarkerOptions = new MarkerOptions().position(arrivalCoordinates).icon(BitmapDescriptorFactory.fromBitmap(getPlaceMarkerIcon(context, arrivalLabel, Configuration.colors.getDestination(), false)));
                googleMap.addMarker(arrivalMarkerOptions);
            }
            zoomToPolyline(googleMap, journeyPathElements.getJourneyPolylineCoords(), false);
        }
    });
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) Dot(com.google.android.gms.maps.model.Dot) OnMapReadyCallback(com.google.android.gms.maps.OnMapReadyCallback) Marker(com.google.android.gms.maps.model.Marker) PolylineOptions(com.google.android.gms.maps.model.PolylineOptions) SectionPolyline(org.kisio.NavitiaSDKUX.BusinessLogic.SectionPolyline) CircleOptions(com.google.android.gms.maps.model.CircleOptions) JourneyPathElements(org.kisio.NavitiaSDKUX.BusinessLogic.JourneyPathElements) GoogleMap(com.google.android.gms.maps.GoogleMap) Gap(com.google.android.gms.maps.model.Gap) LatLng(com.google.android.gms.maps.model.LatLng) OnBind(com.facebook.litho.annotations.OnBind)

Example 12 with CircleOptions

use of com.google.android.gms.maps.model.CircleOptions in project collect by opendatakit.

the class GoogleMapFragment method updateLocationIndicator.

private void updateLocationIndicator(LatLng loc, double radius) {
    if (map == null) {
        return;
    }
    if (locationCrosshairs == null) {
        locationCrosshairs = map.addMarker(new MarkerOptions().position(loc).icon(getBitmapDescriptor(R.drawable.ic_crosshairs)).anchor(0.5f, // center the crosshairs on the position
        0.5f));
    }
    if (accuracyCircle == null) {
        int stroke = new ThemeUtils(requireContext()).getColorPrimaryDark();
        int fill = getResources().getColor(R.color.color_primary_low_emphasis);
        accuracyCircle = map.addCircle(new CircleOptions().center(loc).radius(radius).strokeWidth(1).strokeColor(stroke).fillColor(fill));
    }
    locationCrosshairs.setPosition(loc);
    accuracyCircle.setCenter(loc);
    accuracyCircle.setRadius(radius);
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) CircleOptions(com.google.android.gms.maps.model.CircleOptions) ThemeUtils(org.odk.collect.android.utilities.ThemeUtils) MapPoint(org.odk.collect.geo.maps.MapPoint) SuppressLint(android.annotation.SuppressLint)

Example 13 with CircleOptions

use of com.google.android.gms.maps.model.CircleOptions in project wigle-wifi-wardriving by wiglenet.

the class NetworkActivity method setupMap.

private void setupMap(final Network network, final Bundle savedInstanceState) {
    mapView = new MapView(this);
    try {
        mapView.onCreate(savedInstanceState);
    } catch (NullPointerException ex) {
        MainActivity.error("npe in mapView.onCreate: " + ex, ex);
    }
    MapsInitializer.initialize(this);
    if (network.getLatLng() != null) {
        mapView.getMapAsync(new OnMapReadyCallback() {

            @Override
            public void onMapReady(final GoogleMap googleMap) {
                final CameraPosition cameraPosition = new CameraPosition.Builder().target(network.getLatLng()).zoom(DEFAULT_ZOOM).build();
                googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
                googleMap.addCircle(new CircleOptions().center(network.getLatLng()).radius(5).fillColor(Color.argb(128, 240, 240, 240)).strokeColor(Color.argb(200, 255, 32, 32)).strokeWidth(3f).zIndex(100));
            }
        });
    }
    final RelativeLayout rlView = (RelativeLayout) findViewById(R.id.netmap_rl);
    rlView.addView(mapView);
}
Also used : CameraPosition(com.google.android.gms.maps.model.CameraPosition) CircleOptions(com.google.android.gms.maps.model.CircleOptions) GoogleMap(com.google.android.gms.maps.GoogleMap) RelativeLayout(android.widget.RelativeLayout) MapView(com.google.android.gms.maps.MapView) OnMapReadyCallback(com.google.android.gms.maps.OnMapReadyCallback)

Example 14 with CircleOptions

use of com.google.android.gms.maps.model.CircleOptions in project iNaturalistAndroid by inaturalist.

the class ActivityHelper method addCircle.

private CameraUpdate addCircle(GoogleMap map, LatLng latlng, int radius, Observation observation, boolean updateCamera) {
    int obsColor = observationColor(observation);
    CircleOptions opts = new CircleOptions().center(latlng).radius(radius).fillColor(// Add 50% opacity
    0x80FFFFFF & obsColor).strokeColor(obsColor);
    map.addCircle(opts);
    if (!updateCamera) {
        return null;
    }
    LatLngBounds bounds = new LatLngBounds.Builder().include(SphericalUtil.computeOffset(latlng, radius, 0)).include(SphericalUtil.computeOffset(latlng, radius, 90)).include(SphericalUtil.computeOffset(latlng, radius, 180)).include(SphericalUtil.computeOffset(latlng, radius, 270)).build();
    return CameraUpdateFactory.newLatLngBounds(bounds, 10);
}
Also used : CircleOptions(com.google.android.gms.maps.model.CircleOptions) LatLngBounds(com.google.android.gms.maps.model.LatLngBounds)

Example 15 with CircleOptions

use of com.google.android.gms.maps.model.CircleOptions in project Remindy by abicelis.

the class LocationBasedReminderDetailFragment method setUpMap.

@SuppressWarnings({ "MissingPermission" })
private void setUpMap() {
    mMap.setMyLocationEnabled(true);
    // mMap.setPadding(0, ConversionUtil.dpToPx(68, getResources()), 0, 0);
    mMap.getUiSettings().setMyLocationButtonEnabled(true);
    // Add circle and marker
    int strokeColor = ContextCompat.getColor(getActivity(), R.color.map_circle_stroke);
    int shadeColor = ContextCompat.getColor(getActivity(), R.color.map_circle_shade);
    LatLng latLng = ConversionUtil.placeToLatLng(mReminder.getPlace());
    mMap.addCircle(new CircleOptions().center(latLng).radius(mReminder.getPlace().getRadius()).fillColor(shadeColor).strokeColor(strokeColor).strokeWidth(2));
    mMap.addMarker(new MarkerOptions().position(latLng));
    // Move camera
    // mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latlng, 15), 1000, null);  //Zoom level 15 = Streets, 1000ms animation
    CameraPosition cameraPos = new CameraPosition.Builder().tilt(60).target(latLng).zoom(15).build();
    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPos), 1000, null);
}
Also used : CameraPosition(com.google.android.gms.maps.model.CameraPosition) MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) CircleOptions(com.google.android.gms.maps.model.CircleOptions) LatLng(com.google.android.gms.maps.model.LatLng)

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