Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7797513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:42:28+00:00 2026-06-01T23:42:28+00:00

Now below is my code that draws path between geopoints in map. This works

  • 0

Now below is my code that draws path between geopoints in map. This works perfectly fine. What I’m trying to implement is instead of drawing a line,display this path with the dots(.) as in iPhone. I want it to be like this gp1………gp2 instead of drawing in a single straight line like gp1______gp2.

I have tried almost all the options for doing this but still no success on this, any one can help me solving this?

private void drawPath(List geoPoints, int color) {
    List overlays = objMapView.getOverlays();
    int loopcount = geoPoints.size() - 1;
    for (int i = 0; i < loopcount; i++) {
        GeoPoint p1 = (GeoPoint) geoPoints.get(i);
        GeoPoint p2 = (GeoPoint) geoPoints.get(i + 1);
        MyPathOverLay p = null;
        /**** Marking the start and end of the trailpath ****/
        if (i == 0) {
            Bitmap bmp = BitmapFactory.decodeResource(this.getResources(),R.drawable.greenflag);
            p = new MyPathOverLay(p1, p2, 0xFFFF0000, true, false, bmp);
        } else if (i == loopcount - 1) {
            Bitmap bmp = BitmapFactory.decodeResource(this.getResources(),R.drawable.redflag);
            p = new MyPathOverLay(p1, p2, 0xFFFF0000, false, true, bmp);
        } else {
            p = new MyPathOverLay(p1, p2, 0xFFFF0000, false, false, null);
        }
        overlays.add(p);
    }
}



public class MyPathOverLay extends Overlay {

private GeoPoint gp1;
private GeoPoint gp2;
private int color;
Boolean  isFirstPOI;
Boolean isLastPOI;
AudioMap audioMap;
Bitmap bmp;

public MyPathOverLay(GeoPoint gp1, GeoPoint gp2, int color,Boolean first, Boolean last,Bitmap bitMap) {
    this.gp1 = gp1;
    this.gp2 = gp2;
    this.color = color;
    this.isFirstPOI= first;
    this.isLastPOI = last;
    this.bmp = bitMap;
}

@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    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);
    paint.setStrokeWidth(5);
    paint.setAlpha(120);
    canvas.drawLine(point.x, point.y, point2.x, point2.y, paint);
  //---translate the GeoPoint to screen pixels---
    Point screenPts = new Point();
    mapView.getProjection().toPixels(gp1, screenPts);
    //---translate the GeoPoint to screen pixels---
    Point screenPts1 = new Point();
    mapView.getProjection().toPixels(gp2, screenPts1);
    if(isFirstPOI == true){
            canvas.drawBitmap(bmp,screenPts.x-20,screenPts.y-40, null);  
    }
    else if(isLastPOI == true) {
            canvas.drawBitmap(bmp,screenPts1.x-20,screenPts1.y-35, null);  
   }
    super.draw(canvas, mapView, shadow);
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:42:30+00:00Added an answer on June 1, 2026 at 11:42 pm

    Thanks to this guy, I referred this example and it is working for me.

    How do I make a dotted/dashed line in Android?

    Just need to add these 2 lines,

        paint.setPathEffect(new DashPathEffect(new float[] {10,10}, 5));
        canvas.drawLine(point.x, point.y, point2.x, point2.y, paint);
    

    after I set,

        paint.setAlpha(120); 
    

    @Frankenstein, thank you

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: original question below, but I revise it now that I have some code
UPDATE 2011.09.13 This bug has been resolved by Adobe. The example code below now
Simple code fragment below draws an ellipse on a VB.NET panel. I now need
Below imagemagick code which works fine by creating RUb with the background color black
The code shows below what i have done till now. Now what i need
(Problem solved now, see answers below) Hello, in my app I am trying to
I'm trying to create code in processing that allows for runs of a certain
I give up now on this very simple test I've been trying to run.
I'm wondering how to modify my below code so that I may determine if
I created a facebook application and send request to a user through below code.Now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.