public boolean onMarkerMoved(Marker marker) { if (marker.equals(mCenterMarker)) { mCircle.setCenter(marker.getPosition()); mRadiusMarker.setPosition(toRadiusLatLng(marker.getPosition(), mRadiusMeters)); return true; } if (marker.equals(mRadiusMarker)) { mRadiusMeters = toRadiusMeters(mCenterMarker.getPosition(), mRadiusMarker.getPosition()); mCircle.setRadius(mRadiusMeters); return true; } return false; }
@Override public void setCenter(LatLng center) { real.setCenter(center); }
/** * Called after update position of center marker, to update the circle and the radius marker * @param center */ public void onCenterUpdated(LatLng center) { if(circle != null) circle.setCenter(center); if(radiusMarker != null) radiusMarker.setPosition(MarkerAreasUtils.toRadiusLatLng(center, radiusMeters)); }
/** * Called after update position of center marker, to update the circle and the radius marker * @param center */ public void onCenterUpdated(LatLng center) { if(circle != null) circle.setCenter(center); if(resizerMarker != null) resizerMarker.setPosition(MarkerAreasUtils.toRadiusLatLng(center, radius)); }
private void drawPredictionRange(Location location){ LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); if (this.predictionRange == null) { this.predictionRange = map.addCircle(new CircleOptions() .center(latLng) .fillColor(Color.argb(50, 30, 207, 0)) .strokeColor(Color.argb(128, 30, 207, 0)) .strokeWidth(1.0f) .radius(30)); //30 meters of the prediction range } else { this.predictionRange.setCenter(latLng); } this.predictionRange.setVisible(true); handler.postDelayed(new Runnable() { @Override public void run() { MainActivity.this.predictionRange.setVisible(false); } }, 2000); }
private void drawLocationAccuracyCircle(Location location){ if(location.getAccuracy() < 0){ return; } LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); if (this.locationAccuracyCircle == null) { this.locationAccuracyCircle = map.addCircle(new CircleOptions() .center(latLng) .fillColor(Color.argb(64, 0, 0, 0)) .strokeColor(Color.argb(64, 0, 0, 0)) .strokeWidth(0.0f) .radius(location.getAccuracy())); //set readius to horizonal accuracy in meter. } else { this.locationAccuracyCircle.setCenter(latLng); } }
private void showLocationCircle(LatLng center, double accuracyRadius) { if (mCircle == null) { // location can received before map is initialized, ignoring those updates if (mMap != null) { mCircle = mMap.addCircle(new CircleOptions() .center(center) .radius(accuracyRadius) .fillColor(0x201681FB) .strokeColor(0x500A78DD) .zIndex(1.0f) .visible(true) .strokeWidth(5.0f)); mHeadingMarker = mMap.addMarker(new MarkerOptions() .position(center) .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_blue_dot)) .anchor(0.5f, 0.5f) .flat(true)); } } else { // move existing markers position to received location mCircle.setCenter(center); mHeadingMarker.setPosition(center); mCircle.setRadius(accuracyRadius); } }
private void showBlueDot(LatLng center, double accuracyRadius, double bearing) { if (mCircle == null) { // location can received before map is initialized, ignoring those updates if (mMap != null) { mCircle = mMap.addCircle(new CircleOptions() .center(center) .radius(accuracyRadius) .fillColor(0x201681FB) .strokeColor(0x500A78DD) .zIndex(1.0f) .visible(true) .strokeWidth(5.0f)); mMarker = mMap.addMarker(new MarkerOptions() .position(center) .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_blue_dot)) .anchor(0.5f, 0.5f) .rotation((float)bearing) .flat(true)); } } else { // move existing markers position to received location mCircle.setCenter(center); mCircle.setRadius(accuracyRadius); mMarker.setPosition(center); mMarker.setRotation((float)bearing); } }
private void showBlueDot(LatLng center, double accuracyRadius, double bearing) { if (mCircle == null) { // location can received before map is initialized, ignoring those updates if (mMap != null) { mCircle = mMap.addCircle(new CircleOptions() .center(center) .radius(accuracyRadius) .fillColor(ACTIVE_LEVEL_BLUE_DOT_COLOR) .strokeColor(0x00000000) .zIndex(1.0f) .visible(true)); mMarker = mMap.addMarker(new MarkerOptions() .position(center) .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_blue_dot)) .anchor(0.5f, 0.5f) .rotation((float)bearing) .flat(true)); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(center, 17.0f)); } } else { mCircle.setCenter(center); mCircle.setRadius(accuracyRadius); mMarker.setPosition(center); mMarker.setRotation((float)bearing); } }