Issue
I'am trying to draw a route on google's MapView. but my line is not drawed on the streets like this in screenshot

I've used this code:
GeoPoint gp1;
GeoPoint gp2 = null;
StringBuilder sb = new StringBuilder();
sb.append("http://maps.google.com/maps/api/directions/xml").append("?origin=").append(origin)
.append("&destination=").append(destination)
.append("&mode=driving&sensor=true&language=de");
System.out.println(sb.toString());
xmlPaser parser = new xmlPaser();
String xml = parser.getXmlFromUrl(sb.toString());
Document doc = parser.XmlFromString(xml);
System.out.println(doc);
NodeList start = doc.getElementsByTagName("start_location");
NodeList end = doc.getElementsByTagName("end_location");
for (int intLoop = 0 ; intLoop < start.getLength() ; intLoop++){
Element eStart = (Element) start.item(intLoop);
Element eEnd = (Element) end.item(intLoop);
String test = parser.getValue(eStart, "lat");
String test2 = parser.getValue(eStart, "lng");
if (intLoop == 0){
gp1 = new GeoPoint((int) (Double.parseDouble(parser.getValue(eStart, "lat")) * 1E6),(int) (Double.parseDouble(parser.getValue(eStart, "lng")) * 1E6));
}else{
gp1 = gp2;
}
gp2 = new GeoPoint((int) (Double.parseDouble(parser.getValue(eEnd, "lat")) * 1E6),(int) (Double.parseDouble(parser.getValue(eEnd, "lng")) * 1E6));
ViewMap.getMap().getOverlays().add(new DirectionPathOverlay(gp1, gp2));
}
}
how can i draw the line on the street overlay? thank you
Solution
I've solved the problem. I'am posting this answer if someone else have the same problem.
the start- & end_location are just the main points of the route. to draw a detailed view of the route you have to use the from the xml and parse this to geoPoint.
to do this i've used this function: polyline to geoPoints
then you have to pass the geoPoints to your draw method.
greetings.
Answered By - Asui
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.