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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:37:58+00:00 2026-06-11T15:37:58+00:00

I’m working on a project to display a route in a MapView based on

  • 0

I’m working on a project to display a route in a MapView based on current location from GPS Provider. I’m able to draw the path between two points but the problem starts when the location changes to a new point causing the draw path to erase.

Basically my Location Listener saves the current GeoPoint and sets the new GeoPoint location and after that it starts the overlay to draw a path based on those two points.I think an option could be saving the coordinates to a database and then pulling the information from there to draw the path.

Here is my code so far:

private class MyLocationListener implements LocationListener {

   public void onLocationChanged(Location location) {   

     Toast.makeText(getBaseContext(), "Tracking device..",
                            Toast.LENGTH_SHORT).show();

            gp2 = new GeoPoint(
                    gp1.getLatitudeE6(),
                    gp1.getLongitudeE6());

            gp1 = new GeoPoint(
                    (int) (location.getLatitude() * 1000000),
                    (int) (location.getLongitude() * 1000000));


    myOverlay = new MapOverlay();

    mapOverlays_route.add(myOverlay);
    myMapView.invalidate();
}
}


class MapOverlay extends  com.google.android.maps.Overlay{

        public MapOverlay(){


        }


        public void draw(Canvas canvas, MapView mapv, boolean shadow){
         super.draw(canvas, mapv, shadow);

        //Configuring the paint brush

        Paint mPaint = new Paint();
         mPaint.setDither(true);
         mPaint.setColor(Color.RED);
         mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
         mPaint.setStrokeJoin(Paint.Join.ROUND);
         mPaint.setStrokeCap(Paint.Cap.ROUND);
         mPaint.setStrokeWidth(4);




         Point p1 = new Point();
         Point p2 = new Point();
         Path path1 = new Path();


         Path path2 = new Path();
         projection.toPixels(gp1, p1);
         projection.toPixels(gp2, p2);

         path1.moveTo(p2.x, p2.y);//current location
         path1.lineTo(p1.x,p1.y);//new location


         canvas.drawPath(path1, mPaint);//drawing the path

         }

        }
  • 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-11T15:38:00+00:00Added an answer on June 11, 2026 at 3:38 pm

    Like you said, you need to have these coordinates stored somewhere. These can be stored in a database or a more temporary local list. The draw method must also iterate between all of the coordinates you store.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from

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.