1

エミュレーターでアプリを実行すると、Google Maps API は問題なく動作しますが、ズームインすると、Web バージョンのようにフォーカスやレンダリングが行われません。

何か案は?

ここに私のコード:

@Override
    protected void onCreate(Bundle arg0) {
        // TODO Auto-generated method stub
        super.onCreate(arg0);
        setContentView(R.layout.map);

        Button openDrawer = (Button) findViewById(R.id.openDrawer);
        openDrawer.setOnClickListener(this);

        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);

        List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);
        MapItemizedOverlay itemizedoverlay = new MapItemizedOverlay(drawable, this);

        GeoPoint point = new GeoPoint(19240000,-99120000);
        OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");

        itemizedoverlay.addOverlay(overlayitem);
        mapOverlays.add(itemizedoverlay);
    }
4

2 に答える 2

0

以下のコードを試してみましたか???

MapController controller = mapView.getController();
controller.setZoom(15);
controller.setCenter(point);
于 2012-09-28T13:42:45.293 に答える
0

あなたがする必要があるのは を呼び出すことだけだと思いますmapView.invalidate()。私は自分のマップをあなたのものとは少し違った方法で設定しました。参照用に以下のコードをコピーしました:

LocationManager jLocManager;
MapController mController;
GeoPoint geoP;
MapView mapView;
MyLocationOverlay myLocOverlay;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maps);

    try {
        JJMapsInitialize();
    }catch(Exception e){
        Log.e("JJMapsInitialize", "FAILED: " + e.getMessage());
    }

    myLocOverlay = new MyLocationOverlay(this, mapView);
    myLocOverlay.enableMyLocation();
    mapView.getOverlays().add(myLocOverlay);

}

public void findMyLocation() {
    LocationManager jLocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    // 35000 is 35 seconds to find location && 10 is the minimum distance in meters
    jLocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 10, this.jLocListener);
    jLocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 3000, 10, this.jLocListener);
}

private void JJMapsInitialize() {
    try { 
        mapView = (MapView) findViewById(R.id.mapview);
        mapView.displayZoomControls(true);
        mapView.setBuiltInZoomControls(true);
        mController.animateTo(geoP);
        mController.setZoom(10);
        mapView.invalidate();
    } catch(Exception e) {
        Log.e("JJMapsInitialize", "FAILED: " + e.getMessage());
    }

    try {
        findMyLocation();
    } catch (Exception e) {
        Log.e("findMyLocation", "FAILED: " + e.getMessage());
    }
}

ご覧のとおり、初期化メソッドを呼び出してMapViewwith コントロールを設定し、無効にしてからオーバーレイを追加します。


編集

jLocListeneris just my LocationListener()- 私の名前は「j」で始まるので、通常、命名規則では自分のイニシャルまたは両方のイニシャルを使用します。

public LocationListener jLocListener = new LocationListener() {
        //class findMe implements LocationListener {
        public void onLocationChanged(Location location) {
            try {
                lat = location.getLatitude();
                lon = location.getLongitude();
            } catch (Exception e) {
                Log.e("onLocationChanged", "FAILED: " + e.getMessage());
            }
        }
        public void onProviderDisabled(String provider) {
            Log.i("LocationListener", "onProviderDisabled");
        }
        public void onProviderEnabled(String provider) {
            Log.i("LocationListener", "onProviderEnabled");
        }
        public void onStatusChanged(String provider, int status, Bundle extras) {
            Log.i("LocationListener", "onStatusChanged");
        }

    };
于 2012-09-28T14:21:52.023 に答える