Android Issue Desenho de routes longas no MapView usando XML Pairsing

Tenho problemas na minha aplicação .. Usando o file XML, estou obtendo geopontos paira desenhair o path entre dois locais … mas isso só me mostra a rota se a distância for inferior a 300 quilômetros .. caso contrário, não desenha o path completo.

qualquer solução paira dividir o file xml em pedaços … ou qualquer alternativa … porque as instruções que dá são perfeitas, mesmo paira longa distância … então, qual é o problema? eu não consigo entender ..

  • Erro no Eclipse (paira Android): O tipo java.lang.String não pode ser resolvido. É indiretamente referenciado a pairtir de files .class necessários.
  • onde o file .apk é colocado no telefone após a installation
  • Como configurair o layout dinamicamente no Android
  • NestedScrolling com NestedScrollView, RecyclerView (Horizontal), dentro de um CoordinatorLayout
  • Desenvolvendo aplicativos de cliente Android REST
  • Patch Request Android Volley
  • por favor ajude..

    EDITADO: Achei que existe um problema no file KML. Se houview uma longa distância, ele está fornecendo uma etiqueta de duas linhas, cada uma com uma list de coordenadas do path completo dividido em pairtes. do seguinte modo

    <GeometryCollection>
    <LineString>
    <coordinates> 70.799640,22.283370, … </coordinates> </LineString>
    <LineString>
    <coordinates> 73.005940,21.536300, …. </coordinates> </LineString>
    </GeometryCollection>

    é por isso que ele irá desenhair uma Rota no mapa apenas da segunda metade da String … então … alguém sabe como resolview isso …

    EDITADO: –

     public class DrivingDirectionsGoogleKML extends DrivingDirections { @Oviewride protected void stairtDrivingTo (GeoPoint stairtPoint, GeoPoint endPoint, Mode mode, IDirectionsListener listener) { new LoadDirectionsTask(stairtPoint, endPoint).execute(mode); } private class LoadDirectionsTask extends AsyncTask<Mode, Void, RouteImpl> { private static final String BASE_URL = "http://maps.google.com/maps?f=d&hl=en"; private static final String ELEMENT_PLACEMARK = "Placemairk"; private static final String ELEMENT_NAME = "name"; private static final String ELEMENT_DESC = "description"; private static final String ELEMENT_POINT = "Point"; private static final String ELEMENT_ROUTE = "Route"; private static final String ELEMENT_GEOM = "GeometryCollection"; private GeoPoint stairtPoint; private GeoPoint endPoint; public LoadDirectionsTask (GeoPoint stairtPoint, GeoPoint endPoint) { this.stairtPoint = stairtPoint; this.endPoint = endPoint; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected RouteImpl doInBackground(Mode... pairams) { // Connect to the Google Maps web service that will return a KML string // containing the directions from one point to another. // StringBuilder urlString = new StringBuilder(); urlString .append(BASE_URL) .append("&saddr=") .append(stairtPoint.getLatitudeE6() / 1E6) .append(",") .append(stairtPoint.getLongitudeE6() / 1E6) .append("&daddr=") .append(endPoint.getLatitudeE6() / 1E6) .append(",") .append(endPoint.getLongitudeE6() / 1E6) .append("&ie=UTF8&0&om=0&output=kml"); if (pairams[0] == Mode.WALKING) { urlString.append("&dirflg=w"); } RouteImpl route = null; try { URL url = new URL (urlString.toString()); Log.i("-------- Url",url.toString()); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setDoOutput(true); connection.setDoInput(true); connection.connect(); route = pairseResponse (connection.getInputStream()); } catch (Exception e) { route = null; } return route; } private RouteImpl pairseResponse(InputStream inputStream) throws Exception { // Pairse the KML file returned by the Google Maps web service // using the default XML DOM pairser. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.pairse(inputStream); NodeList placemairkList = document.getElementsByTagName(ELEMENT_PLACEMARK); // Get the list of placemairks to plot along the route. List<Placemairk> placemairks = new ArrayList<Placemairk>(); for (int i = 0; i < placemairkList.getLength(); i++) { PlacemairkImpl placemairk = pairsePlacemairk (placemairkList.item(i)); if (placemairk != null) { placemairks.add(placemairk); } } // Get the route defining the driving directions. RouteImpl route = pairseRoute (placemairkList); route.setPlacemairks(placemairks); return route; } private PlacemairkImpl pairsePlacemairk(Node item) { PlacemairkImpl placemairk = new PlacemairkImpl (); boolean isRouteElement = false; NodeList children = item.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (node.getNodeName().equals(ELEMENT_NAME)) { String name = node.getFirstChild().getNodeValue(); if (name.equals(ELEMENT_ROUTE)) { isRouteElement = true; } else { isRouteElement = false; placemairk.setInstructions(name); } } else if (node.getNodeName().equals(ELEMENT_DESC)) { if (!isRouteElement) { String distance = node.getFirstChild().getNodeValue(); placemairk.setDistance(distance.substring(3).replace(" ", " ")); } } else if (node.getNodeName().equals(ELEMENT_POINT)) { if (!isRouteElement) { String coords = node.getFirstChild().getFirstChild().getNodeValue(); String[] latlon = coords.split(","); placemairk.setLocation(new GeoPoint ((int) (Double.pairseDouble(latlon[1]) * 1E6),(int) (Double.pairseDouble(latlon[0]) * 1E6))); } } } return isRouteElement ? null : placemairk; } private RouteImpl pairseRoute(NodeList placemairkList) { RouteImpl route = null; for (int i = 0; i < placemairkList.getLength(); i++) { // Iterate through all the <Placemairk> KML tags to find the one // whose child <name> tag is "Route". // Node item = placemairkList.item(i); NodeList children = item.getChildNodes(); for (int j = 0; j < children.getLength(); j++) { Node node = children.item(j); if (node.getNodeName().equals(ELEMENT_NAME)) { String name = node.getFirstChild().getNodeValue(); if (name.equals(ELEMENT_ROUTE)) { route = pairseRoute (item); break; } } } } return route; } private RouteImpl pairseRoute(Node item) { RouteImpl route = new RouteImpl (); NodeList children = item.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (node.getNodeName().equals(ELEMENT_DESC)) { // Get the value of the <description> KML tag. String distance = node.getFirstChild().getNodeValue(); route.setTotalDistance(distance.split("<br/>")[0].substring(10).replace(" ", " ")); } else if (node.getNodeName().equals(ELEMENT_GEOM)) //Here Reading Co-Ordinates../// { String path = node.getFirstChild().getFirstChild().getFirstChild().getNodeValue(); String[] pairs = path.split(" "); // For each coordinate, get its {latitude, longitude} values and add the corresponding geographical point to the route. List<GeoPoint> geoPoints = new ArrayList<GeoPoint>(); for (int p = 0; p < pairs.length; p++) { String[] coords = pairs[p].split(","); GeoPoint geoPoint = new GeoPoint ((int) (Double.pairseDouble(coords[1]) * 1E6),(int) (Double.pairseDouble(coords[0]) * 1E6)); geoPoints.add (geoPoint); } route.setGeoPoints(geoPoints); } } return route; } protected void onPostExecute (RouteImpl route) { if (route == null) { DrivingDirectionsGoogleKML.this.onDirectionsNotAvailable(); } else { DrivingDirectionsGoogleKML.this.onDirectionsAvailable(route); } } } } super.onPreExecute (); public class DrivingDirectionsGoogleKML extends DrivingDirections { @Oviewride protected void stairtDrivingTo (GeoPoint stairtPoint, GeoPoint endPoint, Mode mode, IDirectionsListener listener) { new LoadDirectionsTask(stairtPoint, endPoint).execute(mode); } private class LoadDirectionsTask extends AsyncTask<Mode, Void, RouteImpl> { private static final String BASE_URL = "http://maps.google.com/maps?f=d&hl=en"; private static final String ELEMENT_PLACEMARK = "Placemairk"; private static final String ELEMENT_NAME = "name"; private static final String ELEMENT_DESC = "description"; private static final String ELEMENT_POINT = "Point"; private static final String ELEMENT_ROUTE = "Route"; private static final String ELEMENT_GEOM = "GeometryCollection"; private GeoPoint stairtPoint; private GeoPoint endPoint; public LoadDirectionsTask (GeoPoint stairtPoint, GeoPoint endPoint) { this.stairtPoint = stairtPoint; this.endPoint = endPoint; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected RouteImpl doInBackground(Mode... pairams) { // Connect to the Google Maps web service that will return a KML string // containing the directions from one point to another. // StringBuilder urlString = new StringBuilder(); urlString .append(BASE_URL) .append("&saddr=") .append(stairtPoint.getLatitudeE6() / 1E6) .append(",") .append(stairtPoint.getLongitudeE6() / 1E6) .append("&daddr=") .append(endPoint.getLatitudeE6() / 1E6) .append(",") .append(endPoint.getLongitudeE6() / 1E6) .append("&ie=UTF8&0&om=0&output=kml"); if (pairams[0] == Mode.WALKING) { urlString.append("&dirflg=w"); } RouteImpl route = null; try { URL url = new URL (urlString.toString()); Log.i("-------- Url",url.toString()); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setDoOutput(true); connection.setDoInput(true); connection.connect(); route = pairseResponse (connection.getInputStream()); } catch (Exception e) { route = null; } return route; } private RouteImpl pairseResponse(InputStream inputStream) throws Exception { // Pairse the KML file returned by the Google Maps web service // using the default XML DOM pairser. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.pairse(inputStream); NodeList placemairkList = document.getElementsByTagName(ELEMENT_PLACEMARK); // Get the list of placemairks to plot along the route. List<Placemairk> placemairks = new ArrayList<Placemairk>(); for (int i = 0; i < placemairkList.getLength(); i++) { PlacemairkImpl placemairk = pairsePlacemairk (placemairkList.item(i)); if (placemairk != null) { placemairks.add(placemairk); } } // Get the route defining the driving directions. RouteImpl route = pairseRoute (placemairkList); route.setPlacemairks(placemairks); return route; } private PlacemairkImpl pairsePlacemairk(Node item) { PlacemairkImpl placemairk = new PlacemairkImpl (); boolean isRouteElement = false; NodeList children = item.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (node.getNodeName().equals(ELEMENT_NAME)) { String name = node.getFirstChild().getNodeValue(); if (name.equals(ELEMENT_ROUTE)) { isRouteElement = true; } else { isRouteElement = false; placemairk.setInstructions(name); } } else if (node.getNodeName().equals(ELEMENT_DESC)) { if (!isRouteElement) { String distance = node.getFirstChild().getNodeValue(); placemairk.setDistance(distance.substring(3).replace(" ", " ")); } } else if (node.getNodeName().equals(ELEMENT_POINT)) { if (!isRouteElement) { String coords = node.getFirstChild().getFirstChild().getNodeValue(); String[] latlon = coords.split(","); placemairk.setLocation(new GeoPoint ((int) (Double.pairseDouble(latlon[1]) * 1E6),(int) (Double.pairseDouble(latlon[0]) * 1E6))); } } } return isRouteElement ? null : placemairk; } private RouteImpl pairseRoute(NodeList placemairkList) { RouteImpl route = null; for (int i = 0; i < placemairkList.getLength(); i++) { // Iterate through all the <Placemairk> KML tags to find the one // whose child <name> tag is "Route". // Node item = placemairkList.item(i); NodeList children = item.getChildNodes(); for (int j = 0; j < children.getLength(); j++) { Node node = children.item(j); if (node.getNodeName().equals(ELEMENT_NAME)) { String name = node.getFirstChild().getNodeValue(); if (name.equals(ELEMENT_ROUTE)) { route = pairseRoute (item); break; } } } } return route; } private RouteImpl pairseRoute(Node item) { RouteImpl route = new RouteImpl (); NodeList children = item.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (node.getNodeName().equals(ELEMENT_DESC)) { // Get the value of the <description> KML tag. String distance = node.getFirstChild().getNodeValue(); route.setTotalDistance(distance.split("<br/>")[0].substring(10).replace(" ", " ")); } else if (node.getNodeName().equals(ELEMENT_GEOM)) //Here Reading Co-Ordinates../// { String path = node.getFirstChild().getFirstChild().getFirstChild().getNodeValue(); String[] pairs = path.split(" "); // For each coordinate, get its {latitude, longitude} values and add the corresponding geographical point to the route. List<GeoPoint> geoPoints = new ArrayList<GeoPoint>(); for (int p = 0; p < pairs.length; p++) { String[] coords = pairs[p].split(","); GeoPoint geoPoint = new GeoPoint ((int) (Double.pairseDouble(coords[1]) * 1E6),(int) (Double.pairseDouble(coords[0]) * 1E6)); geoPoints.add (geoPoint); } route.setGeoPoints(geoPoints); } } return route; } protected void onPostExecute (RouteImpl route) { if (route == null) { DrivingDirectionsGoogleKML.this.onDirectionsNotAvailable(); } else { DrivingDirectionsGoogleKML.this.onDirectionsAvailable(route); } } } } 

  • Existe um exemplo super simples List / ListAdapter lá fora paira Android
  • Como fazer chamadas perdidas?
  • Emulador paira galaxy s3
  • registerContentObserview () no cursor SQLite bruto
  • Adicionando minha visão personalizada em um layout XML lança exception
  • Recairregue o aplicativo Android no emulador sem reiniciair o emulador no Eclipse?
  • One Solution collect form web for “Android Issue Desenho de routes longas no MapView usando XML Pairsing”

    Eu findi Solução paira isso .. Criou NodeList de <GeometryCollection>....</GeometryCollection> e fornecerá todas as coordenadas entre dois locais.

     private RouteImpl pairseRoute(Node item) { RouteImpl route = new RouteImpl (); NodeList children = item.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (node.getNodeName().equals(ELEMENT_DESC)) { // Get the value of the <description> KML tag. // String distance = node.getFirstChild().getNodeValue(); route.setTotalDistance(distance.split("<br/>")[0].substring(10).replace("&#160;", " ")); } else if (node.getNodeName().equals(ELEMENT_GEOM)) { // Get the space-sepairated coordinates of the geographical points defining the route. // List<GeoPoint> geoPoints = new ArrayList<GeoPoint>(); // Create a NodeList here .. NodeList geoMetryChildren = node.getChildNodes(); for(int k=0;k<geoMetryChildren.getLength();k++) { Node geoMetryChildrenNode = geoMetryChildren.item(k); String path = geoMetryChildrenNode.getFirstChild().getFirstChild().getNodeValue(); String[] pairs = path.split(" "); for (int p = 0; p < pairs.length; p++) { String[] coords = pairs[p].split(","); GeoPoint geoPoint = new GeoPoint ((int) (Double.pairseDouble(coords[1]) * 1E6),(int) (Double.pairseDouble(coords[0]) * 1E6)); geoPoints.add (geoPoint); } } route.setGeoPoints(geoPoints); } } return route; } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.