如何缩放openstreet地图?我的下面的代码只有mapview.builinzoom控件(TRUE)
如何在googlemapview中提供我的缩放级别,有一个像
这样的功能MapController mc = mapView.getController();
mc.setZoom(15);
那么如何在openstreet map中添加此类型函数,以便在启动应用程序时它已经缩放并向我显示正确的结果?
import org.osmdroid.DefaultResourceProxyImpl;
import org.osmdroid.ResourceProxy;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
import com.google.android.maps.MapController;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.Drawable;
public class MainActivity extends Activity {
MyItemizedOverlay myItemizedOverlay = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
Drawable marker=getResources().getDrawable(android.R.drawable.star_big_on);
int markerWidth = marker.getIntrinsicWidth();
int markerHeight = marker.getIntrinsicHeight();
marker.setBounds(0, markerHeight, markerWidth, 0);
ResourceProxy resourceProxy = new
DefaultResourceProxyImpl(getApplicationContext());
myItemizedOverlay = new MyItemizedOverlay(marker, resourceProxy);
mapView.getOverlays().add(myItemizedOverlay);
GeoPoint myPoint1 = new GeoPoint(24.893379000000000000, 67.028060900000010000);
myItemizedOverlay.addItem(myPoint1, "myPoint1", "myPoint1");
GeoPoint myPoint2 = new GeoPoint(24.824796300000000000, 67.031565699999990000);
myItemizedOverlay.addItem(myPoint2, "myPoint2", "myPoint2");
}
}
答案 0 :(得分:1)
请参阅API,特别是IMapView和IMapController接口。你应该得到这样的东西:
mapView.getController().setZoom(16);
答案 1 :(得分:1)
U禁用此行并为您的应用程序运行,
mapView.setBuiltInZoomControls(true);
答案 2 :(得分:-1)
不要在xml中创建mapview,在xml中没有为我设置拖动地图和缩放控件。
但是,像这个例子一样以编程方式创建,对我有用。