Draw a closed polygon witihin mapview

by Dudero » Tue, 25 Jan 2011 20:40:52 GMT


Sponsored Links
 Hello,

I want to display borders(based on GeoPoints) on my mapview but
android does not support anything like:

java.awt.polygon

At the moment i solve this with the following code in the draw-method
of an ItemizedOverlay:

for(int i = 0;i< geopoints.size();i++){


                                if(i<size()-1)
                                        canvas.drawLine(Point(i).x, Point(i).y, 
Point(i+1).x, Point(i+1),
mPaint);
                                //Auer beim letzen Punkt: zeichne hier zum 
ersten Punkt:
Geschlossenheit
                                else
                                        
mapView.getProjection().toPixels(((OverlayItem)
mOverlays.get(0)).getPoint(), pxNew);
                                canvas.drawLine(pxOld.x, pxOld.y, pxNew.x, 
pxNew.y, mPaint);
                        }

-- 



Re: Draw a closed polygon witihin mapview

by Kostya Vasilyev » Tue, 25 Jan 2011 21:01:06 GMT


 Android doesn't use or support java.awt.* APIs, have you tried these:

 http://developer.android.com/reference/android/graphics/Path.html 

 http://developer.android.com/reference/android/graphics/Canvas.html #drawPath(android.graphics.Path,
android.graphics.Paint)

But I don't see anything really wrong with the way you're doing it (except
for possibly joins and antialiasing at the vertices).

-- Kostya

2011/1/25 Dudero <sinfanh...@googlemail.com>


-- 


Sponsored Links


Draw a closed polygon witihin mapview

by Dudero » Tue, 25 Jan 2011 21:26:06 GMT


 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:

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

-- 



Other Threads

1. How to extract an image from a video

Hi,

      I want to get thumbnail from a video. So I need to extract first
frame in the video. Please let me know how can I do that in Android.

Thanks in Advance,
Raghu

--~--~---------~--~----~------------~-------~--~----~

2. how to add scroll bar to linearlayout

I have build a UI using linearlayout. It displays fine if phone is in
vertical position. But when I switch my phone to horizontal position.
Some content is not displayed. Is there anyway to add a scroll bar to
linear layout?
--~--~---------~--~----~------------~-------~--~----~

3. Generating Touch screen events from remote host PC

4. Android 1.5 Cupcake

5. So when will we be allowed to Force Quit any process we want without root access?

6. Anyone doesn't see the message "not found"?

7. Flicker Problem.