2012-08-08 1 views
1

여기에 질문이 있습니다. 어떻게 고정 점에서 특정 점의 방향을 찾을 수 있습니까? 예를 들어 Google지도의 현재 위치에서 특정 지점의 방향을 알고 싶습니다. 나는 어떻게 이것을 달성 할 수 있는가. 어느 누구도 이것에 관해 나를 인도 할 수 있습니까? 미리 감사 ..다른 고정 소수점에서 한 점의 방향 찾기

답변

0

코드를 시도 ::

//calling method from onCreate() method 

문자열 쌍 [= getDirectionData (sourceLat, sourceLong, destinationLat, destinationLong);

private String[] getDirectionData(String sourceLat, String sourceLong, 
      String destinationLat, String destinationLong) { 

     String urlString = "http://maps.google.com/maps?f=d&hl=en&" + "saddr=" 
       + sourceLat + "," + sourceLong + "&daddr=" + destinationLat 
       + "," + destinationLong + "&ie=UTF8&0&om=0&output=kml"; 
     Log.d("URL", urlString); 
     Document doc = null; 
     HttpURLConnection urlConnection = null; 
     URL url = null; 
     String pathConent = ""; 

     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()); 

     } catch (Exception e) { 
     } 

     NodeList nl = doc.getElementsByTagName("LineString"); 
     for (int s = 0; s < nl.getLength(); s++) { 
      Node rootNode = nl.item(s); 
      NodeList configItems = rootNode.getChildNodes(); 
      for (int x = 0; x < configItems.getLength(); x++) { 
       Node lineStringNode = configItems.item(x); 
       NodeList path = lineStringNode.getChildNodes(); 
       pathConent = path.item(0).getNodeValue(); 
      } 
     } 
     String[] tempContent = pathConent.split(" "); 
     return tempContent; 
    } 
+0

답장을 보내 주셔서 감사합니다. 실제로 필요한 것은 센서를 사용하여 안드로이드 장치 제목 (길 찾기)을 시도한 것입니다. 그렇다면 어떻게 센서를 사용하여 현재 위치에서 점의 방향을 찾을 수 있습니까? 이 또는 어떤 제안을 할 가능성이 있습니까? –

+0

어떤 종류의 센서를 사용하고 싶습니까? –

+0

방향 센서 –