gpt4 book ai didi

java - 为什么 osmdroid 不能在离线模式下工作(多个问题)?

转载 作者:行者123 更新时间:2023-12-01 11:33:05 27 4
gpt4 key购买 nike

我正在开发 OSMdroid 库,并希望使其离线,所以我使用了此代码

 mMapView.setUseDataConnection(false);

但在这种情况下,除了图形页面之外,它甚至不会显示 map 。但是当我将 boolean 更改为 true 时,它再次开始工作。

So how do i make it work completely offline?

我也在尝试获取poi,所以我有以下代码

 geoPoint= new GeoPoint(37.439974,-119.003906);
double north = 84;
double east = -180;
double south = -84;
double west = 180;
boundingBoxE6 = new BoundingBoxE6(north, east, south, west);
mMapView.setScrollableAreaLimit(boundingBoxE6);
mMapView.setMultiTouchControls(true);
Marker marker= new Marker(mMapView,mResourceProxy);
marker.setPosition(geoPoint);
mMapView.getOverlays().add(marker);
poiMarkers = new FolderOverlay(getActivity());
new connection().execute();
mMapView.invalidate();


public class connection extends AsyncTask{

@Override
protected Object doInBackground(Object[] objects) {
NominatimPOIProvider poiProvider = new NominatimPOIProvider();
pois=poiProvider.getPOICloseTo(geoPoint,"atm",50,1000);
return pois;
}

@Override
protected void onPostExecute(Object o) {
super.onPostExecute(o);
mMapView.getOverlays().add(poiMarkers);
Drawable poiIcon = getResources().getDrawable(R.drawable.marker_poi_default);
if (o != null) {
for (POI poi : pois) {
Marker poiMarker = new Marker(mMapView);
poiMarker.setTitle(poi.mType);
poiMarker.setSnippet(poi.mDescription);
poiMarker.setPosition(poi.mLocation);
poiMarker.setIcon(poiIcon);
poiMarkers.add(poiMarker);
}
}else{
Toast.makeText(getActivity(),"null",Toast.LENGTH_SHORT).show();
}
}
}

But instead of getting the poi on the given geopint i get it somewhere else and everytime i mean whatever the code i change i don't get the poi in any other places other than that

http://nominatim.openstreetmap.org/search?format=json&q=[atm]&limit=50&bounded=1&viewbox=-1119.003906,1037.439974,880.996094,-962.560026

Is it possible to access poi in offline mode?

最佳答案

至于显示离线图 block ,您确定您已将离线 map 图 block .ZIP文件存储在/mnt/sdcard/osmdroid/(或任何您设备的 SD 卡的路径是,它只需位于此文件夹中名为 osmdroid 的子目录中)?

可以在这里找到对我有帮助的好教程:http://www.haakseth.com/?p=30

如果没有互联网连接来检索图 block ,OSMdroid TileSource 将自动查找此.ZIP 文件。在 OpenStreetMapTileProviderConstants 类中有这样一段代码:

/** Base path for osmdroid files. Zip files are in this folder. */
public static final File OSMDROID_PATH = new File(Environment.getExternalStorageDirectory(),
"osmdroid");

如您所见,您只需要在 SDcard 文件夹中包含 osmdroid 目录,一切就应该可以正常工作。

如果您还没有 map 图 block .ZIP,请查看 Mobile Atlas Creator用于创建这个。

关于java - 为什么 osmdroid 不能在离线模式下工作(多个问题)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30265308/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com