2017-05-09 1 views
1

Google 지역 정보 API를 사용하여 맞춤 장소 선택 도구를 만들려고합니다. Google Place Picker 컨트롤에서지도가 스크롤되면 핀 위치가 변경되고 새 핀 위치에 해당하는 주변 장소가 가져옵니다. iOS/Android Google Places API에서 주변 기기를 현재 위치에서 가져 오는 API 만 볼 수 있습니다.Google Places API를 사용하여지도를 스크롤 할 때 주변 장소를 업데이트하는 방법은 무엇인가요?

위도/경도로 근처 장소를 가져 오는 데 사용할 수있는 Google 지역 정보 웹 서비스 API가 있지만 iOS/Android API를 통해 가능합니까?

iOS/Android Google Places API를 사용하여지도가 스크롤 된 특정 좌표의 주변 장소를 가져올 수있는 방법은 무엇인가요?

답변

-1

사용자 지정 위치를 선택하려면 place picker을 사용해야합니다.

다음 코드는 작업 선택 도구를 실행합니다. 근처 장소

에 대한

int PLACE_PICKER_REQUEST = 1; 
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); 
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST); 
1

사용이 게시물 방법은 미터에 SEARCH TYPE 및 반경을 설정합니다.

String url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json" + "?location=" + location.getLatitude() + "," + location.getLongitude() + "&radius=" + RADIUS_IN_METERS + "&type=" + SEARCH_TYPE + "&key=" + API_KEY; 
Log.d(TAG, url); 
Map<String, String> params = new HashMap<>(); 
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url, new JSONObject(params), 
    new Response.Listener<JSONObject>() {   
    @Override 
    public void onResponse(JSONObject response) { 
    try { 
      locationList = new ArrayList<>(); 
      JSONArray results = response.getJSONArray("results"); 
      for (int i = 0; i < results.length(); i++) { 
        JSONObject geometry = results.getJSONObject(i).getJSONObject("geometry"); 
        String name = results.getJSONObject(i).getString("name"); 
        String address = results.getJSONObject(i).getString("vicinity"); 
        String place_id = results.getJSONObject(i).getString("place_id"); 
        if (geometry != null) { 
          JSONObject location = geometry.getJSONObject("location"); 
          if (location != null) { 
            double latitude = location.getDouble("lat"); 
            double longitude = location.getDouble("lng"); 
            if (latitude != 0.0 && longitude != 0.0) { 
              Location markerLocation = new Location(SEARCH_TYPE); 
              markerLocation.setLatitude(latitude); 
              markerLocation.setLongitude(longitude); 
              Bundle bundle = new Bundle(); 
              bundle.putString("NAME", name); 
              bundle.putString("ADDRESS", address); 
              bundle.putString("PLACE_ID", place_id); 
              bundle.putString("TYPE", SEARCH_TYPE); 
              markerLocation.setExtras(bundle); 
              locationList.add(markerLocation); 
              Log.d(TAG, latitude + " " + longitude); 
             } 
            } 
           } 

          } 
          if (locationList.size() != 0) { 
           addMarkers(SEARCH_TYPE); 
          } 
          //Log.d(TAG,results.toString()); 
         } catch (JSONException e) { 
          e.printStackTrace(); 
         } 
        } 
       }, 
       new Response.ErrorListener() { 
        @Override 
        public void onErrorResponse(VolleyError error) { 

        } 
       } 
     ); 
    requestQueue.add(jsonObjectRequest); 
관련 문제