Reputation: 10656
I want to show touristic areas of Morocco in an osmdroid map in my Android application.
First of all, I've been searching the web for ways to get a list of coordinates (longitude & latitude) that can define an area (like an array or json), but with no luck. There are solutions for only one point on the map.
Secondly, with these coordinates, how can I show an area on osmdroid ? Thanks.
Upvotes: 2
Views: 1624
Reputation: 2156
First I would highly recommend you to use Google Maps Api V2 through the Google Play Services. This will work much easier. Any reason why you are not using this ?
Second, to draw a polygon on the map do soemthing like
private void AddPolygon() {
int diff=1000;
GeoPoint pt1=new GeoPoint(13.002798, 77.580000);
GeoPoint pt2= new GeoPoint(pt1.getLatitudeE6()+diff, pt1.getLongitudeE6());
GeoPoint pt3= new GeoPoint(pt1.getLatitudeE6()+diff, pt1.getLongitudeE6()+diff);
GeoPoint pt4= new GeoPoint(pt1.getLatitudeE6(), pt1.getLongitudeE6()+diff);
GeoPoint pt5= new GeoPoint(pt1);
PathOverlay myOverlay= new PathOverlay(Color.RED, this);
myOverlay.getPaint().setStyle(Paint.Style.FILL);
myOverlay.addPoint(pt1);
myOverlay.addPoint(pt2);
myOverlay.addPoint(pt3);
myOverlay.addPoint(pt4);
myOverlay.addPoint(pt5);
map.getOverlays().add(myOverlay);
}
Upvotes: 2