Draw a closed polygon witihin mapview

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Draw a closed polygon witihin mapview

Postby dudero » Tue Jan 25, 2011 3:09 pm

Hello,
I want to display borders (based on GeoPoints) on my mapview. But as far as I know android does not support anything like "java.awt.polygon"?

My problem is that if I add new points to my polygon some edges intersect with others edges. The soloution is that I have to sort my points into the right order, but I think this is not really trivial...

At the moment I draw my polygon with following code into the draw-method of an ItemizedOverlay:
Code: Select all
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
...
   for(int i = 0; i < geopoints.size(); i++){
     //If its not the last point: connect the current point with its next
     if ( i < size()-1 )
       canvas.drawLine(Point(i).x,Point(i).y, Point(i+1).x, Point(i+1),mPaint);
     //The last point will be connected to the first(0) the get a closed polygon
     else
       canvas.drawLine(Point(i).x,Point(i).y, Point(0).x, Point(0).y, mPaint);
   }
...
}



Any suggestions?


Greetz dudero
dudero
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Jan 25, 2011 1:25 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 5 guests