2012-09-23 13 views
0

我在我的應用程序中有以下功能。MyLocatoinOverlay disableMyLocation或使用OverlayItem

  1. 我使用MyLocationOverlay獲取我的當前位置。
  2. 爲了能夠放下自定義標記而不是閃爍的藍色標記,我擴展了MyLocationOverlay。

我需要最後一項要求方面的幫助。我只想讓一個標記保持固定在MyLocationOverlay最初發現的位置,而不是從衛星跳轉到衛星時四處移動。

創建此類用戶體驗有哪些選擇?

回答

0

我建議保存第一個獲取饋送到CustomLocationOverlay中drawMyLocation函數的地址點,並使用它代替饋送給該函數的myLocation。

int intFirstGeoPoint = 0; 
GeoPoint FirstGeoPoint; 

protected void drawMyLocation(Canvas canvas, MapView mapView, Location lastFix, GeoPoint myLocation, long when) { 

     if(intFirstGeoPoint == 0){ 
      FirstGeoPoint=myLocation; 
      intFirstGeoPoint=1; 
     }else{ 
      myLocation=FirstGeoPoint; 
     } 

     // translate the GeoPoint to screen pixels 
     Point screenPts = mapView.getProjection().toPixels(myLocation, null); 
     ... 
     ... 

你也可以抓住這個位置,並創建一個新的DrawableMapOverlay只繪製了這一點,而不是霸王硬上弓LocationOverlay

+0

你應該做的另一個問題。但是,是的。使用相同的FirstGeoPoint,在那一點做一個canvas.drawText(),並加上一些偏移量。如果你提出另一個問題,我會提供更多細節 – greekygyro