为什么 osmdroid 不能在离线模式下工作(多个问题)?
Why osmdroid not working in offline mode (multiple questions)?
我正在开发 OSMdroid
库,想把它变成 offline
所以我使用了这个代码
mMapView.setUseDataConnection(false);
但在这种情况下,它甚至不会显示除图表页面以外的地图。但是当我将 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?
至于显示的离线图块,你确定你有离线地图图块 .ZIP-file
存储在 /mnt/sdcard/osmdroid/
中吗(或者无论你设备的 SD 卡的路径是什么,它必须在此文件夹位于名为 osmdroid
)?
的子目录中
可以在这里找到对我有帮助的好教程:http://www.haakseth.com/?p=30
如果没有互联网连接可从中检索图块,OSMdroid TileSource 将自动查找此 .ZIP-file
。在 OpenStreetMapTileProviderConstants class 中有这段代码:
/** Base path for osmdroid files. Zip files are in this folder. */
public static final File OSMDROID_PATH = new File(Environment.getExternalStorageDirectory(),
"osmdroid");
所以如您所见,您只需要在 SD 卡文件夹中有 osmdroid
目录,一切都应该正常。
如果您还没有地图图块 .ZIP
,请查看 Mobile Atlas Creator 以创建它。
我正在开发 OSMdroid
库,想把它变成 offline
所以我使用了这个代码
mMapView.setUseDataConnection(false);
但在这种情况下,它甚至不会显示除图表页面以外的地图。但是当我将 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 givengeopint
i get it somewhere else and everytime i mean whatever the code i change i don't get thepoi
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?
至于显示的离线图块,你确定你有离线地图图块 .ZIP-file
存储在 /mnt/sdcard/osmdroid/
中吗(或者无论你设备的 SD 卡的路径是什么,它必须在此文件夹位于名为 osmdroid
)?
可以在这里找到对我有帮助的好教程:http://www.haakseth.com/?p=30
如果没有互联网连接可从中检索图块,OSMdroid TileSource 将自动查找此 .ZIP-file
。在 OpenStreetMapTileProviderConstants class 中有这段代码:
/** Base path for osmdroid files. Zip files are in this folder. */
public static final File OSMDROID_PATH = new File(Environment.getExternalStorageDirectory(),
"osmdroid");
所以如您所见,您只需要在 SD 卡文件夹中有 osmdroid
目录,一切都应该正常。
如果您还没有地图图块 .ZIP
,请查看 Mobile Atlas Creator 以创建它。