1

如何缩放 openstreet 地图?我下面的代码只有一个 mapview.builinzoom 控件(TRUE)

我如何像在 googlemapview 中一样提供我的缩放级别有一个类似的功能

MapController mc = mapView.getController();
mc.setZoom(15);

那么如何在 openstreet 地图中添加这种类型的函数,以便在启动应用程序时它已经缩放并显示正确的结果?

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");


    } 

   }
4

3 回答 3

1

请参阅 API,特别是IMapViewIMapController接口。你应该得到这样的东西:

mapView.getController().setZoom(16);
于 2012-11-29T12:19:33.663 回答
1

你禁用这条线并为你的应用程序运行,

 mapView.setBuiltInZoomControls(true);
于 2012-11-29T12:48:09.817 回答
-1

不要在 xml 中创建你的地图视图,在 xml 中对我来说拖拽地图和缩放控件不起作用。

但是,像这个例子一样以编程方式创建对我有用。

https://code.google.com/p/osmdroid/source/browse/branches/rotation/OpenStreetMapViewer/src/org/osmdroid/MapActivity.java?r=914

于 2013-05-22T14:12:26.223 回答