com.google.android.gms.maps.model.Circle Java Examples
The following examples show how to use
com.google.android.gms.maps.model.Circle.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapViewHandler.java From PowerSwitch_Android with GNU General Public License v3.0 | 6 votes |
/** * Add Geofence to Map * * @param latLng position * @param radius radius * @return Geofence */ public Geofence addGeofence(LatLng latLng, double radius) { MarkerOptions markerOptions = new MarkerOptions() .position(latLng) .draggable(true); Marker marker = googleMap.addMarker(markerOptions); CircleOptions circleOptions = new CircleOptions().center(latLng) .radius(radius) .fillColor(ContextCompat.getColor(context, R.color.geofenceFillColor)) .strokeColor(Color.BLUE) .strokeWidth(2); Circle circle = googleMap.addCircle(circleOptions); circles.put(circle.getId(), circle); Geofence geofence = new Geofence(marker, circle); geofences.put(marker.getId(), geofence); return geofence; }
Example #2
Source File: ObservationMarkerCollection.java From mage-android with Apache License 2.0 | 5 votes |
@Override public boolean onMarkerClick(Marker marker) { boolean handled = false; Observation observation = mapObservations.getMarkerObservation(marker.getId()); if (observation != null) { final Geometry g = observation.getGeometry(); if (g != null) { Point point = GeometryUtils.getCentroid(g); LatLng latLng = new LatLng(point.getY(), point.getX()); Float accuracy = observation.getAccuracy(); if (accuracy != null) { try { if (observationAccuracyCircle != null) { observationAccuracyCircle.second.remove(); } Circle circle = map.addCircle(new CircleOptions() .center(latLng) .radius(accuracy) .fillColor(context.getResources().getColor(R.color.accuracy_circle_fill)) .strokeColor(context.getResources().getColor(R.color.accuracy_circle_stroke)) .strokeWidth(2.0f)); observationAccuracyCircle = new Pair<>(observation.getRemoteId(), circle); } catch (NumberFormatException nfe) { Log.e(LOG_NAME, "Problem adding accuracy circle to the map.", nfe); } } } map.setInfoWindowAdapter(infoWindowAdapter); marker.showInfoWindow(); handled = true; } return handled; }
Example #3
Source File: CircleClickFuncTest.java From RxGoogleMaps with Apache License 2.0 | 5 votes |
@Test public void shouldEmmitMarker() throws Exception { TestSubscriber<Circle> testSubscriber = new TestSubscriber<>(); new CircleClickFunc().call(googleMap) .subscribe(testSubscriber); verify(googleMap).setOnCircleClickListener(argumentCaptor.capture()); argumentCaptor.getValue().onCircleClick(null); testSubscriber.assertNoErrors(); testSubscriber.assertValueCount(1); argumentCaptor.getValue().onCircleClick(null); testSubscriber.assertValueCount(2); }
Example #4
Source File: CircleManager.java From android-maps-utils with Apache License 2.0 | 5 votes |
@Override public void onCircleClick(Circle circle) { Collection collection = mAllObjects.get(circle); if (collection != null && collection.mCircleClickListener != null) { collection.mCircleClickListener.onCircleClick(circle); } }
Example #5
Source File: ShapeActivity.java From Complete-Google-Map-API-Tutorial with Apache License 2.0 | 4 votes |
@Override public void onCircleClick(Circle circle) { onClick((CustomTag) circle.getTag()); }
Example #6
Source File: MapActivity.java From homeassist with Apache License 2.0 | 4 votes |
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.setOnMarkerClickListener(this); UiSettings uiSettings = mMap.getUiSettings(); uiSettings.setCompassEnabled(true); uiSettings.setZoomControlsEnabled(true); uiSettings.setMyLocationButtonEnabled(true); uiSettings.setAllGesturesEnabled(true); uiSettings.setMyLocationButtonEnabled(true); DatabaseManager databaseManager = DatabaseManager.getInstance(this); ArrayList<Entity> devices = databaseManager.getDeviceLocations(); LatLngBounds.Builder builder = new LatLngBounds.Builder(); int zoneCount = 0; int deviceCount = 0; for (Entity device : devices) { Log.d("YouQi", "Device: " + CommonUtil.deflate(device)); LatLng latLng = device.getLocation(); if (latLng == null) continue; builder.include(latLng); if (device.isZone()) { zoneCount += 1; Log.d("YouQi", "Zone!!"); Circle circle = mMap.addCircle(new CircleOptions() .center(latLng) // .strokeColor(Color.RED) .strokeColor(Color.parseColor("#FF5722")) .fillColor(Color.parseColor("#33FFAB91"))); if (device.attributes.radius != null) { circle.setRadius(device.attributes.radius.floatValue()); } if (device.hasMdiIcon()) { Log.d("YouQi", "hasMdiIcon"); mMap.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromBitmap(mifZoneIcon.makeMaterialIcon(device.getMdiIcon()))) .position(latLng) .zIndex(1.0f) .anchor(mifZoneIcon.getAnchorU(), mifZoneIcon.getAnchorV())); } else { Log.d("YouQi", "nope"); mMap.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromBitmap(mifZoneText.makeIcon(device.getFriendlyName()))) .position(latLng) .zIndex(1.0f) .anchor(mifZoneText.getAnchorU(), mifZoneText.getAnchorV())); } } else if (device.isDeviceTracker()) { deviceCount += 1; Marker marker = createMarker(device); markers.put(device.entityId, marker); } } if (deviceCount == 0 && zoneCount == 0) { mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.3333395, -30.3274332), 2)); new MaterialDialog.Builder(this) .cancelable(false) .title(R.string.title_nozone) .content(R.string.content_nozone) .positiveText(R.string.button_continue) .positiveColorRes(R.color.md_red_500) .buttonRippleColorRes(R.color.md_grey_200) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }) .show(); } else { LatLngBounds bounds = builder.build(); int width = getResources().getDisplayMetrics().widthPixels; int height = getResources().getDisplayMetrics().heightPixels; int padding = (int) (width * 0.20); // offset from edges of the map 10% of screen CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, width, height, padding); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(bounds.getCenter(), 10)); mMap.animateCamera(cu); } //mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); }
Example #7
Source File: MapUtils.java From android-rxgeofence with MIT License | 4 votes |
public static Circle addCircleFromPlace(GoogleMap googleMap, Place place) { return googleMap.addCircle(new CircleOptions().center(getLatLngFromPlace(place)) .radius(place.getRad() * 1000) .fillColor(Color.argb(66, 255, 0, 255)) .strokeColor(Color.argb(66, 0, 0, 0))); }
Example #8
Source File: Geofence.java From PowerSwitch_Android with GNU General Public License v3.0 | 4 votes |
public Geofence(Marker marker, Circle circle) { this.marker = marker; this.circle = circle; }
Example #9
Source File: Geofence.java From PowerSwitch_Android with GNU General Public License v3.0 | 4 votes |
public Circle getCircle() { return circle; }
Example #10
Source File: TagsDemoActivity.java From android-samples with Apache License 2.0 | 4 votes |
@Override public void onCircleClick(Circle circle) { onClick((CustomTag) circle.getTag()); }
Example #11
Source File: CircleManager.java From android-maps-utils with Apache License 2.0 | 4 votes |
@Override protected void removeObjectFromMap(Circle object) { object.remove(); }
Example #12
Source File: CircleManager.java From android-maps-utils with Apache License 2.0 | 4 votes |
public Circle addCircle(CircleOptions opts) { Circle circle = mMap.addCircle(opts); super.add(circle); return circle; }
Example #13
Source File: CircleManager.java From android-maps-utils with Apache License 2.0 | 4 votes |
public void showAll() { for (Circle circle : getCircles()) { circle.setVisible(true); } }
Example #14
Source File: CircleManager.java From android-maps-utils with Apache License 2.0 | 4 votes |
public void hideAll() { for (Circle circle : getCircles()) { circle.setVisible(false); } }
Example #15
Source File: CircleManager.java From android-maps-utils with Apache License 2.0 | 4 votes |
public boolean remove(Circle circle) { return super.remove(circle); }
Example #16
Source File: CircleManager.java From android-maps-utils with Apache License 2.0 | 4 votes |
public java.util.Collection<Circle> getCircles() { return getObjects(); }