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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:52:57+00:00 2026-05-22T22:52:57+00:00

in my app i need to draw lines on map while i am walking,running

  • 0

in my app i need to draw lines on map while i am walking,running or driving. for get location i use OnLocationChanged method of LocattionListener class. in OnLocationChanged method i call line drawing class. the class is called it printed in log but i do not get no lines on my map. please help me. if you have experience on this or ideas please share with me.

code:

    public void onCreate(Bundle savedInstanceState) 
    { 
       .......
        myManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,new myLocationListener());
    } 
    ......
    class myLocationListener implements LocationListener {
       public void onLocationChanged(Location loc) {
                    Log.e("status","begin");
        Toast.makeText(getBaseContext(),"onStatusChanged - called",Toast.LENGTH_SHORT).show();
        Log.e("MAP","onStatusChanged - called");
        LocationManager myManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        if(myManager != null){
            String param = (String)myManager.getProviders(true).get(0);
            Location loc1 = myManager.getLastKnownLocation(param); 
            if(loc1 != null){
                latPointDst = loc1.getLatitude();
                lngPointDst = loc1.getLongitude();
                tolat=latPointDst;
                tolng=latPointDst;
                GeoPoint tmp2= new GeoPoint((int) ( tolat  * 1E6), (int) ( tolng  * 1E6));
                drawingmethod(tmp2);                    
            }
             else
                    Log.e("Err-2","Error: Location  is null");
        }
        else
            Log.e("Err-2","Error: Location Manager is null");               
        Log.e("status","end");
    }
  }    
}

public void drawingmethod(GeoPoint g2) {
    geo.add(g2);
    mc = mapView.getController();
    mapOverlays = mapView.getOverlays();        
    projection = mapView.getProjection();
    Iterator<GeoPoint> itr = geo.listIterator();
    while(itr.hasNext()){
        if(itr.hasNext()){
            p=itr.next();
        }
        if(itr.hasNext()){
            p1=itr.next();
        }
        mapOverlays.add(new MyOverlay(p.getLatitudeE6(),p.getLongitudeE6(),p1.getLatitudeE6(),p1.getLongitudeE6()));  
    }
}

// line drawing class

public class MyOverlay extends Overlay {
    private GeoPoint gp1;
    private GeoPoint gp2;

    public MyOverlay(int fromlatE6,int fromlonE6,int tolatE6,int tologE6)    {          

        int flat=0,flog=0,tlat=0,tlog=0;
        flat=fromlatE6;
        flog=fromlonE6;
        tlat=tolatE6;
        tlog=tologE6;                       
        gp1 = new GeoPoint(flat,flog);
        gp2 = new GeoPoint(tlat,tlog);
    }

    @Override
    public boolean draw(Canvas canvas, MapView mapView, boolean shadow,long when) {
        Projection projection = mapView.getProjection();
        if (shadow == false) {
            Paint paint = new Paint();
            paint.setAntiAlias(true);
            Point point = new Point();
            projection.toPixels(gp1, point);
            paint.setColor(Color.RED);
            Point point2 = new Point();
            projection.toPixels(gp2, point2);
            paint.setStrokeWidth(3);
            Log.e("location change","drawing");
            canvas.drawLine((float) point.x, (float) point.y, (float) point2.x,(float) point2.y, paint);
            Log.e("map","draw2");
        }
        return super.draw(canvas, mapView, shadow, when);
    }
    @Override
    public void draw(Canvas canvas, MapView mapView, boolean shadow) {
        // TODO Auto-generated method stub
        super.draw(canvas, mapView, shadow);
        Log.e("map","draw1");
    }
}
  • 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-05-22T22:52:58+00:00Added an answer on May 22, 2026 at 10:52 pm

    you should get list of coordinates between source and destination by calling google api.

    then you can draw the line. Refer this

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

Sidebar

Related Questions

I'm writing an app that will need to make use of Timer s, but
I am building a web app where I need to get all the images
I need to draw a lot of (about 500000) little lines in some area
I have a drawing app where the user can draw lines with their finger,
In my app i need to save changed values (old and new) when model
In my app users need to be able to enter numeric values with decimal
I'm building a app that need manage money datatype. I'm new on Obj-c, so
I have a LAMP (PHP) web app which need to interface with programs on
I'm currently working on a Silverlight app and need to convert XML data into
I have a Rails app that I need to deploy. Here are the facts:

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.