Open stleusc opened 10 years ago
Well that code would/could render one (1) circle and not many. Basically I want a circle around each visible marker in an ItemizedLayer. Also, I'm not an OpenGL expert (actually, no clue about OpenGL) so I don't know how to extend from one circle to many. Maybe there is an easy way to add a circle around each visible Item in ItemizedLayer?
GeoPoint position = new GeoPoint(40.689248,-74.044499);
double distanceKm = 0.500;
int lineWidth = 4;
int lineColor = Color.parseColor("#990F98D0");
// Radius
PathLayer circleLayer = new PathLayer(mMap, lineColor, lineWidth);
List<GeoPoint> pts = new ArrayList<GeoPoint>();
for(int i=0; i<360; i++){
pts.add(destinationPoint(position, i, distanceKm));
}
circleLayer.setPoints(pts);
mMap.layers().add(circleLayer);
public GeoPoint destinationPoint(GeoPoint latlon, double brng, double distanceKm) {
final double dist = distanceKm / 6371;
final double bearingRad = Math.toRadians(brng);
double lat1 = Math.toRadians(latlon.getLatitude());
double lon1 = Math.toRadians(latlon.getLongitude());
final double lat2 =
Math.asin(
Math.sin(lat1) * Math.cos(dist) +
Math.cos(lat1) * Math.sin(dist) * Math.cos(bearingRad));
double lon2 =
lon1 +
Math.atan2(
Math.sin(bearingRad) * Math.sin(dist) * Math.cos(lat1),
Math.cos(dist) - Math.sin(lat1) * Math.sin(lat2));
lon2 = (lon2 + 3 * Math.PI) % (2 * Math.PI) - Math.PI;
return new GeoPoint(Math.toDegrees(lat2), Math.toDegrees(lon2));
}
Get circle in meters:
public List<GeoPoint> addCircle(GeoPoint latlon, double distance) {
List<GeoPoint> pts = new ArrayList<GeoPoint>();
for(int i=0; i<360; i++){
pts.add(destinationPoint(latlon, i, distance/1000));
}
return pts;
}
How can I create something similar to this:
Above code is Google Maps API V2. I did not find and easy way to create a layer that can draw circles with a radius given in meters/miles/feet around lat/lon
Any help???