问题描述
我想尝试具有OpenStreetMap的集成由osmdroid,但我被困在了一个问题,我不知道什么是失踪。的情况如下:
I wanted to try out having OpenStreetMap integration by osmdroid, but I got stuck at an issue where I have no idea what is missing. The scenario is as follows:
症状:图窗口小部件被显示,但只能用一个空格
这是在我的Activity类:
This is in my Activity class:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapView mapView = new MapView(this, 256);
mapView.setTileSource(TileSourceFactory.MAPNIK);
mapView.setClickable(true);
mapView.setBuiltInZoomControls(true);
setContentView(mapView);
}
(我试过选择各种TileSources看似没有区别)
(I tried selecting various TileSources with seemingly no difference)
我的清单还包括这些权限(如℃的孩子;清单>
,在<使用-SDK>
):
My Manifest also includes these permissions (as a child of <manifest>
, after <uses-sdk>
):
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
...和我的仿真器以其他方式连接到互联网,如。网页浏览器。
...and my emulator is otherwise connected to the internet, eg. web browsers work.
osmdroid和SLF4J是在构建路径。该应用程序编译没有问题,不会产生异常。
osmdroid and slf4j are in the build path. The app compiles without a problem and generates no exceptions.
什么地方出错了?
非常感谢!
解决:这是我的模拟器没有外部存储缓存地图图块引起
推荐答案
我是pretty的新OSMdroid太多,但尝试这样做呢?
I'm pretty new to OSMdroid too but try doing this?
setContentView(R.layout.offline_map_activity);
mapView = (MapView) findViewById(R.id.openmapview);
您还需要有offline_map_activity.xml在RES /布局:
You would also need to have offline_map_activity.xml in your res/layouts:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<org.osmdroid.views.MapView
android:id="@+id/openmapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
希望这对你的作品。至少这个工作对我的codeS:)
Hope this works for you. At least this worked for my codes :)
这篇关于osmdroid显示一个空网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!