private void initMap() { PlaceAutocompleteFragment autocompleteFragment = new PlaceAutocompleteFragment(); CustomMapFragment mapFragment = new CustomMapFragment(); autocompleteFragment.setOnPlaceSelectedListener(this); mapFragment.setParent(mBinding.scroll); mapFragment.getMapAsync(this); FragmentManager manager = getActivity().getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); transaction.add(R.id.place_autocomplete_fragment, autocompleteFragment); transaction.add(R.id.google_map_fragment, mapFragment); transaction.commit(); mMarkerOptions = new MarkerOptions().icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); mCircleOptions = new CircleOptions().fillColor(Color.argb(97, 93, 185, 139)).strokeColor(Color.argb(200, 93, 185, 139)); }
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // mMap.setOnMapClickListener(this); Bundle bundle = getIntent().getExtras(); double r_long=bundle.getDouble("lattitude"); double r_lat=bundle.getDouble("longitude"); // Add a marker in Sydney and move the camera LatLng mark = new LatLng(r_lat, r_long); CircleOptions circleoptions=new CircleOptions().strokeWidth(2).strokeColor(Color.BLUE).fillColor(Color.parseColor("#500084d3")); mMap.addMarker(new MarkerOptions().position(mark).title(getAddress(mark))); mMap.moveCamera(CameraUpdateFactory.newLatLng(mark)); Circle circle=mMap.addCircle(circleoptions.center(mark).radius(5000.0)); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(circleoptions.getCenter(),getZoomLevel(circle))); }
private void drawFlagsCircle(LatLng position, String circleKey, int strokeColor, int fillColor){ // check if circle exist or not. if(flagsCircleHashMap.containsKey(circleKey)){ flagsCircleHashMap.get(circleKey).setCenter(position); flagsCircleHashMap.get(circleKey).setFillColor(fillColor); flagsCircleHashMap.get(circleKey).setRadius(Constants.FLAG_RADIUS); flagsCircleHashMap.get(circleKey).setStrokeColor(strokeColor); }else { CircleOptions circleOptions = new CircleOptions() .center(position) .strokeColor(strokeColor) .fillColor(fillColor) .radius(Constants.FLAG_RADIUS); flagsCircleHashMap.put(circleKey, googleMap.addCircle(circleOptions)); } }
@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); }
private void refreshAccuraryIndicator(Location location) { if (mShowAccuracy) { // Accuracy circle marker if (mAccuracyCircle != null) { mAccuracyCircle.setCenter(new LatLng(location.getLatitude(), location.getLongitude())); mAccuracyCircle.setRadius(location.getAccuracy()); } else if (mMap != null) { CircleOptions circleOptions = new CircleOptions().center(new LatLng(location.getLatitude(), location.getLongitude())); circleOptions.fillColor(getResources().getColor(R.color.accuracy_circle_fill_color)); circleOptions.strokeColor(android.R.color.black); circleOptions.strokeWidth(1); circleOptions.radius(location.getAccuracy()); circleOptions.zIndex(2f); mAccuracyCircle = mMap.addCircle(circleOptions); } } else { if (mAccuracyCircle != null) { mAccuracyCircle.remove(); mAccuracyCircle = null; } } }
private void updateLocationOnMap(@NonNull Location location) { if (locationMarker != null) { locationMarker.remove(); } LatLng userLocation = new LatLng(location.getLatitude(), location.getLongitude()); if (!followed) { mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(userLocation, 15)); followed = true; } locationMarker = mMap.addMarker(new MarkerOptions().position(userLocation).title("Your location")); if (radiusCircle != null) { radiusCircle.remove(); } radiusCircle = mMap.addCircle(new CircleOptions().center(locationMarker.getPosition()).radius(Double.parseDouble(PreferenceManager.getDefaultSharedPreferences(this).getString(getString(R.string.pref_radius_key), getString(R.string.pref_radius_default)))).fillColor(Color.argb(195, 102, 147, 173))); }
private void redrawLocationOnMap() { if(locationMarker!=null) { LatLng markerLocation = locationMarker.getPosition(); if (!followed) { mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(markerLocation, 15)); followed = true; } locationMarker = mMap.addMarker(new MarkerOptions().position(markerLocation).title("Your location")); if (radiusCircle != null) { radiusCircle.remove(); } radiusCircle = mMap.addCircle(new CircleOptions().center(locationMarker.getPosition()).radius(Double.parseDouble(PreferenceManager.getDefaultSharedPreferences(this).getString(getString(R.string.pref_radius_key), getString(R.string.pref_radius_default)))).fillColor(Color.argb(195, 102, 147, 173))); } else { Log.d("MapsActivity", "redrawLocationOnMap called with null==locationMarker"); } }
public void setScanning(boolean scanning) { if (scanRange != null) scanRange.remove(); if (scanning) { scanRange = mMap.addCircle(new CircleOptions().center(location).strokeColor(Color.argb(50, 29, 132, 181)).fillColor(Color.argb(30, 29, 132, 181)).radius(50)); scanButton.setVisibility(View.INVISIBLE); scanProgressBar.setVisibility(View.VISIBLE); cancelScanButton.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE); progressBar.setProgress(0); } else { scanButton.setVisibility(View.VISIBLE); scanProgressBar.setVisibility(View.INVISIBLE); cancelScanButton.setVisibility(View.INVISIBLE); progressBar.setVisibility(View.INVISIBLE); scanRange = null; if (rangeCenter != null) rangeCenter.remove(); rangeCenter = null; } }
private void nearbyRadius(LatLng latLng) { int radius = Integer.parseInt(settingsSharedPreferences.getString("nearby_radius", "100")); if (nearbyCircle != null) { nearbyCircle.setCenter(latLng); nearbyCircle.setRadius(radius); } else { CircleOptions nearbyCircleOptions = new CircleOptions() .center(latLng) .radius(radius) .fillColor(Application.getContext().getResources().getColor(R.color.colorPrimaryTransparent)) .strokeWidth(0); nearbyCircle = googleMap.addCircle(nearbyCircleOptions); } nearbyFriends(); }
public DraggableCircle(LatLng center, double radiusDouble) { this.radius = radiusDouble; centerMarker = mMap.addMarker(new MarkerOptions() .position(center) .draggable(true)); radiusMarker = mMap.addMarker(new MarkerOptions() .position(toRadiusLatLng(center, this.radius)) .draggable(true) .icon(BitmapDescriptorFactory.defaultMarker( BitmapDescriptorFactory.HUE_AZURE))); circle = mMap.addCircle(new CircleOptions() .center(center) .radius(this.radius) .strokeWidth(DEFAULT_CIRCLE_WIDTH) .strokeColor(DEFAULT_STROKE_COLOR) .fillColor(DEFAULT_FILL_COLOR)); }
/** * Reconstructs the result. * * @param in The parcel where the result was written to */ protected Result(Parcel in) { bundleId = in.readString(); markers = new ArrayList<>(); ArrayList<MarkerOptions> optionsList = in.createTypedArrayList(MarkerOptions.CREATOR); ArrayList<Bitmap> bitmapList = in.createTypedArrayList(Bitmap.CREATOR); ArrayList<Pair<MarkerOptions, Bitmap>> markers = new ArrayList<>(); polylines = in.createTypedArrayList(PolylineOptions.CREATOR); polygons = in.createTypedArrayList(PolygonOptions.CREATOR); circles = in.createTypedArrayList(CircleOptions.CREATOR); if (bitmapList.size() != optionsList.size()){ throw new RuntimeException("optionlist and bitmapList are not equal in size"); } for (int i = 0; i < optionsList.size(); i++){ markers.add(new Pair<MarkerOptions, Bitmap>(optionsList.get(i),bitmapList.get(i))); } this.markers = markers; }
private void addMarker(LatLng position){ mMap.clear(); mWorkspaceMarker = new MarkerOptions() .position(position) .title("Your Workplace") .icon(BitmapDescriptorFactory.fromResource(R.drawable.location)); mMap.addMarker(mWorkspaceMarker); // Instantiates a new CircleOptions object and defines the center and radius double radiusInMeters = 100.0; int strokeColor = 0xffff0000; //red outline int shadeColor = 0x44ff0000; //opaque red fill CircleOptions circleOptions = new CircleOptions().center(position).radius(radiusInMeters).fillColor(shadeColor).strokeColor(strokeColor).strokeWidth(2); Circle mCircle = mMap.addCircle(circleOptions); if (myLocation!=null){ calculationByDistance(myLocation,position); } mAddressET.setText(getAddressFromCoordinates(position)); }
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 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 displayLinesAndAreas(List<ILatLonRecord> waypoints) { try { PolylineOptions polyline = new PolylineOptions().width(ResourcesHelper.getDimensionPixelSize(this, R.dimen.task_line_width)).color(getResources().getColor(R.color.task_line)); for (int i = 0; i < waypoints.size(); i++) { CRecordWayPoint cRecordWayPoint = (CRecordWayPoint) waypoints.get(i); if (cRecordWayPoint.getType() == CRecordType.START || cRecordWayPoint.getType() == CRecordType.TURN || cRecordWayPoint.getType() == CRecordType.FINISH) { polyline.add(new LatLng(waypoints.get(i).getLatLon().getLat(), waypoints.get(i).getLatLon().getLon())); } if (cRecordWayPoint.getType() == CRecordType.TURN) { googleMap.addCircle(new CircleOptions().center(new LatLng(waypoints.get(i).getLatLon().getLat(), waypoints.get(i).getLatLon().getLon())) .radius(TaskConfig.getAreaWidth()).strokeColor(Color.TRANSPARENT) .strokeWidth(getResources().getDimensionPixelSize(R.dimen.task_line_width)) .fillColor(getResources().getColor(R.color.task_fill_color))); } } googleMap.addPolyline(polyline); } catch (Throwable t) { Logger.logError("Error trying to draw waypoints: " + t.getMessage()); } }
/** * Makes a CircleOptions out of this KnownLocation (when added to the map, * you get the actual Circle back). This is used in KnownLocationsPicker to * give the user a better idea of what the range looks like. * * @param c a Context * @return a CircleOptions representing this KnownLocation's location and range */ @NonNull public CircleOptions makeCircle(@NonNull Context c) { CircleOptions toReturn = new CircleOptions(); KnownLocationPinData data = new KnownLocationPinData(c, mLocation); int baseColor = data.getColor(); toReturn.center(mLocation) .radius(mRange) .strokeWidth(c.getResources().getDimension(R.dimen.known_location_circle_stroke_width)) .strokeColor( Color.argb( c.getResources().getInteger(R.integer.known_location_circle_stroke_alpha), Color.red(baseColor), Color.green(baseColor), Color.blue(baseColor))) .fillColor( Color.argb( c.getResources().getInteger(R.integer.known_location_circle_alpha), Color.red(baseColor), Color.green(baseColor), Color.blue(baseColor))); return toReturn; }
private void loadGeofences() { MapDataProvider mapDataProvider = new MapDataProvider(this); mapDataProvider.prepareMapData(); mCircleOptionsArrayList = new ArrayList<CircleOptions>(); mMarkerOptionsArrayList = new ArrayList<MarkerOptions>(); mCircleOptionsArrayList = mapDataProvider.getCircleOptions(); mMarkerOptionsArrayList = mapDataProvider.getMarkerOptions(); if (null != mCircleOptionsArrayList && null != mMarkerOptionsArrayList) { int count = mCircleOptionsArrayList.size(); for (int i = 0; i < count; i++) { mMap.addCircle(mCircleOptionsArrayList.get(i)); mMap.addMarker(mMarkerOptionsArrayList.get(i)); } } }
private void drawDBGeofences(GeofenceItem geofenceItem) { LatLng myPosition = new LatLng( Double.valueOf(geofenceItem.getLatitude()), Double.valueOf(geofenceItem.getLongitude())); MarkerOptions mo = new MarkerOptions() .position(myPosition) .visible(true) .title(geofenceItem.getName()); Marker marker = mGooglemap.addMarker(mo); marker.showInfoWindow(); mGooglemap.addCircle(new CircleOptions() .center(myPosition) .radius(Double.valueOf(geofenceItem.getRadius())) .strokeColor(Color.RED)); }
@Override public void onMapReady(GoogleMap googleMap) { LatLng myPosition = new LatLng( Double.valueOf(mGeofencesList.get(Utils.LATITUDE)), Double.valueOf(mGeofencesList.get(Utils.LONGITUDE))); MarkerOptions mo = new MarkerOptions() .position(myPosition) .visible(true) .title(mGeofencesList.get(Utils.NAME)); Marker marker = googleMap.addMarker(mo); marker.showInfoWindow(); Circle circle = googleMap.addCircle(new CircleOptions() .center(myPosition) .radius(Double.valueOf(mGeofencesList.get(Utils.RADIUS))) .strokeColor(Color.RED)); googleMap.moveCamera(CameraUpdateFactory.newLatLng(myPosition)); googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(myPosition, Utils.getZoomLevel(circle))); }
/** * 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; }
/** * Primary constructor * * @param map * @param center center of circle in geo coordinates * @param radiusMeters radius of circle in meters * @param strokeWidth circle stroke with in pixels * @param strokeColor circle stroke color * @param fillColor circle fill color * @param minRadiusMeters optional - circle min radius in meters (circle will not shrink bellow this, and callback is called when reached) * @param maxRadiusMeters optional - circle max radius in meters (circle will not expand above this, and callback is called when reached) * @param centerDrawableId drawable ressource id for positioning marker. If not set a default geomarker is used * @param radiusDrawableId drawable ressource id for resizing marker. If not set a default geomarker is used * @param moveDrawableAnchorU horizontal anchor for move drawable * @param moveDrawableAnchorV vertical anchor for move drawable */ public MapAreaWrapper(GoogleMap map, LatLng center, double radiusMeters, float strokeWidth, int strokeColor, int fillColor, int minRadiusMeters, int maxRadiusMeters, int centerDrawableId, int radiusDrawableId, float moveDrawableAnchorU, float moveDrawableAnchorV) { this.radiusMeters = radiusMeters; this.minRadiusMeters = minRadiusMeters; this.maxRadiusMeters = maxRadiusMeters; centerMarker = map.addMarker(new MarkerOptions() .position(center) .anchor(moveDrawableAnchorU, moveDrawableAnchorV) .draggable(true)); if (centerDrawableId != -1) { centerMarker.setIcon(BitmapDescriptorFactory.fromResource(centerDrawableId)); } circle = map.addCircle(new CircleOptions() .center(center) .radius(radiusMeters) .strokeWidth(strokeWidth) .strokeColor(strokeColor) .fillColor(fillColor)); }
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(0x801681FB) .strokeColor(0x800A78DD) .zIndex(1.0f) .visible(true) .strokeWidth(5.0f)); } } else { // move existing markers position to received location mCircle.setCenter(center); mCircle.setRadius(accuracyRadius); } }
@SuppressLint("NewApi") private void drawCircle(){ final Circle circle = map.addCircle(new CircleOptions() .center(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude())) .strokeColor(Color.BLUE).radius(100)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ValueAnimator vAnimator = new ValueAnimator(); vAnimator.setRepeatCount(0); vAnimator.setRepeatMode(ValueAnimator.RESTART); /* PULSE */ vAnimator.setIntValues(0, 100); vAnimator.setDuration(1000); vAnimator.setEvaluator(new IntEvaluator()); vAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); vAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float animatedFraction = valueAnimator.getAnimatedFraction(); // Log.e("", "" + animatedFraction); circle.setRadius(animatedFraction * 100); } }); vAnimator.start(); } }
public CircleOptions getPoint() { if(point == null && points != null && points.size() > 0){ point = new CircleOptions().center(points.get(0)); point.radius(3); // In meters if (feature.getStatus().equalsIgnoreCase("final")) { point.fillColor(Color.argb(100, 204, 153, 255)).strokeWidth(5).strokeColor(Color.BLACK); } else if (feature.getStatus().equalsIgnoreCase("rejected")) { point.fillColor(Color.argb(100, 255, 51, 51)).strokeWidth(4).strokeColor(Color.BLACK); } else if (feature.getStatus().equalsIgnoreCase("complete")) { point.fillColor(Color.argb(150, 204, 255, 153)).strokeWidth(5).strokeColor(Color.BLACK); } else point.fillColor(CommonFunctions.pointColor).strokeWidth(4).strokeColor(Color.BLUE); point.zIndex(4); } return point; }
/** * 形状を追加する。 * * @param shapeOptions 形状オプション */ private void addShapes(@NonNull List<Parcelable> shapeOptions) { if (mMap == null) { return; } for (final Parcelable shapeOption : shapeOptions) { if (shapeOption instanceof PolygonOptions) { mShapes.add(mMap.addPolygon((PolygonOptions) shapeOption)); } else if (shapeOption instanceof PolylineOptions) { mShapes.add(mMap.addPolyline((PolylineOptions) shapeOption)); } else if (shapeOption instanceof CircleOptions) { mShapes.add(mMap.addCircle((CircleOptions) shapeOption)); } else { Log.w(TAG, "想定していない形状。" + shapeOption.getClass().getSimpleName()); } } }
private static Circle drawScaledCircle(GoogleMap map, LatLng coordinates, double percent, int strokeColor, int fillColor) { Log.d(TAG, "drawScaledCircle() - percent: " + percent); double circleArea = percent * MAX_AREA; double radius = Math.sqrt(circleArea / Math.PI); Log.d(TAG, "drawScaledCircle() - radius (m): " + radius + " circleArea: " + circleArea + " percent: " + percent + " max Area: " + MAX_AREA); CircleOptions circleOptions = new CircleOptions() .center(coordinates) .radius(radius) .fillColor(fillColor) .strokeColor(strokeColor) .strokeWidth(5); return map.addCircle(circleOptions); }
public DraggableCircle(LatLng center, double radius) { this.radius = radius; centerMarker = mMap.addMarker(new MarkerOptions() .position(center) .draggable(true)); radiusMarker = mMap.addMarker(new MarkerOptions() .position(toRadiusLatLng(center, radius)) .draggable(true) .icon(BitmapDescriptorFactory.defaultMarker( BitmapDescriptorFactory.HUE_AZURE))); circle = mMap.addCircle(new CircleOptions() .center(center) .radius(radius) .strokeWidth(mWidthBar.getProgress()) .strokeColor(mStrokeColor) .fillColor(mFillColor)); }
public DraggableCircle(LatLng center, LatLng radiusLatLng) { this.radius = toRadiusMeters(center, radiusLatLng); centerMarker = mMap.addMarker(new MarkerOptions() .position(center) .draggable(true)); radiusMarker = mMap.addMarker(new MarkerOptions() .position(radiusLatLng) .draggable(true) .icon(BitmapDescriptorFactory.defaultMarker( BitmapDescriptorFactory.HUE_AZURE))); circle = mMap.addCircle(new CircleOptions() .center(center) .radius(radius) .strokeWidth(mWidthBar.getProgress()) .strokeColor(mStrokeColor) .fillColor(mFillColor)); }
@Override public void onMapClick(LatLng arg0) { map.clear(); CircleOptions circleOptions = new CircleOptions() .center(arg0) .radius(1000) .strokeWidth(2).strokeColor(Color.BLUE) .fillColor(Color.parseColor("#500084d3")); this.map_act.setPosition(arg0); Circle circle = map.addCircle(circleOptions); seekBarListener.setCircle(circle); map_act.resetSeekBar(); map_act.setPosition(arg0); map_act.setRadius(1000); }
@UiThread public void setMarkers(){ if(map == null) return; map.clear(); List<FenceInfo> fenceinfo = store.loadAllFenceInfo(this); List<CompactVenue> venues = store.loadCompactVenues(this); for(int i = 0 ; i < venues.size() ; i++){ FenceInfo fence = fenceinfo.get(i); CompactVenue venue = venues.get(i); CircleOptions circleOptions = new CircleOptions() .center(new LatLng(venue.getLocation().getLat(), venue.getLocation().getLng())) .strokeColor(getResources().getColor(R.color.blue)) .fillColor(getResources().getColor(R.color.blue_transparent_9)) .strokeWidth(3) .radius(fence.getRadius()); // In meters map.addMarker(new MarkerOptions() .position(new LatLng(venue.getLocation().getLat(), venue.getLocation().getLng())) .draggable(false)); map.addCircle(circleOptions); } }
protected void goToCurrentLocation() { loc = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Location locate = loc.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (loc == null) { Toast.makeText(this, "Current location is not available", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(this, "Current location is available", Toast.LENGTH_SHORT).show(); LatLng ll = new LatLng(locate.getLatitude(), locate.getLongitude()); CameraUpdate update = CameraUpdateFactory.newLatLngZoom(ll, DEFAULTZOOM); mMap.animateCamera(update); Circle circle = mMap.addCircle(new CircleOptions() .center(new LatLng(locate.getLatitude(), locate.getLongitude())) .radius(7) .strokeColor(Color.BLUE) .fillColor(Color.GREEN) ); } }
private Marker plotTask(ITask t) { LatLng position = toGms(t.getLocation()); Marker m = gmap.addMarker(new MarkerOptions() .position(position) .title(t.getName()) .snippet(t.getDescription())); if (t.getRadius() > 0) { gmap.addCircle(new CircleOptions() .center(position) .strokeWidth(1) .fillColor(0x80FF80A0) .radius(t.getRadius())); } return m; }
private void onInitializeMap() { if (!mIsInitialized) { Log.d(TAG, "Initializing map."); LatLng userPosition = ((MainActivity) getActivity()).getLastLocation(); if (userPosition == null) { return; } // move camera to current position getMap().moveCamera( CameraUpdateFactory.newLatLngZoom(userPosition, ZOOM_LEVEL_INITIAL)); // draw a circle around it getMap().addCircle(new CircleOptions() .center(userPosition) .radius(RADIUS_METERS) .strokeColor(getResources().getColor(R.color.lilac)) .strokeWidth(4) .fillColor(getResources().getColor(R.color.lilac_transparent))); mIsInitialized = true; } }
@Override public void onMapReady(GoogleMap googleMap) { mGoogleMap = googleMap; goToLocation(longitude, latitude, 7); mGoogleMap.addCircle(new CircleOptions() .center(new LatLng(longitude, latitude)) .radius(40000) .strokeColor(Color.argb(30, 255, 0, 0)) .clickable(true) .fillColor(Color.argb(100, 255, 0, 0))); }
@Override public void onMapClick(LatLng point) { mMap.clear(); System.out.println("125"); CircleOptions circleoptions = new CircleOptions().strokeWidth(2).strokeColor(Color.BLUE).fillColor(Color.parseColor("#500084d3")); try { com.trackin.iodroid.trackin.GPSTracker gpsTracker = new com.trackin.iodroid.trackin.GPSTracker(getApplicationContext()); mLocation = gpsTracker.getLocation(); latitude = mLocation.getLatitude(); longitude = mLocation.getLongitude(); /* Geocoder geocoder = new Geocoder(this); geocoder.get*/ // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); lat = gpsTracker.getLocation().getLatitude(); lng = gpsTracker.getLocation().getLongitude(); LatLng currloc = new LatLng(lat, lng); mMap.addMarker(new MarkerOptions().position(currloc).title(getAddress(currloc))); mMap.moveCamera(CameraUpdateFactory.newLatLng(currloc)); Circle circle = mMap.addCircle(circleoptions.center(currloc).radius(5000.0)); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(circleoptions.getCenter(), getZoomLevel(circle))); final TextView textViewToChange = (TextView) findViewById(R.id.cord); textViewToChange.setText("Latittude:"+point.latitude+"\nLongitude"+point.longitude); System.out.println("149"); } catch (Exception e) { //toast } System.out.println("153"); }
@Override public void setMarkerOnMap(CheckPoint checkPoint) { if (googleMap != null) { LatLng latLng = new LatLng(checkPoint.getLatitude(), checkPoint.getLongitude()); googleMap.addMarker(new MarkerOptions().position( latLng) .draggable(false) .icon(BitmapDescriptorFactory.fromResource(R.drawable.flag))); googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15), 10, null); googleMap.addCircle(new CircleOptions().center(latLng) .strokeWidth(5) .strokeColor(getResources().getColor(R.color.cardview_dark_background)) .radius(500)); } }