我已经按照Hellomap Tutorial进行操作并且工作得很好,但我想要做的是当应用程序启动它以放大我的位置时。
这是我的代码:`
import java.util.List;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
public class MainActivity extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.getController().setZoom(7);
List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);
CustomOverlay itemizedoverlay = new CustomOverlay(drawable, this);
GeoPoint point = new GeoPoint((int)(24.3567 * 1E6), (int)(31.4387 * 1E6));
OverlayItem overlayitem = new OverlayItem(point, "Hello!", "Guess Where I am");
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
有人可以帮忙吗?
答案 0 :(得分:0)
如果您只想设置一个以您所在位置为中心的固定缩放级别,请执行以下操作:
MapController controller = mapView.getController();
controller.setCenter(point);
controller.setZoom(ZOOM_LEVEL); // Some nice constant zoom level.