3

How can i draw a line between two particular longitude and latitude points in android?

In my application i want to draw shortest distance path between two points which is given in the database.

bool.dev
  • 16,879
  • 5
  • 62
  • 90
Hrishik
  • 167
  • 2
  • 2
  • 7
  • If you're drawing between lat/lon points, you might want to specify what kind of surface you're drawing on. Google maps? Google earth? Open streetmaps? Android canvas? If the latter, you may have to do some sort of conversion to a planar projection and make sure that your image is properly geo-referenced, like UTM. – Marc Jun 03 '11 at 13:01

2 Answers2

5

I think this is the answer for your question.

How to draw a line in android

Community
  • 1
  • 1
Tanmay Mandal
  • 38,117
  • 12
  • 49
  • 46
2

Hi you can use this code in your onDraw() instead of drawing line... using Projection

   Projection projection = mapView.getProjection();
    Paint paint = new Paint();
    Point point = new Point();
    projection.toPixels(gp1, point);
    paint.setColor(color);
    Point point2 = new Point();
    projection.toPixels(gp2, point2);
Dhana
  • 554
  • 1
  • 8
  • 28
Sujit
  • 9,830
  • 9
  • 36
  • 42