How to draw line on MapView given coordinates?
AFAIK, on iPhone it is possible.
Please advise.
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To use a MapView your Activity must extend MapActivity.
For each line you want to draw (or really anything else) you need to subclass Overlay and do the drawing in the
Overlay‘sonDraw()method. Once you’ve created yourOverlayadd it to theMapViewwith something likemMapView.getOverlays().add(new MyOverlay());.Inside your custom
Overlayyou’ll want to get a Projection with something likeProjection p = mapView.getProjection();. From theProjectionyou can convert GPS coordinates into screen coordinates withProjection‘s toPixels(GeoPoint, Point) method and then just draw to the passed in Canvas using normal Android 2D drawing methods.That’s the basics… if you need anything else, just ask.