We had developer an application in past which had integrated old Arc gis core Android library. Now we have migrated from 10x to 100.9.0 Runtime library. And we have observed many functionality is not working due to method changed. Most of the functionality we had fixed but we are stuck at 2 functionality which is like draw circle with user centre location.
Please see my below code which I have used to draw circle.
Actually we are able to get the circle on map but it is not with the centre point which I have used. I have passed my location as param you can see in below method, the first one param.
private Graphic getCircleForMapReference(LatLng position, double radius, SpatialReference mapReference, MapView mapView) {
int pointCount = 360;
if (radius > 0)
{
Application application = ApplicationUtil.getInstance().getApplicationInstance();
int color = application.getResources().getColor(com.cityshob.responder.R.color.investigationCircleOrange);
Point center = LocationUtils.convertToMapPoint(position, mapReference);
SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID,color, 7);
PointCollection pointCollection = new PointCollection(SpatialReferences.getWgs84());
for (int i = 0; i <= pointCount; i++)
{
double rad = 2 * Math.PI / pointCount * i;
double x = Math.cos(rad) * radius + center.getX();
double y = Math.sin(rad) * radius + center.getY();
android.graphics.Point screenPoint = new android.graphics.Point((int) Math.round(x),(int) Math.round(y));
Point mapPoint = mapView.screenToLocation(screenPoint);
Point wgs84Point = (Point) GeometryEngine.project(mapPoint, SpatialReferences.getWgs84());
pointCollection.add(wgs84Point.getX(),wgs84Point.getY());
}
Polyline lineGeometry = new Polyline(pointCollection);
Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol);
return lineGraphic;
}
return null;
}
Second issue which I am facing is to clear that circle. I used below line of code to clear but it is not working.
mGraphicsLayer.getGraphics().remove(circle)
where
mGraphicsLayer is the object of GraphicOverlay
circle is the index where I have added object.we are stuck on above 2 points, Please help us as soon as possible. Please let us know what we had implemented wrong.