2011-01-22 46 views
0

我需要您的快速幫助,以解決以下問題需要關於地圖標記的位置的幫助

在我的android應用程序中,我在特定位置顯示標記。

這裏是我的代碼

double latitude = Double.parseDouble(this.latitude); 
    double longitude = Double.parseDouble(this.longitude); 



    int latitudeE6 = (int) (latitude * 1e6); 
    int longitudeE6 = (int) (longitude * 1e6); 


    Log.i("Latitude","String = "+this.latitude+",Double = "+latitude+", int = "+latitudeE6); 
    Log.i("Longitude","String = "+this.longitude+",Double = "+longitude+", int = "+longitudeE6); 


    GeoPoint point = new GeoPoint(latitudeE6, longitudeE6); 
    Log.i("Point a", ""+point.getLatitudeE6()+","+point.getLongitudeE6()); 
    OverlayItem overlay = new OverlayItem(point, title, detail); 

    Drawable drawable = mapView.getContext().getResources().getDrawable(
      R.drawable.pin); 


    HelloOverlayItem helloOverLay = new HelloOverlayItem(drawable, this); 
    Log.i("Point b", ""+point.getLatitudeE6()+","+point.getLongitudeE6()); 
    helloOverLay.addOverlay(overlay); 

    mapView.getOverlays().add(helloOverLay); 

    MapController controller = mapView.getController(); 

    Log.i("Point c", ""+point.getLatitudeE6()+","+point.getLongitudeE6()); 

    controller.animateTo(point); 
    controller.setCenter(point); 
    controller.setZoom(10); 

我能在「C點」適當的位置整數日誌條目,這是不是0,0(其中一些靠近倫敦),但在地圖上它總是給我0 ,0怎麼可能?如何擺脫這個??

回答

0

我不能說它肯定是一個答案或只是一個工作,直到它造成一些錯誤。但打電話mapView.invalidate()工作。我已經在mapView.getOverlays().add(helloOverLay);之後加上了這一行然後它就起作用了。