2012-12-06 2 views
6

InfoWindow 내부에 위치 이미지를 표시하는 InfoWindowAdapter에서 작업하기 시작했습니다. 위치가 많기 때문에 위치 이미지를 휴대 전화에서 사용할 수없고 웹에서 다운로드 할 수도 있습니다. 반환되는 뷰의 스냅 샷이보기에 너무 이후의 변경 사항에 대한 정보 창에서 반영되지 않습니다지도를 촬영 한 후 렌더링됩니다Google Maps InfoWindow가 업데이트되기 전에 계속 표시되는지 확인하는 방법은 무엇입니까?

참고 :

이제지도 API는 다음 상태 지도. 정보 창이 업데이트 된 후 (예 : 이미지가로드 된 후) showInfoWindow()를 호출하면보기가 업데이트됩니다.

나는 이것을 이해하기 때문에 이미지 창이로드되면 showInfoWindow를 업데이트하고 호출하려는 정보창을 만든 마커를 추적해야합니다. ImageDownloadService는 이미지로드가 완료되면 알림을받는 Handler를가집니다.

이미지로드가 약간 더 오래 걸리면 사용자가 다른 InfoWindow를 열거 나 현재 창을 스크롤하여 닫을 수 있습니다. 문제는 뷰를 업데이트하기 위해 마커에서 showInfoWindow를 다시 호출 할 때 InfoWindow가 계속 표시되는지 확신 할 수 없다는 것입니다.

InfoWindow가 계속 표시되는 경우에만 업데이트 할 수 있습니까?

+0

이 문제가 수정 되었습니까? 나는 같은 문제를 겪고있다 !! 어떤 도움을 주셔서 감사합니다! – LilMoke

+0

전문 Android 개발자로서 해결책을 찾았습니까? :) 그것은 당신의 블로그에 있습니까? 거기에서 아무 것도 찾을 수 없기 때문에 : ( – glenneroo

답변

3

마이트 마커의 부울 isInfoWindowShown() 메소드는 찾고 계신 것입니까? 정보창이 떨어져 스크롤 할 때 그것은 그, 나는 생각한다, 당신은 아마 마커의 LatLng를 변환해야하지만, 도움이되지 수

Marker#isInfoWindowShown() - Google Maps Android API v2 documentation

는 화면 좌표 또는 여부를 확인하려면이 옵션을 사용하는 좌표 마커는 화면에 여전히 :

How to get Latitude/Longitude span in Google Map V2 for Android

나는 그것이 윈도우 자체지도보기 경계에 여전히인지 아닌지 확인하기 위해 가능한 모든인지 확실하지 않다.

6

나는 방금 InfoWindow을 다운로드하고 업데이트하는 것과 비슷한 문제를 겪어 왔으며 오늘 아침 벽에 머리를 대고 내 머리를 긁으면 나는이 작은 해결 방법을 제안했다. 이 하나.

AsyncTaskOnPostExecute() 방법에 marker.showInfoWindow()를 호출 한 루프에서 끝나는 결코 제대로 내 변경 내용을 전파하지 된 InfoWindowAdapter 방법을 다시했다.

내가 사용한 솔루션은 현재 선택한 마커와 표시하고자하는 뷰를 저장하는 것이 었습니다. 나는 아래의 예제에서 TextViewDownloadBubbleInfoAsyncTask (내가 믿는 이미지 스레드와 비슷합니다)에서 업데이트되는 위치에 머물렀습니다.

  // Setting a custom info window adapter for the google map 
     gMap.setInfoWindowAdapter(new InfoWindowAdapter() { 

      // Use default InfoWindow frame 
      public View getInfoWindow(Marker arg0) { 
       return null; 
      } 

      // Defines the contents of the InfoWindow 
      public View getInfoContents(Marker arg0) { 
       if (selectedMarker.isInfoWindowShown()) { 
        return infoWindowView; 
       } else { 
        // Getting view from the layout file info_window_layout 
        infoWindowView = getLayoutInflater().inflate(
          R.layout.bubblewindowlayout, null); 
        // Stash the base view in infoWindowView 
        // Getting reference to the TextView to set latitude 
        TextView tvTit = (TextView) infoWindowView 
          .findViewById(R.id.tv_title); 
        tvTit.setText("Fetching data..."); 

        // Async the update so we're not slowed down waiting for 
        // the 
        // bubble to populate 
        new DownloadBubbleInfo(context, infoWindowView, arg0) 
          .execute(arg0.getTitle(), arg0.getSnippet()); 

        // Returning the view containing InfoWindow contents 
        return infoWindowView; 
       } 
      } 
     }); 
     gMap.setOnMarkerClickListener(new OnMarkerClickListener() { 

      public boolean onMarkerClick(Marker marker) { 
       // When a marker is clicked set it as the selected marker so 
       // we can track it for the InfoWindow adapter. This will 
       // make sure that the correct marker is still displayed when 
       // the callback from DownloadBubbleInfo is made to 
       // marker.showInfoWindow() which is needed to update the 
       // InfoWindow view. 
       selectedMarker = marker; 
       infoWindowView = null; 
       return false; 
      } 
     }); 

과의 관련 라인들 DownloadBubbleInfoAsyncTask :

이제
@Override 
protected String[] doInBackground(String... queryparts) { 
    // Do the query and stash the results in queryResults and pass to 
    // onPostExecute to attach to the mainview (the current view from the 
    // main code) and then call showInfoWindow on the marker to re-launch 
    // the InfoWindowAdapter methods again to repopulate the InfoWindow view 
    // and attach it. 
    return queryResults; 
} 
protected void onPostExecute(String[] results) { 
    ((TextView) mainview.findViewById(R.id.tv_title)).setText(results[0]); 
    ((TextView) mainview.findViewById(R.id.tv_info)).setText(results[1]); 

    marker.showInfoWindow(); 
    Log.i("Chris-Debug", "Reshowing InfoWindow"); 
} 

,이 모든 헤이 프레스토 다른 코너를 올바른 마커가 당신의 AsyncTask에서 반환 올바른 정보로 채워되고 있는지 확인해야하고 매우 어색한 Android Maps API 버전 인 GoogleMaps v2가 성공적으로 주최했습니다!

+0

내 하루 사람을 구했다 :) 감사합니다. – MKY

관련 문제