1.å¦ä½ä½¿ç¨androidç¾åº¦å°å¾ç¦»çº¿å°å¾
å¦ä½ä½¿ç¨androidç¾åº¦å°å¾ç¦»çº¿å°å¾
1.é¦å æ离线å°å¾æ¾å¨androidå·¥ç¨ä¸çassetséé¢ã
注æï¼å»ºè®®ç¦»çº¿å°å¾ä¸è½½éè¿ç¾åº¦å°å¾APIDEMOå»ä¸è½½ï¼å 为å°å®ç½ä¸ä¸è½½ç离线å°å¾æä»¶æ ¼å¼ä¸ä¸æ ·ï¼APIDEMOçæ ¼å¼æ¯.dat,地地图导航陆股通资金公式源码èå®ç½ä¸çæ ¼å¼æ¯.dat_svcæå¯è½å è½½ä¸äºå°å¾.
2.æ离线å°å¾ä»assetsä¸æ·è´å°sdå¡ä¸
public static void copy(Context context) {
try {
String filepath = Environment.getExternalStorageDirectory() + "/"
+ "BaiduMapSDK" + "/" + "vmp" + "/" + "h" + "/"
+ "xxxxx.dat";
String path = Environment.getExternalStorageDirectory() + "/"
+ "BaiduMapSDK" + "/" + "vmp" + "/" + "h" + "/";
File file = new File(path);
if (!file.exists()) {
file.mkdir();
}
if (!(new File(filepath)).exists()) {
new File(filepath).createNewFile();
InputStream is = context.getAssets().open(
"xxxx.dat");
FileOutputStream fos = new FileOutputStream(filepath);
byte[] buffer = new byte[];
int count = 0;
while ((count = is.read(buffer)) > 0) {
fos.write(buffer, 0, count);
}
fos.close();
is.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
3.åå§å离线å°å¾
private MKOfflineMap mOffline = null;
MapController mMapController;
mMapController = mMapView.getController();
mOffline = new MKOfflineMap();
mOffline.init(mMapController, new MKOfflineMapListener() {
@Override
public void onGetOfflineMapState(int type, int state) {
// TODO Auto-generated method stub
switch (type) {
case MKOfflineMap.TYPE_DOWNLOAD_UPDATE: {
}
break;
case MKOfflineMap.TYPE_NEW_OFFLINE:
break;
case MKOfflineMap.TYPE_VER_UPDATE:
break;
}
}
});