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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:25:17+00:00 2026-06-15T20:25:17+00:00

I am trying to draw a line between 2 geopoints on a google map.

  • 0

I am trying to draw a line between 2 geopoints on a google map. I am able to place markers, but not draw a line between them. I know I am missing something trivial.

//subscribedToMap is a MapView
subscribedToMap.getOverlays().add(new PathMarker(journey.getSourceGPSX(),
                    journey.getSourceGPSY(),
                    journey.getDestinationGPSX(),
                    journey.getDestinationGPSY())) ;
subscribedToMap.invalidate();

public class PathMarker extends Overlay {
    private Double slat, slng, dlat, dlng;

    public PathMarker(Double slat, Double slng, Double dlat, Double dlng) {
        super();
        this.slat = slat;
        this.slng = slng;
        this.dlat = dlat;
        this.dlng = dlng;
    }

    @Override
    public void draw(Canvas canvas, MapView mapView, boolean shadow) {
        canvas.drawLine(slat.intValue(), slng.intValue(), dlat.intValue(),
                dlng.intValue(), new Paint());
        super.draw(canvas, mapView, shadow);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event, MapView mapView) {
        return (super.onTouchEvent(event, mapView));
    }
}

Edit : I even tried

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

    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(2);

    GeoPoint gP1 = new GeoPoint(19240000,-99120000);
    GeoPoint gP2 = new GeoPoint(37423157, -122085008);

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

    projection.toPixels(gP1, p1);
    projection.toPixels(gP2, p2);

    path.moveTo(p2.x, p2.y);
    path.lineTo(p1.x,p1.y);

    canvas.drawPath(path, mPaint);
}
  • 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-15T20:25:18+00:00Added an answer on June 15, 2026 at 8:25 pm

    Trivial Error, did not create GeoPoints correctly

    GeoPoint gP1 = new GeoPoint((int)(slat * 1E6),(int) (slng * 1E6));
    GeoPoint gP2 = new GeoPoint((int)(dlat * 1E6),(int) (dlng * 1E6));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to draw a line between two cities, on a world map, using
I'm trying to use the Google maps JavaScript API to draw a line between
So, Basically I'm trying to draw a line between the center of 2 ellipses
I'm trying to draw two circles at random positions and draw a line between
I'm trying to draw a line between two (2D) points when the user swipes
I'm trying to draw a line between one object and where the user touched.
I am trying to draw a line using the Graphics 2D but then the
I am trying to draw a line along with mouse move on a paper.
I'am trying to draw a line above mapkit. If I try to set the
I'm just trying to draw a line with JavaScript. I would like it to

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.