1

I have an application that gets the current position and the user selects a destination, these two starting locations, it queries Google: https://developers.google.com/maps/documentation/directions/

And get an xml with the places where I "turn" to reach the destination

After I read the xml, and trace a path between first and second point of the xml, and so on

Before the change of API, the path was perfect in the streets, but now appears like this image:

image

The code I use to draw:

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

    Projection proj = mapView.getProjection();

    Point ponto1, ponto2;
    Path caminho = new Path();
    for (int i = 0; i < geoPoints.size() - 1; i++) {
        ponto1 = proj.toPixels(geoPoints.get(i), null);
        ponto2 = proj.toPixels(geoPoints.get(i + 1), null);

        caminho.moveTo(ponto2.x, ponto2.y);
        caminho.lineTo(ponto1.x,ponto1.y);

        canvas.drawPath(caminho, paint);
    }
}
Hesham Saeed
  • 5,358
  • 7
  • 37
  • 57

1 Answers1

1

This might help you, I wrote an extensive answer for someone who had the same issue as you. Check it out, hope it would help you too

https://stackoverflow.com/a/11357351/975959

Community
  • 1
  • 1
La bla bla
  • 8,558
  • 13
  • 60
  • 109
  • Thanks, that's exactly what I looked for one month, and the problem I think was also what you said about the decode. Now I'll just try to change the mode for the XML I use. Thank you – user1620318 Sep 01 '12 at 01:13