腾讯地图图层
Showing
6 changed files
with
282 additions
and
18 deletions
... | @@ -19,6 +19,8 @@ import com.pashanhoo.landsurvey.layers.geoq.GeoQMapLayerTypes; | ... | @@ -19,6 +19,8 @@ import com.pashanhoo.landsurvey.layers.geoq.GeoQMapLayerTypes; |
19 | import com.pashanhoo.landsurvey.layers.geoq.GeoQMapsTiledServiceLayer; | 19 | import com.pashanhoo.landsurvey.layers.geoq.GeoQMapsTiledServiceLayer; |
20 | import com.pashanhoo.landsurvey.layers.google.GoogleMapLayerTypes; | 20 | import com.pashanhoo.landsurvey.layers.google.GoogleMapLayerTypes; |
21 | import com.pashanhoo.landsurvey.layers.google.GoogleMapsTiledServiceLayer; | 21 | import com.pashanhoo.landsurvey.layers.google.GoogleMapsTiledServiceLayer; |
22 | import com.pashanhoo.landsurvey.layers.tencent.TencentMapLayerTypes; | ||
23 | import com.pashanhoo.landsurvey.layers.tencent.TencentMapsTiledServiceLayer; | ||
22 | import com.pashanhoo.landsurvey.utils.AppInfo; | 24 | import com.pashanhoo.landsurvey.utils.AppInfo; |
23 | import com.pashanhoo.landsurvey.utils.GISHelper; | 25 | import com.pashanhoo.landsurvey.utils.GISHelper; |
24 | import com.pashanhoo.landsurvey.utils.JZLocationConverter; | 26 | import com.pashanhoo.landsurvey.utils.JZLocationConverter; |
... | @@ -47,11 +49,11 @@ public class GoogleMapActivity extends AppCompatActivity { | ... | @@ -47,11 +49,11 @@ public class GoogleMapActivity extends AppCompatActivity { |
47 | // GoogleMapsTiledServiceLayer GOOGLE_ANNO_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.IMAGE_ANNO_GOOGLE_MAP); | 49 | // GoogleMapsTiledServiceLayer GOOGLE_ANNO_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.IMAGE_ANNO_GOOGLE_MAP); |
48 | // mapView.addLayer(GOOGLE_ANNO_Layer); | 50 | // mapView.addLayer(GOOGLE_ANNO_Layer); |
49 | // GoogleMapsTiledServiceLayer OSM_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.OSM_Map); | 51 | // GoogleMapsTiledServiceLayer OSM_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.OSM_Map); |
50 | // mapView.addLayer(OSM_Layer); | 52 | // mapView.addLayer(GOOGLE_VECTOR_Layer); |
51 | 53 | ||
52 | //--------------------------------------------------------------------------------------------------------------------- | 54 | //--------------------------------------------------------------------------------------------------------------------- |
53 | // 高德矢量图层(含路网,含注记) | 55 | // 高德矢量图层(含路网,含注记) |
54 | GaodeMapsTiledServiceLayer gaodeMapsTiledServiceLayer = new GaodeMapsTiledServiceLayer(GaodeMapLayerTypes.AMAP_VECTOR); | 56 | // GaodeMapsTiledServiceLayer gaodeMapsTiledServiceLayer = new GaodeMapsTiledServiceLayer(GaodeMapLayerTypes.AMAP_VECTOR); |
55 | // 高德影像图层(不含路网,不含注记) | 57 | // 高德影像图层(不含路网,不含注记) |
56 | // GaodeMapsTiledServiceLayer gaodeMapsTiledServiceLayer = new GaodeMapsTiledServiceLayer(GaodeMapLayerTypes.AMAP_IMAGE); | 58 | // GaodeMapsTiledServiceLayer gaodeMapsTiledServiceLayer = new GaodeMapsTiledServiceLayer(GaodeMapLayerTypes.AMAP_IMAGE); |
57 | // 高德路网图层(含路网,含注记) | 59 | // 高德路网图层(含路网,含注记) |
... | @@ -61,8 +63,8 @@ public class GoogleMapActivity extends AppCompatActivity { | ... | @@ -61,8 +63,8 @@ public class GoogleMapActivity extends AppCompatActivity { |
61 | // mapView.addLayer(gaodeMapsTiledServiceLayer); | 63 | // mapView.addLayer(gaodeMapsTiledServiceLayer); |
62 | //--------------------------------------------------------------------------------------------------------------------- | 64 | //--------------------------------------------------------------------------------------------------------------------- |
63 | 65 | ||
64 | BaiduMapsTiledServiceLayer baiduMapsTiledServiceLayer = new BaiduMapsTiledServiceLayer(BaiduMapLayerTypes.BAIDU_TRAFFIC); | 66 | TencentMapsTiledServiceLayer tencentMapsTiledServiceLayer = new TencentMapsTiledServiceLayer(TencentMapLayerTypes.TENCENT_MAP_VECTOR); |
65 | mapView.addLayer(baiduMapsTiledServiceLayer); | 67 | mapView.addLayer(tencentMapsTiledServiceLayer); |
66 | 68 | ||
67 | //--------------------------------------------------------------------------------------------------------------------- | 69 | //--------------------------------------------------------------------------------------------------------------------- |
68 | // GeoQMapsTiledServiceLayer geoQMapsTiledServiceLayer = new GeoQMapsTiledServiceLayer(GeoQMapLayerTypes.ChinaOnlineCommunity_Mobile); | 70 | // GeoQMapsTiledServiceLayer geoQMapsTiledServiceLayer = new GeoQMapsTiledServiceLayer(GeoQMapLayerTypes.ChinaOnlineCommunity_Mobile); | ... | ... |
... | @@ -133,29 +133,29 @@ public class BaiduMapsTiledServiceLayer extends TiledServiceLayer { | ... | @@ -133,29 +133,29 @@ public class BaiduMapsTiledServiceLayer extends TiledServiceLayer { |
133 | @SuppressLint("DefaultLocale") | 133 | @SuppressLint("DefaultLocale") |
134 | protected byte[] getTile(int level, int col, int row) throws Exception { | 134 | protected byte[] getTile(int level, int col, int row) throws Exception { |
135 | byte[] result = null; | 135 | byte[] result = null; |
136 | 136 | Log.i("baidu", level + "/"+col+"/"+row); | |
137 | String url = ""; | 137 | String url = ""; |
138 | String s = "Galil"; | 138 | String s = "Galil"; |
139 | int offsetV = (int) (Math.pow(2, level - 1)); | ||
139 | switch (baiduMapLayerTypes) { | 140 | switch (baiduMapLayerTypes) { |
140 | case BAIDU_VECTOR: | 141 | case BAIDU_VECTOR: |
141 | int offsetV = (int) (Math.pow(2, level - 1)); | ||
142 | url= "http://online" + ((col + row) % 8 + 1) + ".map.bdimg.com/onlinelabel/?qt=tile" | 142 | url= "http://online" + ((col + row) % 8 + 1) + ".map.bdimg.com/onlinelabel/?qt=tile" |
143 | + "&x=" + (col - offsetV) + "&y=" + (offsetV - row - 1) + "&z=" + level | 143 | + "&x=" + (col - offsetV) + "&y=" + (offsetV - row - 1) + "&z=" + level |
144 | + "&styles=sl"; | 144 | + "&styles=pl"; |
145 | break; | 145 | break; |
146 | case BAIDU_IMAGE: | 146 | case BAIDU_IMAGE: |
147 | int offsetI = (int) (Math.pow(2, level - 1)); | ||
148 | url= "http://online" + ((col + row) % 8 + 1) + ".map.bdimg.com/onlinelabel/?qt=tile" | 147 | url= "http://online" + ((col + row) % 8 + 1) + ".map.bdimg.com/onlinelabel/?qt=tile" |
149 | + "&x=" + (col - offsetI) + "&y=" + (offsetI - row - 1) + "&z=" + level | 148 | + "&x=" + (col - offsetV) + "&y=" + (offsetV - row - 1) + "&z=" + level |
150 | + "&styles=pl"; | 149 | + "&styles=sl"; |
151 | break; | 150 | break; |
152 | case BAIDU_ROAD: | 151 | case BAIDU_ROAD: |
153 | url = "http://webst02.is.autonavi.com/appmaptile?style=8&x=" + col + "&y=" + row + "&z=" + level; | 152 | url = "http://shangetu" + ((col + row) % 8 + 1) + ".map.bdimg.com/it/u=" |
153 | + "x=" + (col - offsetV) + ";y=" + (offsetV - row - 1) + ";z=" + level | ||
154 | + ";v=009;type=sate&fm=46"; | ||
154 | break; | 155 | break; |
155 | case BAIDU_TRAFFIC: | 156 | case BAIDU_TRAFFIC: |
156 | int offsetT = (int) (Math.pow(2, level - 1)); | ||
157 | url = "http://its.map.baidu.com:8002/traffic/TrafficTileService?" | 157 | url = "http://its.map.baidu.com:8002/traffic/TrafficTileService?" |
158 | + "level=" + level + "&x=" + (col - offsetT) + "&y=" + (offsetT - row - 1) | 158 | + "level=" + level + "&x=" + (col - offsetV) + "&y=" + (offsetV - row - 1) |
159 | + "&time=" + System.currentTimeMillis(); | 159 | + "&time=" + System.currentTimeMillis(); |
160 | break; | 160 | break; |
161 | } | 161 | } | ... | ... |
... | @@ -138,11 +138,11 @@ public class GaodeMapsTiledServiceLayer extends TiledServiceLayer { | ... | @@ -138,11 +138,11 @@ public class GaodeMapsTiledServiceLayer extends TiledServiceLayer { |
138 | String s = "Galil"; | 138 | String s = "Galil"; |
139 | switch (gaodeMapLayerTypes) { | 139 | switch (gaodeMapLayerTypes) { |
140 | case AMAP_VECTOR: | 140 | case AMAP_VECTOR: |
141 | url= "http://webrd01.is.autonavi.com/appmaptile?&x=" + col + "&y=" + row + "&z=" + level + | 141 | url = "http://webrd01.is.autonavi.com/appmaptile?&x=" + col + "&y=" + row + "&z=" + level + |
142 | "&lang=zh_cn&size=1&scale=1&style=7"; | 142 | "&lang=zh_cn&size=1&scale=1&style=7"; |
143 | break; | 143 | break; |
144 | case AMAP_IMAGE: | 144 | case AMAP_IMAGE: |
145 | url = "http://webst02.is.autonavi.com/appmaptile?style=6&x="+col+"&y="+row+"&z="+level; | 145 | url = "http://webst02.is.autonavi.com/appmaptile?style=6&x=" + col + "&y=" + row + "&z=" + level; |
146 | break; | 146 | break; |
147 | case AMAP_ROAD: | 147 | case AMAP_ROAD: |
148 | url = "http://webst02.is.autonavi.com/appmaptile?style=8&x=" + col + "&y=" + row + "&z=" + level; | 148 | url = "http://webst02.is.autonavi.com/appmaptile?style=8&x=" + col + "&y=" + row + "&z=" + level; | ... | ... |
... | @@ -130,7 +130,6 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer { | ... | @@ -130,7 +130,6 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer { |
130 | @SuppressLint("DefaultLocale") | 130 | @SuppressLint("DefaultLocale") |
131 | protected byte[] getTile(int level, int col, int row) throws Exception { | 131 | protected byte[] getTile(int level, int col, int row) throws Exception { |
132 | byte[] result = null; | 132 | byte[] result = null; |
133 | |||
134 | String url = ""; | 133 | String url = ""; |
135 | String s = "Galil"; | 134 | String s = "Galil"; |
136 | switch (googleMapLayerType) { | 135 | switch (googleMapLayerType) { |
... | @@ -145,13 +144,11 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer { | ... | @@ -145,13 +144,11 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer { |
145 | break; | 144 | break; |
146 | case IMAGE_ANNO_GOOGLE_MAP: | 145 | case IMAGE_ANNO_GOOGLE_MAP: |
147 | url = "http://mt" + (col % 4) + ".google.cn/vt/lyrs=s@131,h@209000000&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&" + "s=" + s; | 146 | url = "http://mt" + (col % 4) + ".google.cn/vt/lyrs=s@131,h@209000000&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&" + "s=" + s; |
148 | // url = "http://webst02.is.autonavi.com/appmaptile?style=8&x=" + col + "&y=" + row + "&z=" + level; | ||
149 | break; | 147 | break; |
150 | case OSM_Map: | 148 | case OSM_Map: |
151 | url = "https://c.tile.openstreetmap.org/"+ level +"/"+ col +"/"+ row +".png"; | 149 | url = "https://c.tile.openstreetmap.org/"+ level +"/"+ col +"/"+ row +".png"; |
152 | break; | 150 | break; |
153 | } | 151 | } |
154 | |||
155 | try { | 152 | try { |
156 | // 首先从离线数据库中读取 | 153 | // 首先从离线数据库中读取 |
157 | result = getOfflineCacheDB(level, col, row); | 154 | result = getOfflineCacheDB(level, col, row); | ... | ... |
1 | package com.pashanhoo.landsurvey.layers.tencent; | ||
2 | |||
3 | import com.pashanhoo.landsurvey.layers.BaseTiledMapServiceType; | ||
4 | |||
5 | public enum TencentMapLayerTypes implements BaseTiledMapServiceType { | ||
6 | /** | ||
7 | * 百度矢量图层(含路网,含注记) | ||
8 | */ | ||
9 | TENCENT_MAP_VECTOR, | ||
10 | |||
11 | TENCENT_MAP_VECTOR_NIGHT, | ||
12 | /** | ||
13 | * 百度影像图层(不含路网,不含注记) | ||
14 | */ | ||
15 | TENCENT_MAP_IMAGE, | ||
16 | /** | ||
17 | * 百度路网图层(含路网,含注记) | ||
18 | */ | ||
19 | TENCENT_MAP_ROAD, | ||
20 | /** | ||
21 | * 百度实时交通图层 | ||
22 | */ | ||
23 | TENCENT_MAP_TERRAIN; | ||
24 | |||
25 | @Override | ||
26 | public String getName() | ||
27 | { | ||
28 | return this.name().toString(); | ||
29 | } | ||
30 | } |
app/src/main/java/com/pashanhoo/landsurvey/layers/tencent/TencentMapsTiledServiceLayer.java
0 → 100644
1 | package com.pashanhoo.landsurvey.layers.tencent; | ||
2 | |||
3 | import android.annotation.SuppressLint; | ||
4 | import android.content.ContentValues; | ||
5 | import android.database.Cursor; | ||
6 | import android.util.Log; | ||
7 | |||
8 | import com.esri.android.map.TiledServiceLayer; | ||
9 | import com.esri.android.map.event.OnStatusChangedListener; | ||
10 | import com.esri.core.geometry.Envelope; | ||
11 | import com.esri.core.geometry.Point; | ||
12 | import com.esri.core.geometry.SpatialReference; | ||
13 | import com.esri.core.internal.io.handler.ResponseListener; | ||
14 | import com.esri.core.internal.io.handler.a; | ||
15 | import com.esri.core.io.UserCredentials; | ||
16 | import com.pashanhoo.landsurvey.utils.AppInfo; | ||
17 | import com.pashanhoo.landsurvey.utils.GADBHelper; | ||
18 | |||
19 | import java.util.concurrent.RejectedExecutionException; | ||
20 | |||
21 | /** | ||
22 | * Created by jiangbotao on 2018/3/28. | ||
23 | */ | ||
24 | |||
25 | public class TencentMapsTiledServiceLayer extends TiledServiceLayer { | ||
26 | private static final double xmin = -22041257.773878; | ||
27 | private static final double ymin = -32673939.6727517; | ||
28 | private static final double xmax = 22041257.773878; | ||
29 | private static final double ymax = 20851350.0432886; | ||
30 | |||
31 | private static final double XMin = 110.35992000000005; | ||
32 | private static final double YMin = 31.382360000000062; | ||
33 | private static final double XMax = 116.65036000000009; | ||
34 | private static final double YMax = 36.36647000000005; | ||
35 | |||
36 | private static final double[] res = {156543.03392800014, | ||
37 | 78271.516963999937, | ||
38 | 39135.758482000092, | ||
39 | 19567.879240999919, | ||
40 | 9783.9396204999593, | ||
41 | 4891.9698102499797, | ||
42 | 2445.9849051249898, | ||
43 | 1222.9924525624949, | ||
44 | 611.49622628138, | ||
45 | 305.748113140558, | ||
46 | 152.874056570411, | ||
47 | 76.4370282850732, | ||
48 | 38.2185141425366, | ||
49 | 19.1092570712683, | ||
50 | 9.55462853563415, | ||
51 | 4.7773142679493699, | ||
52 | 2.3886571339746849, | ||
53 | 1.1943285668550503, | ||
54 | 0.59716428355981721, | ||
55 | 0.29858214164761665}; | ||
56 | |||
57 | private static final double[] scale = {591657527.591555, | ||
58 | 295828763.79577702, | ||
59 | 147914381.89788899, | ||
60 | 73957190.948944002, | ||
61 | 36978595.474472001, | ||
62 | 18489297.737236001, | ||
63 | 9244648.8686180003, | ||
64 | 4622324.4343090001, | ||
65 | 2311162.217155, | ||
66 | 1155581.108577, | ||
67 | 577790.554289, | ||
68 | 288895.277144, | ||
69 | 144447.638572, | ||
70 | 72223.819286, 6111.909643, | ||
71 | 18055.954822, | ||
72 | 9027.9774109999998, | ||
73 | 4513.9887049999998 | ||
74 | , 2256.994353, | ||
75 | 1128.4971760000001}; | ||
76 | |||
77 | private static String URL = "http://maps.iwxlh.com"; | ||
78 | private ResponseListener responseListener; | ||
79 | private static Point origin = new Point(-20037508.342787, 20037508.342787); | ||
80 | |||
81 | private TencentMapLayerTypes tencentMapLayerTypes; | ||
82 | |||
83 | public TencentMapsTiledServiceLayer(TencentMapLayerTypes layerType) { | ||
84 | this(true); | ||
85 | this.tencentMapLayerTypes = layerType; | ||
86 | // 新建数据表,主要在Activity中必须有AppInfo.Settings()初始数据库 | ||
87 | GADBHelper.createTable(AppInfo.mapcachedb, this.tencentMapLayerTypes.getName()); | ||
88 | } | ||
89 | |||
90 | public TencentMapsTiledServiceLayer(boolean initLayer) { | ||
91 | super(URL); | ||
92 | this.isBingMap = true; | ||
93 | |||
94 | if (!(initLayer)) | ||
95 | return; | ||
96 | try { | ||
97 | getServiceExecutor().submit(new Runnable() { | ||
98 | public void run() { | ||
99 | TencentMapsTiledServiceLayer.this.initLayer(); | ||
100 | } | ||
101 | }); | ||
102 | } catch (RejectedExecutionException localRejectedExecutionException) { | ||
103 | Log.e("ArcGIS", "initialization of the layer failed.", localRejectedExecutionException); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | public static double[] getRes() { | ||
108 | return res; | ||
109 | } | ||
110 | |||
111 | protected void initLayer() { | ||
112 | if (getID() == 0L) { | ||
113 | this.nativeHandle = create(); | ||
114 | } | ||
115 | if (getID() == 0L) { | ||
116 | this.changeStatus(OnStatusChangedListener.STATUS.fromInt(-1000)); | ||
117 | } else { | ||
118 | try { | ||
119 | this.setDefaultSpatialReference(SpatialReference.create(102100)); | ||
120 | this.setFullExtent(new Envelope(xmin, ymin, xmax, ymax)); | ||
121 | this.setTileInfo(new TileInfo(origin, scale, res, scale.length, 96, 256, 256)); | ||
122 | super.initLayer(); | ||
123 | } catch (Exception localException) { | ||
124 | this.changeStatus(OnStatusChangedListener.STATUS.fromInt(-1005)); | ||
125 | Log.e("ArcGIS", "Bing map url =" + getUrl(), localException); | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | |||
130 | @SuppressLint("DefaultLocale") | ||
131 | protected byte[] getTile(int level, int col, int row) throws Exception { | ||
132 | byte[] result = null; | ||
133 | String url = ""; | ||
134 | String s = "Galil"; | ||
135 | row = (int) Math.pow(2, level) - 1 - row; | ||
136 | switch (tencentMapLayerTypes) { | ||
137 | case TENCENT_MAP_VECTOR: | ||
138 | url = "http://rt" + (col % 4) + ".map.gtimg.com/tile?" | ||
139 | + "z=" + level + "&x=" + col + "&y=" + row | ||
140 | + "&type=vector&styleid=0"; | ||
141 | break; | ||
142 | case TENCENT_MAP_IMAGE: | ||
143 | url = "http://p" + (col % 4) + ".map.gtimg.com/sateTiles/" + level + "/" + (int) Math.floor(col / 16) + "/" + (int) Math.floor(row / 16) | ||
144 | + "/" + col + "_" + row + ".jpg"; | ||
145 | break; | ||
146 | case TENCENT_MAP_ROAD: | ||
147 | url = "http://rt" + (col % 4) + ".map.gtimg.com/tile?" | ||
148 | + "z=" + level + "&x=" + col + "&y=" + row | ||
149 | + "&type=vector&styleid=3"; | ||
150 | break; | ||
151 | case TENCENT_MAP_TERRAIN: | ||
152 | url = "http://p" + (col % 4) + ".map.gtimg.com/demTiles/" + level + "/" + (int) Math.floor(col / 16) + "/" + (int) Math.floor(row / 16) | ||
153 | + "/" + col + "_" + row + ".jpg"; | ||
154 | break; | ||
155 | case TENCENT_MAP_VECTOR_NIGHT: | ||
156 | url = "http://rt" + (col % 4) + ".map.gtimg.com/tile?" | ||
157 | + "z=" + level + "&x=" + col + "&y=" + row | ||
158 | + "&type=vector&styleid=4"; | ||
159 | break; | ||
160 | } | ||
161 | try { | ||
162 | // 首先从离线数据库中读取 | ||
163 | result = getOfflineCacheDB(level, col, row); | ||
164 | // 如果没有就直接从web上读取 | ||
165 | if (result == null) { | ||
166 | result = a.a(url, null, null, this.responseListener); | ||
167 | // 将读取的数据存入mbtiles中 | ||
168 | AddOfflineCacheDB(level, col, row, result); | ||
169 | } | ||
170 | } catch (Exception ex) { | ||
171 | ex.printStackTrace(); | ||
172 | } | ||
173 | |||
174 | return result; | ||
175 | } | ||
176 | |||
177 | public void refresh() { | ||
178 | try { | ||
179 | getServiceExecutor().submit(new Runnable() { | ||
180 | public void run() { | ||
181 | if (!(TencentMapsTiledServiceLayer.this.isInitialized())) | ||
182 | return; | ||
183 | try { | ||
184 | TencentMapsTiledServiceLayer.this.clearTiles(); | ||
185 | } catch (Exception localException) { | ||
186 | Log.e("ArcGIS", "Re-initialization of the layer failed.", localException); | ||
187 | } | ||
188 | } | ||
189 | }); | ||
190 | } catch (RejectedExecutionException localRejectedExecutionException) { | ||
191 | return; | ||
192 | } | ||
193 | } | ||
194 | |||
195 | public void reinitializeLayer(UserCredentials usercredentials) { | ||
196 | } | ||
197 | |||
198 | public void reinitializeLayer(String appID) { | ||
199 | super.reinitializeLayer(null); | ||
200 | } | ||
201 | |||
202 | private byte[] getOfflineCacheDB(int level, int col, int row) throws Exception { | ||
203 | |||
204 | byte[] result = null; | ||
205 | String sql = "select * from " + this.tencentMapLayerTypes.getName() + " where TILELEVEL = " + level + " and TILECOL = " + col + " and TILEROW = " + row; | ||
206 | Cursor mCursor = AppInfo.mapcachedb.rawQuery(sql, null); | ||
207 | boolean hasData = false; | ||
208 | |||
209 | while (mCursor.moveToNext()) {//判断是否存在数据 | ||
210 | hasData = true; | ||
211 | } | ||
212 | if (hasData) {//数据库中有数据 | ||
213 | try { | ||
214 | if (mCursor.moveToFirst()) { | ||
215 | result = mCursor.getBlob(mCursor.getColumnIndex("TILEDATA")); | ||
216 | } | ||
217 | mCursor.close(); | ||
218 | } catch (Exception e) { | ||
219 | e.printStackTrace(); | ||
220 | result = null; | ||
221 | } | ||
222 | } | ||
223 | return result; | ||
224 | } | ||
225 | |||
226 | private void AddOfflineCacheDB(int level, int col, int row, byte[] bytes) { | ||
227 | ContentValues values = new ContentValues(); | ||
228 | values.put("TILELEVEL", level); | ||
229 | values.put("TILECOL", col); | ||
230 | values.put("TILEROW", row); | ||
231 | values.put("TILEDATA", bytes); | ||
232 | |||
233 | AppInfo.mapcachedb.insert(this.tencentMapLayerTypes.getName(), null, values); | ||
234 | } | ||
235 | } |
-
Please register or sign in to post a comment