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. signatureOrSystem permission protectio

http://developer.android.com/guide/topics/manifest/permission-element.html

"signatureOrSystem" A permission that the system grants only to
applications that are in the Android system image or that are signed
with the same certificates as those in the system image.

I guess the above statement is a bit misleading. "that are signed with
the same certificates as those in the system image. "

Indeed, they must be signed by the same certificate, but not necessary
by one from the system image. Basically, this is the equivalent of the
protection level "signature". However, the above statement assumes
that "signatureOrSystem" protected permissions are only declared by
applications located in the system image.

guillaume

2. Related about progrssbar

Hi Android developer

My Question is related about progressbar(Horizantal) . i have created
a progressbar using XMl Code
but i want to change the Progress Color(yello) .plz tel me how to
change the progress Color
from Yellow to Blue


thank you

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

3. Working with zip file in Android.

4. HTTPS connections through the browser, from within application

5. Android on ZuneHD?

6. how to edit the resource.arsc file in the android APK package

7. How to import com.android.internal.telephony.Phone?