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

  • Home
  • SEARCH
  • 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 8836973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:36:50+00:00 2026-06-14T09:36:50+00:00

Background I´m developing an application that displays a path over a map (Google maps

  • 0

Background

I´m developing an application that displays a path over a map (Google maps and OpenStreet maps). Bellow an output example:

Path

To draw the above path I´m using the following approach:

private void drawWithoutElevation(Canvas canvas, Projection projection){
    if(rebuildRequired)
        pathBuild();
    else{ //check if path need to be offset
        if(offsetRequired){
            path.offset(offset.x, offset.y);
        }
    }
    canvas.drawPath(path, paint); 
}

The approach above takes about 1.5ms to draw 10.000 points, which is acceptable.

However, I also want to show the path using different colors depending on the point altitude. Bellow an output example:

Path 2

As I couldn’t find a way to define different color per path segment, I’ve tried the following approaches:

Approach 1

The most obvious solution, using a canvas.drawLine() between each point in the path. Example bellow:

private void drawWithElevation(Canvas canvas, Projection projection){
    for(int i=1; i<geoArrList.size(); i++){
            paint.setColor(geoArrList.get(i));
            canvas.drawLine(pPrev.x, pPrev.y, p1.x, p1.y, paint);
            pPrev.set(p1.x, p1.y);
        }
    }
}

This results in a very disappointing time of about 80ms for the same 10.000 points.

Approach 2

Segment the altitude in discrete steps, and build a list of Path objects, one per altitude segment change. Code example below:

private void drawWithElevation(Canvas canvas, Projection projection){
    if(rebuildRequired)
        pathBuild();
    for(int i=0; i<pathSegments.size(); i++){
        if(needOffset){
            pathSegments.get(i).path.offset(offsetX, offsetY);
        }
        paint.setColor(pathSegments.get(i).color);
        canvas.drawPath(pathSegments.get(i).path, paint); 
    }
}

This results in a less disappointing time of about 5ms for the same 10.000 points.

Question

Although the last approach shows a significant improvement, compared to the first one, I would like to further improve it.

Is there any other approach that could be used to draw the path with different color per segment in a more efficient way (speed and/or memory usage)?

Thanks for your time and your help.

  • 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-14T09:36:51+00:00Added an answer on June 14, 2026 at 9:36 am

    Check out the source for MyTracks by google, that may lead to some inspiration

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

Sidebar

Related Questions

Background I am developing an application (with Spring MVC ) with its base path
I am developing one application.In that i set the one image as background for
Background: We are developing a web application that includes charts. Currently one can left-click
Background I'm developing a research application that runs on Android phones. In short, the
I'm developing an iPhone application that I want to run in the background. Stack
I'm developing an Android application that consists of: a lightweight background service that logs
My team and I are developing a WPF application that displays several concurrent XamDataChart
Background: I'm developing an application that involves taking an existing pdf form and overlaying
Background: I'm developing a WinForms application using C# with an OpenFileDialog and FileBrowserDialog that
Background: I'm developing a WinForms application using C# with an OpenFileDialog & FileBrowserDialog that

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.