的並沒有出現,而不是指定位置重疊
改變疊加的,並從onCreat()方法來updateOverlays(),我只是想獲得正確的位置地圖代碼,並設置疊加層的正確地圖無法在地圖上顯示我的位置?
public class tabsActivity extends MapActivity
{
private static final String LIST_TAB_TAG = "Notification";
private static final String MAP_TAB_TAG = "Map";
private TabHost tabHost;
private ListView listView;
private MapView mapView;
MyLocationOverlay Compass;
double longitude , latitude;
MapController mc;
GeoPoint point;
protected LocationManager locationManager;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.maps_notification_tabs);
LocationListener listener = new LocationListener()
{
@Override
public void onStatusChanged(String provider, int status, Bundle extras)
{
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider)
{
// TODO Auto-generated method stub
}
@Override
public void onProviderDisabled(String provider)
{
// TODO Auto-generated method stub
}
@Override
public void onLocationChanged(Location location)
{
updateOverlays(location);
}
};
LocationManager locMgr = (LocationManager) getBaseContext().getSystemService(Context.LOCATION_SERVICE);
locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, listener);
// setup map view
mapView = (MapView) findViewById(R.id.mapview);
//Compass Setup
Compass = new MyLocationOverlay(this, mapView);
mapView.getOverlays().add(Compass);
final MapController control = mapView.getController();
}
public void updateOverlays(Location location)
{
mapView.setBuiltInZoomControls(true);
mapView.postInvalidate();
mapView.setSatellite(true);
mc = mapView.getController();
point = new GeoPoint((int) location.getLatitude() , (int) location.getLongitude());
mc.animateTo(point);
mc.setZoom(10);
mapView.invalidate();
OverlayItem overlayitem = new OverlayItem(point, "Hint", "Your Are Here");
List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.black);
MapOverlays itemizedoverlay = new MapOverlays(drawable, this);
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
}
感謝編輯:) @Rahul GARG – Mahmoud 2012-03-04 12:59:25
的問題是如何好是你的GPS定位?你有沒有檢查準確性?多少「顯示錯誤」?錯誤的國家?還是隻有幾百米? – WarrenFaith 2012-03-04 13:01:26
我的gps在谷歌地圖上運行良好,它的錯誤國家 – Mahmoud 2012-03-04 13:25:43