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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:14:07+00:00 2026-06-09T20:14:07+00:00

I am using this method to draw route between two points on map in

  • 0

I am using this method to draw route between two points on map in my application

 private void DrawPath(GeoPoint src, GeoPoint dest, int color,
          MapView mMapView01) {


        // connect to map web service
        StringBuilder urlString = new StringBuilder();
        urlString.append("http://maps.google.com/maps?f=d&hl=en");
        urlString.append("&saddr=");//from
        urlString.append( Double.toString((double)src.getLatitudeE6()/1.0E6 ));
        urlString.append(",");
        urlString.append( Double.toString((double)src.getLongitudeE6()/1.0E6 ));
        urlString.append("&daddr=");//to
        urlString.append( Double.toString((double)dest.getLatitudeE6()/1.0E6 ));
        urlString.append(",");
        urlString.append( Double.toString((double)dest.getLongitudeE6()/1.0E6 ));
        urlString.append("&ie=UTF8&0&om=0&output=kml");
        Log.d("xxx","URL="+urlString.toString());


        try
        {
          URL url = new URL(urlString.toString());
          urlString = null;
          HttpURLConnection urlConnection=(HttpURLConnection)url.openConnection();
          urlConnection.setRequestMethod("GET");
          urlConnection.setDoOutput(true);
          urlConnection.setDoInput(true);
          urlConnection.connect();

          DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
          DocumentBuilder db = dbf.newDocumentBuilder();
          Document doc = db.parse(urlConnection.getInputStream());

          if(doc.getElementsByTagName("GeometryCollection").getLength()>0)
          {

            String path = doc.getElementsByTagName("GeometryCollection").item(0).getFirstChild().getFirstChild().getFirstChild().getNodeValue() ;
            Log.d("xxx","path="+ path);
            String [] pairs = path.split(" ");
            String[] lngLat = pairs[0].split(","); // lngLat[0]=longitude lngLat[1]=latitude lngLat[2]=height
            // src
            GeoPoint startGP = new GeoPoint((int)(Double.parseDouble(lngLat[1])*1E6),(int)(Double.parseDouble(lngLat[0])*1E6));

            GeoPoint gp1;
            GeoPoint gp2 = startGP;



            for(int i=1;i<pairs.length;i++) // the last one would be crash
            {
              lngLat = pairs[i].split(",");
              gp1 = gp2;
              // watch out! For GeoPoint, first:latitude, second:longitude
              gp2 = new GeoPoint((int)(Double.parseDouble(lngLat[1])*1E6),(int)(Double.parseDouble(lngLat[0])*1E6));



              mapRouteOverlay = new MapRouteOverlay(gp1,gp2,2,color);

              mMapView01.getOverlays().add(mapRouteOverlay);
              Log.d("xxx","pair:" + pairs[i]);
              Log.e("Check  ","Draw  " + mapRouteOverlay);
            }

          }
        }
        catch (MalformedURLException e)
        {
          e.printStackTrace();
        }
        catch (IOException e)
        {
          e.printStackTrace();
        }
        catch (ParserConfigurationException e)
        {
          e.printStackTrace();
        }
        catch (SAXException e)
        {
          e.printStackTrace();
        }


      }

this method is working fine(from last three months) to draw path but form about 15 days it gives problem and not showing/drawing path.

my logcat output is

 08-11 10:15:47.363: W/System.err(401): org.xml.sax.SAXParseException: unterminated entity ref (position:ENTITY_REF &@1:808 in java.io.InputStreamReader@44f9cde8) 
 08-11 10:15:47.373: W/System.err(401):     at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:153)
 08-11 10:15:47.373: W/System.err(401):     at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:110)
 08-11 10:15:47.373: W/System.err(401):     at com.map.MapMainActivity.DrawPath(MapMainActivity.java:621)
 08-11 10:15:47.373: W/System.err(401):     at com.map.MapMainActivity.getDirection(MapMainActivity.java:582)
 08-11 10:15:47.373: W/System.err(401):     at com.map.MapMainActivity$DownloadWebPageTask.onPostExecute(MapMainActivity.java:1318)
 08-11 10:15:47.373: W/System.err(401):     at com.map.MapMainActivity$DownloadWebPageTask.onPostExecute(MapMainActivity.java:1)
 08-11 10:15:47.373: W/System.err(401):     at android.os.AsyncTask.finish(AsyncTask.java:417)
 08-11 10:15:47.373: W/System.err(401):     at android.os.AsyncTask.access$300(AsyncTask.java:127)
 08-11 10:15:47.373: W/System.err(401):     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
 08-11 10:15:47.373: W/System.err(401):     at android.os.Handler.dispatchMessage(Handler.java:99)
 08-11 10:15:47.373: W/System.err(401):     at android.os.Looper.loop(Looper.java:123)
 08-11 10:15:47.383: W/System.err(401):     at android.app.ActivityThread.main(ActivityThread.java:4627)
 08-11 10:15:47.383: W/System.err(401):     at java.lang.reflect.Method.invokeNative(Native Method)
 08-11 10:15:47.383: W/System.err(401):     at java.lang.reflect.Method.invoke(Method.java:521)
 08-11 10:15:47.383: W/System.err(401):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
 08-11 10:15:47.383: W/System.err(401):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
 08-11 10:15:47.383: W/System.err(401):     at dalvik.system.NativeStart.main(Native Method)

I could not understand what is the problem?
any help?

Thanks in Advance.

  • 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-09T20:14:08+00:00Added an answer on June 9, 2026 at 8:14 pm

    see this link definitely help you.
    because the Google Directions from Google by parsing the KML file is no longer available since 27 July 2012 (because Google has changed the structure of retrieving Google Directions, now you can only get it by JSON or XML), it is time to migrate your code to JSON instead of KML.

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

Sidebar

Related Questions

I'm developing an Android 2.2 application. I'm using this method to draw a text
I'm using this method to install an application, but it doesn't put the applications
I deployed an application using this method and it worked very good. However, there
I'm currently using this method in calling batch files in vb.net: Private Sub Button3_Click(ByVal
I am using this method - (void)keyboardWillShow:(NSNotification *)notification that is triggered when the keyboard
I'm using this code to draw a point on a map: function addPointToMap(pMap){ var
when using this method public List<Field> getFieldWithoutId(List<Integer> idSections) throws Exception { try { Connection
I am using this method on a button click. My app is not yet
I find myself using this method a ton to perform actions based on a
Should I always be using this method when rendering? Does it slow down much

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.