我正在尝试在android.support.v4.app.Fragment中使用OSMdroid的离线模式。 我的瓷砖由MOBAC使用" OSMdroid Zip"在地球的坐标0,0周围格式化(它只是海洋,但我只想要一些东西作为开头出现)。
我的zip文件位于/sdcard/osmdroid/MapquestOSM.zip,并包含文件夹MapQuest,其中包含自己在子文件夹中以数字作为名称的所有图块,从缩放11到缩放16.图块是png文件和有扩展" .png"。请注意,/ sdcard // osmdroid文件夹仅包含我的zip文件。
我的问题是我只看到一张空白地图,这是一个空的灰色网格。
public class ContactMapFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
return inflater.inflate(R.layout.map_fragment, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState){
super.onActivityCreated(savedInstanceState);
MapView map = (MapView) getActivity().findViewById(R.id.mapview);
map.setBuiltInZoomControls(true);
map.getController().setZoom(11);
map.getController().setCenter(new GeoPoint(0,0));
map.setClickable(true);
map.setUseDataConnection(false);
map.setMaxZoomLevel(16);
map.setMinZoomLevel(11);
map.setTileSource(new XYTileSource("MapQuest",
ResourceProxy.string.offline_mode, 11, 16, 256, ".jpg", new String[] {
"http://otile1.mqcdn.com/tiles/1.0.0/map/",
"http://otile2.mqcdn.com/tiles/1.0.0/map/",
"http://otile3.mqcdn.com/tiles/1.0.0/map/",
"http://otile4.mqcdn.com/tiles/1.0.0/map/"}));
}
}
使用osmdroid-android-4.2和slf4j-api-1.7.10 权限是:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE"/>
所以我有两个问题:为什么没有显示? XYTileSource中应该指向的URL是什么(我在教程中找到了这些URL)?
答案 0 :(得分:1)
这是我最终使用的解决方案,它正在运行。如果我记得很清楚,你不必关心zip文件名,虽然我不确定它是真的。
pwd='/Users/pallavi/Documents/containers/platform241/etisalatwallet/api-server-tomcat-7/bin'
pwdlog='/Users/pallavi/Documents/containers/platform241/etisalatwallet/api-server-tomcat-7/logs'
pwd1='/Users/pallavi/Documents/containers/platform241/etisalatwallet/core-server-jboss-7.2/bin'
logpwd1='/Users/pallavi/Documents/containers/platform241/etisalatwallet/core-server-jboss-7.2/standalone/log'
osascript -e "tell application \"Terminal\"" \
-e "tell application \"System Events\" to keystroke \"t\" using {command down}" \
-e "do script \"cd $pwd\" in front window" \
-e "do script \"./startup.sh\" in front window" \
-e "tell application \"System Events\" to keystroke \"t\" using {command down}" \
-e "do script \"cd $pwdlog\" in front window" \
-e "do script \"tail -f catalina.out \" in front window" \
-e "tell application \"System Events\" to keystroke \"t\" using {command down}" \
-e "do script \"cd $pwd1\" in front window" \
-e "do script \"./standalone.sh\" in front window" \
-e "tell application \"System Events\" to keystroke \"t\" using {command down}" \
-e "do script \"cd $logpwd1\" in front window" \
-e "do script \"tail -f core.log \" in front window" \
-e "end tell"
> /dev/null
zip文件中包含以.png格式存储的磁贴。
希望它会有所帮助。