1

I parsed a KML file and I was able to extract the longitude and latitude data from it The problem now is that I am trying to draw a polygon using these data in my android application but whenever I try doing so nothing changes and I get the default map that open when I run google maps. I have tried many codes that where given as correct answers here on stackoverflow with the same geopoints given in them also nothing appeared...Does anyone have any idea about wwhat might be the problem? This is the link that I tried the code in it but it is not working Drawing a line/path on Google Maps

Thanks in advance

 public void draw(Canvas canvas, MapView mapv, boolean shadow){
        super.draw(canvas, mapv, shadow);

        Paint   mPaint = new Paint();
        mPaint.setDither(true);
        mPaint.setColor(Color.RED);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setStrokeWidth(2);

        GeoPoint gP1 = new GeoPoint(19240000,-99120000);
        GeoPoint gP2 = new GeoPoint(37423157, -122085008);

        Point p1 = new Point();
        Point p2 = new Point();
        Path path = new Path();

        projection.toPixels(gP1, p1);
        projection.toPixels(gP2, p2);

        path.moveTo(p2.x, p2.y);
        path.lineTo(p1.x,p1.y);

        canvas.drawPath(path, mPaint);
    }
Community
  • 1
  • 1
user1291437
  • 81
  • 1
  • 1
  • 11

1 Answers1

-1

Did u override the "draw()" method properly? is there any super() missing, or maybe dont u draw on the given canvas parameter?

Thkru
  • 4,128
  • 2
  • 16
  • 36
  • I added the draw method for you to look at, I dont know I think everything in it makes sense – user1291437 Apr 24 '12 at 12:59
  • Try logging the values of p1 and p2 to make sure that what you draw is within the screen boundaries. If they are, then there may be something wrong with the way you set up the map and overlays. That knowledge should help direct you to the right way. – Torben Apr 24 '12 at 13:05
  • thank you but excuse my question since I am new to android, how would I know my screen boundaries? – user1291437 Apr 24 '12 at 13:07
  • 1
    Not an answer, but rather a comment – Dmitry Zaytsev Feb 18 '15 at 14:14