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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:15:53+00:00 2026-06-08T19:15:53+00:00

I want to create a functionality like Google Maps. I want to update my

  • 0

I want to create a functionality like Google Maps. I want to update my location marker whenever a person start walking/driving. I am thinking of using onLocationChange method of LocationListner but I am not sure. I also like to draw the path with updating location on the Google Maps.

All suggestions are most welcome.

ItemizedOverlay:-

public class LocationOverlay extends ItemizedOverlay<OverlayItem>{

    private List<OverlayItem> myOverlays;
    Path path;
    static int cnt = -1;
    public LocationOverlay(Drawable defaultMarker) {
        super(boundCenterBottom(defaultMarker));
        System.out.println("Normal...");
        myOverlays = new ArrayList<OverlayItem>();
    }


    public void addOverlay(OverlayItem overlay) {
        System.out.println("Add Overlay called");
        myOverlays.add(overlay);
        populate();
            cnt++;
    }

    @Override
    protected OverlayItem createItem(int i) {
        return myOverlays.get(i);
    }

    public void removeItem(int i) {
        myOverlays.remove(i);
        populate();
    }

    @Override
    public int size() {
        return myOverlays.size();
    }

    @Override
    public void draw(Canvas canvas, final MapView mapView, boolean shadow) {


           if (shadow) {
            paint.setDither(true);
            paint.setColor(Color.RED);
            paint.setStyle(Paint.Style.STROKE);
            paint.setStrokeJoin(Paint.Join.ROUND);
            paint.setStrokeCap(Paint.Cap.ROUND);
            paint.setStrokeWidth(4);

            path = new Path();
            Point point1 = new Point();
            Projection projection = mapView.getProjection();
            if (myOverlays.size() > 1) {

                System.out.println(">>>>>>>>>>>");

                for (int i = 0, j=i; i < myOverlays.size(); i++) {
                Point point1 = new Point();
                Point point2 = new Point();
                projection.toPixels(myOverlays.get(i).getPoint(), point1);

                System.out.println(">>>>>>>>>>>");

                projection.toPixels(myOverlays.get(j++).getPoint(), point2);
                System.out.println("Point == " + j);

                path.moveTo(point2.x, point2.y);
                path.lineTo(point1.x, point1.y);
                canvas.drawPath(path, paint);
                super.draw(canvas, mapView, shadow);
            }   
            }
        }
        canvas.drawPath(path, paint);
        super.draw(canvas, mapView, shadow);
    }
}

NOTE – draw method gets called multiple time for single locationChanged.

EDIT :-

I am able to draw the route whenever there is any location changed event fire but I am facing a small problem there. Its also drawing path from root every time. I want that from last place it should start drawing the path (i.e connecting from last to next location). I am attaching one image for better understanding.

enter image description here

From the image you can see that the starting point is also connected to last point. I don’t want this. Any idea on this.

  • 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-08T19:15:54+00:00Added an answer on June 8, 2026 at 7:15 pm

    Current location can be easily drawn with MyLocationOverlay. What you need to do – is to add this overlay to your MapView. Something like:

    mapView.addOverlay(new MyLocationOverlay(context, mapView));
    

    The default location dot will be drawn automatically and will be updated as soon as you move

    With route it is a bit trickier, but still there is no rocket science in there. What you need to do – is to extend Overlay class and implement draw() logic. You need to keep track of GeoPoints you travelled and project them on a map (in your overlay’s draw() you can ask your mapView for a Projection instance – getProjection(). You can use this projection to map GeoPoints to your map coordinates).
    As soon as you have list of GeoPoints – you can create a Path and draw this Path on a Canvas

    The simplified example how to draw path on a map (there are some custom classes I use in my project, but you should get an idea):

    Path path;
    
    @Override
    public void draw(Canvas canvas, final MapView mapView, boolean shadow)
    {
        Projection proj = mapView.getProjection();
        updatePath(mapView,proj);
        canvas.drawPath(path, mPaint);
    }
    
    protected void updatePath(final MapView mapView, Projection proj)
    {
        path = new Path();
    
        proj.toPixels(mPoints.get(0).point, p);
        path.moveTo(p.x, p.y);
    
        for(RouteEntity.RoutePoint rp : mPoints)
        {
            proj.toPixels(rp.point, mPoint);
            path.lineTo(mPoint.x, mPoint.y);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a simple editor like Notepad++ with simple functionality... I need
I want to create a simple login functionality in WP7 app using remote MySQL
I want create module which update list of usb devices automatically (not only mass
It seems like PasteScript 's paster create functionality is just about the only widely
I want to create screen-in-screen functionality in my HTML5 game, and to do this
Hi i want to create an application that works like spring quartz i can
I want to create a SQL-like interface for a special data source which I
I'm making a google maps project and need to create a route clicking on
Excel (2010) has functionality to create pivot tables from an external data source like
I've got a network of websites that I want to create single sign-on functionality

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.