2014-04-22 210 views
0

我有一個包含疊加項目的mapview。這些覆蓋圖可以點擊,然後在mapview中顯示一個片段活動。問題是,當fragmentactivity已被解散,mapview將焦點返回到我的當前位置。我想將焦點重新放在輕拍覆蓋物項目上。如何才能做到這一點?您的答覆將受到高度讚賞。謝謝OverlayItem在FragmentActivity關閉時丟失焦點

這是我有的代碼,但它不工作。

final DefaultItemizedOverlay overlay = new DefaultItemizedOverlay(trafficProfileMarkerOverlay); 

     final OverlayItem overlayItem = new OverlayItem(geopoint, "", "");  
     overlay.addItem(overlayItem); 

     overlay.setTapListener(new ItemizedOverlay.OverlayTapListener() { 
      @Override 
      public void onTap(GeoPoint pt, MapView mapView) { 
       Intent trafficProfileIntent = new Intent(getApplicationContext(), TrafficProfilePopUpActivity.class); 
       startActivity(trafficProfileIntent);overlay.setFocus(overlayItem); 
      } 
     });   
     mapView.getOverlays().add(overlay); 

回答

0

您TrafficProfilePopUpActivity變得開放之前,您可以將您的GeoPoint某些變量。

,當用戶來到映射活動,你可以使用CameraUpdateFactory.newCameraPosition到地圖攝像機移動到存儲在變量您的GeoPoint前的onResume()方法

高興地幫助。

+0

謝謝,它的工作:) –

+0

不客氣。 –

+0

嗨,我剛剛發現,動畫到onResume上覆蓋項目的挖掘地理位置時,mylocationoverlay消失了,您認爲問題是什麼?下面是代碼: 'code' @覆蓋 \t保護無效的onResume(){ \t \t嘗試{ \t \t \t \t \t \t如果(overlayTappedGeopoint!= NULL){ \t \t \t \t的MapView。 。getController()animateTo(overlayTappedGeopoint); } else { myLocationOverlay.enableMyLocation(); myLocationOverlay.setFollowing(true); myLocationOverlay.shouldAnimate(false); myLocationOverlay.setBeaconAnimationOutlinePaint(null); myLocationOverlay.setBeaconAnimationFillPaint(null); } 'code' –