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 8664659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:17:39+00:00 2026-06-12T17:17:39+00:00

I currently need to display a boat/cruise ship route in a MapView, something like

  • 0

I currently need to display a boat/cruise ship route in a MapView, something like this
Cruise routes

I started coding my version of it, but since every example that I see of water routes are the same I started wondering if there was a “standard” method of doing it. I have been searching for hours and haven’t found anything yet, so I decided to ask here.

Here’s what I have so far:

Point point2 = new Point();
projection.toPixels(gp2, point2);
paint.setStrokeWidth(5);
paint.setPathEffect(new DashPathEffect(new float[] {8,12}, 5));
paint.setAlpha(defaultColor==Color.parseColor("#6C8715")?200:100);
canvas.drawLine(point.x, point.y, point2.x,point2.y, paint);

It is working and the only thing left to do is adjust the line every time that the user zooms.
Is this the way to do it, or there’s a standard way of doing it?

Any help is appreciated, thank you.

  • 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-12T17:17:41+00:00Added an answer on June 12, 2026 at 5:17 pm

    If you move your code to an Overlay then you wouldn’t have to worry about adjusting the line when the user zooms/pans. Since you probably have more than two points to draw you can also take advantage of the Path class.

    import com.google.android.maps.Overlay;
    
    class PathOverlay extends Overlay {
    
        private void List<GeoPoint>geoPoints;
    
        public PathOverlay(List<GeoPoint> points) {
            this.geoPoints = geoPoints;
        }   
    
        public void draw(Canvas canvas, MapView mapView, boolean shadow) {
            super.draw(canvas, mapv, shadow);
    
            Paint paint = new Paint();
            paint.setStrokeWidth(5);
            paint.setPathEffect(new DashPathEffect(new float[] {8,12}, 5));
            paint.setAlpha(defaultColor==Color.parseColor("#6C8715")?200:100);
    
            Path path = new Path();
            boolean isFirst = true;
            for (GeoPoint geoPoint : this.geoPoints) {
                Point point = new Point();
                mapView.getProjection().toPixels(geoPoint, point);
                if (isFirst) {
                    isFirst = false;
                    path.moveTo(point.x, point.y);
                }
                else {
                    path.lineTo(point.x,point.y);
                }
            }
            canvas.drawPath(path, paint);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently this is my code, and I need to display Please enter a valid
I need to display elapsed time in my application form. I currently do this
I'm currently working on a auction site where I need to display a countdown
I need to display a complete calendar (12 months, 31~ days/month) on screen. Currently,
I need to display a list of all of the playlists currently on the
Here is my current issue. I need to display a tree like structure displaying
I am currently using dojo 1.7. My requirement is that i need to display
Fiddle Link I need to display border behind a h1 tag but just not
Need to display incoming mails when the user is currently logged in. Can we
Currently we access our repo via svn:\, but recently the need to access a

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.