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);
}
});
}
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);
}
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);
}
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);
}
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);
}
Aggregations