我正在构建一个需要使用OpenStreetMap的应用程序。地图已加载。然而,当我缩小时,我发现有多个地图加载..实际上,似乎有无数的地图......一个地图在中间,一个在上面,一个在下面;其实如果你向下滚动屏幕,你会看到更多...为什么osmdroid加载了很多地图。缩放到错误的地方
是什么原因?对不起,stackoverflow不允许我上传照片。我的代码已附加,你可能想试试..
另一件事是,我发现我的当前位置经纬度和使用位置服务,并将它们存储在一个GeoPoint;然后我将缩放中心设置为该点,但是osm又到了另一个点。很远。
我的代码& XML文件连接下面
public class OsmdActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setTileSource(TileSourceFactory.MAPNIK);
mapView.setBuiltInZoomControls(true);
MapController mapController = mapView.getController();
mapController.setZoom(10);
double lat = 1.29377413882149 * 1000000;
double lon = 103.771969817518 * 1000000;
GeoPoint p = new GeoPoint(lat, lon);
mapController.setCenter(p);
}}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<org.osmdroid.views.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"/>
</LinearLayout>
嗨,感谢您的回复,但我没有使用离线地图。这会导致这个问题吗? – Kelsie
嗨,谢谢,我知道我的问题是什么!我应该删除该源以使用在线地图。但是,对于脱机使用,您的意思是多于一个存档地图? – Kelsie
我不这么认为。也许你的互联网连接很低或类似的东西。或者你可以检查你的SD卡上的osmdroid文件夹,并清除它,如果不是空的。 –