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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:23:49+00:00 2026-06-16T00:23:49+00:00

I want to show a route between the user’s current location and the location

  • 0

I want to show a route between the user’s current location and the location he entered in the searchview. Here is my code for the onQueryTextSubmit method

@Override
    public boolean onQueryTextSubmit(String query) {
        // TODO Auto-generated method stub
        try
        {
            if(direction.isChecked() == false)
            {
                gc = new Geocoder(this);

                addresses = gc.getFromLocationName(query,5);
                String add = "";
                if (addresses.size() > 0) 
                {
                    p = new GeoPoint(
                            (int) (addresses.get(0).getLatitude() * 1E6), 
                            (int) (addresses.get(0).getLongitude() * 1E6));
                    mc.animateTo(p);
                    mc.setZoom(9);
                    mapView.invalidate();

                    searchView.clearFocus();
                }   
                else
                {
                     Toast.makeText(this, " Location not found.",
                                Toast.LENGTH_LONG).show();
                }
                return true;
            }
            else
            {
            // draw a route between the locations                    
                 return true;
            }
        }
        catch(IOException ex)
        {

        }

        return false;
    }

what is the simplest way to do it? (examples will help me understand more)

Thank You

  • 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-16T00:23:49+00:00Added an answer on June 16, 2026 at 12:23 am

    Once you have your destination GeoPoint you could do an http request to google in this address:

    String url = "http://maps.google.com/maps?f=d&hl=es&saddr="+ origin +"&daddr=" + destination + "&ie=UTF8&om=0&output=dragdir";
    

    being origin and destination (latitude, longitude) points.

    For example, this request gives you this json:

    {tooltipHtml:" (86,4 km / 55 minutos)",polylines:[{id:"route0",points:"wa{uFt|kUoAkE??jDyE??uFuLqFaH??mAl@gAZ??q@[Yg@KwCBkATq@X[bCu@??tMsBrIuBrDoA~J}EbC{@pCy@dIeA`JBrDThd@nFpDRnTkAdBGVFhRyC`McA|KkAzCK|CP??lA~@NZHn@I~@Q`@c@\\[Hu@KYWUe@Gc@D{BnG}a@`Kcb@|A}JvAkOXmHDgFKcMMmDkBgW??SaCEoFBaCb@mH`AwGdE_Qh@sCf@}Db@yGFcFIqE]iGcAkLUyGB{K^aHf@_EfC_PtAqOlB}X|AiNrCyTnE{WjDqOtCqK~DoMhHoSvX}u@~KeYpI}VrSkk@zBiJ`@_Ct@oG`@mGPoGCcLMoDq@wHiCaSe@qE_BgTMuEEoIDsJxA_`@DcHGoCw@iJkAoHsCwN_AcHk@mG]wGOcLLeJZiG\\gEr@kGhBeKpB{H~@uCvB{F~CuGbBuCdE_GlE}ElBgBfQeNpCsCtCmDtCoEnBsD~BmFdBqFz@_DdByIt@iGb@iFZeJBiYJ{GRkGf@{HpAaMdDwRzB{IrCsIrCoGbHiMzGmJnEaFjCeCdCwBfE}CdC_BzHiErNyG~NsFdN}DnQuDzK}A~KcAxKm@hJQhLAfhAhA~HQnFm@xGsAtFqBdCoAdEgC|GaGtEiF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ChAgDr@yDR}BhBs\\VuBx@kDlAyCdBkCdDqClQcHlC_B|CuDlJcQbA{AlAqA~_Ags@lSiSrBaCfOiWtVs]z`@_s@zMiVvAuBzPyTfRg[rBuD`B_EtCkIvKs]nCaHlEuIfHaMbMoRv[kd@lEqFfo@qp@|C{Cf@[bQsHrBoA~AsAbAqA|GsMtBiC|B_BlHwD`Au@vA{AnAmB|@wB|@eDbEmThAsEh@_BzAcDnKmP~z@}kA|AcBbDcCvFyBvSgGnBa@~TiGnNmC|DkB??xCoApDU|@UtAeAZm@\\gARkBQeK@i@^cC??pBkHvFy]Pm@ZCHQVuAAc@hAyC~@m@dBYzPq@??Jd@NJR?VSBi@pBq@l@e@d@e@jAoB\\_A\\_BnBePTCN[A[SWtIsr@Aq@VCLSAg@OQpDwX^kE??rAJrB]p@[tAuA",levels:"BBBBB?BB?BB???@??BB??????@???@???????BB??@???@????@???@????BB???@????@??????@??????@??@????@??A???@????@????@?????@????A?????@?????@???@???@?????@???A?@???@????@???@???@???A?????@????@??????????@??????@????@?????@???@???@?????BB??@???@??????@????@??@???@??A???@?????@????@?@??????????@???A???@?????@?????@???@?????@???????@??@???@???@????@???@????@???@???@??@????A????@????@????@?????@???@???@?????@??????@???@???@?????@??@???@????@???@?????@??????A???@???@??@??????@????@??@?@@???@???@???@??????@?@??@????BB????@????BB???????@??BB??????@???@????????????BB???B",numLevels:4,zoomFactor:16}]}
    

    The String with name points is the polyline you have to draw on your map. But before drawing you have to decode it. Take a look here for that duty.

    Once you have your GeoPoint list, you can draw it on your map. For that you need an overlay if you’re using google api v1. I’d recommend you to have a look into api v2. It’s easier to add polylines to map objects via the addPolyline method in GoogleMap class and PolylineOptions.

    Hope that helps.

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

Sidebar

Related Questions

I want to show a route on a MKMapView between the current location and
I want to open an inbuilt google map intent to show route between two
I want to know how to display the route between two Points on map
I want to show 2 or more paths between 2 locations similar to Suggested
I want to route the root of my project to the books#show action. And
I want to get all route info when user request to server. When user
i want to show a direction to a target location from my location, i
I am able to show the route between two geo points in android using
In my rails blog I'm writing I want the show route for posts to
I want show an information page after success db opartions. And after the info

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.