I am able to parse google map according to location name. Now my problem is
when i enter a wrong location in my editbox and press enter button it
crashes. I want: when no location is found then it will show a message *"No
Location found Enter location correctly*" instead of crash. How can i do
this? My parsing code is here:

*  *         StringBuilder urlString = new StringBuilder();
            urlString.append("http://maps.google.com/maps?q=";);
            urlString.append(enter.getText().toString());//from
            urlString.append(",dhaka");
            urlString.append("&ie=UTF8&0&om=0&output=kml");
            Log.d("xxx","URL="+urlString.toString());
            // get the kml (XML) doc. And parse it to get the
coordinates(direction route).
            Document doc = null;
            HttpURLConnection urlConnection= null;
            URL url = null;
            try
            {
            url = new URL(urlString.toString());
            urlConnection=(HttpURLConnection)url.openConnection();
            urlConnection.setRequestMethod("GET");
            urlConnection.setDoOutput(true);
            urlConnection.setDoInput(true);
            urlConnection.connect();

            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            doc = db.parse(urlConnection.getInputStream());
            if(doc.getElementsByTagName("Point").getLength()>0)
            {
                String path =
doc.getElementsByTagName("Point").item(0).getFirstChild().getFirstChild().getNodeValue()
;
                Log.d("xxx","path="+ path);
                String [] pairs = path.split(" ");
                lngLat = pairs[0].split(",");

            }

            }
            catch (MalformedURLException e)
            {
                      e.printStackTrace();

            }
            catch (IOException e)
            {
            e.printStackTrace();

            catch (ParserConfigurationException e)
            {
               e.printStackTrace();

            }
            catch (SAXException e)
            {
                           e.printStackTrace();
            }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to