1

방금 ​​Google API 키를 구입했습니다. Google 지역 정보를 사용하여 정확한 장소를 찾습니다. 가장 중요한 것은 프로그래밍 방식으로 해당 위치를 찾아야한다는 것입니다. 즉, 응용 프로그램을 열면 해당 위치가 텍스트보기에 표시됩니다. 또한 가장 가까운 장소를 찾고 싶습니다. 당신은 구글 코드를 사용할 수 있습니다호 Google 안드로이드에서 장소를 찾기 위해 Google 장소를 사용합니까

+0

당신은 안드로이드에서 프로그램 방식으로 장소를 검색하고 싶다는 뜻. –

+0

** 사용해보기 : ** http://www.androidhive.info/2012/08/android-working-with-google-places-and-maps-tutorial/ –

+0

예. 절대적으로 맞습니다. – user1954492

답변

2

사람이 전체 샘플 코드와 함께 설명시겠습니까 (자바가 아니라 자바 스크립트 코드는) 내가 검색 공항을 가지고 있지만 자신을 검색 할 수 있습니다 여기에 API 광고를

배치 장소와 당신은 여기 getJsonResponse 아이디 당신은 모든 장소에 도착했을 때

String url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query="**Place To Search**"&sensor=true&key=**Your Api Key**"; 
       String res = getJsonRespose(url); 

       if (res != null && !res.equalsIgnoreCase("")) { 
        JSONObject jObject = new JSONObject(res); 
        // if (jObject.getString("status").equalsIgnoreCase("ok")) { 
        JSONArray jArray = jObject.getJSONArray("results"); 

        if (jArray.length() > 0) { 
         for (int i = 0; i < jArray.length(); i++) { 
          AirportListData adata = new AirportListData(); 
          JSONObject geo = jArray.getJSONObject(i); 

          JSONObject jLocation = geo.getJSONObject("geometry"); 
          JSONObject jgetLocation = jLocation 
            .getJSONObject("location"); 

          Address = geo.getString("formatted_address"); 
          name = geo.getString("name"); 
          adata.setAirportName(name); 
          lat = jgetLocation.getDouble("lat"); 
          lng = jgetLocation.getDouble("lng"); 
          adata.setLat(lat); 
          adata.setLng(lng); 
          double dis = getDistance(lat, lng); 
          adata.setAddress(Address); 
          adata.setDistnace(dis/1000); 

          ardata.add(adata); 

          Log.e("address", "Distance" + (dis/1000) + "Address" 
            + Address + "name" + name + "lat" + lat + "lng" 
            + lng); 
         } 

        } 

       } 

당신이 getDistance 메서드를 호출하고 거리를 찾을 수 있습니다 HttpClient를 찾을 때 여기

public static double getDistance(double lat, double lng) { 

     try { 
      float[] result = new float[3]; 
      // Log.e("lat long : ", c.getDouble(1) + " : " + c.getDouble(2) + 
      // " : " + latitude + " : " + longitude); 
      Location.distanceBetween(Constantdata.lat, Constantdata.lon, lat, 
        lng, result); 
      double distance = ((double) result[0]); 
      return distance; 
     } catch (Exception e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
     return 0.0; 

    } 

가까운 곳에 당신이 가지고 있다는 귀하의 현재 위치 및 도착 장소 사이의 계산 후 Constantdata.lat 및 constant.lon 현재 위도와 경도 긴 위도 장소 위도하고 당신이

있어 logitude입니다
+0

xml 및 매니페스트 파일을 게시하시기 바랍니다. – user1954492

+0

이 질문에 내 xml 필요 없음 – bindal

+0

명시 적 허가 – user1954492

관련 문제