update 3.28
Showing
8 changed files
with
523 additions
and
11 deletions
... | @@ -17,11 +17,7 @@ | ... | @@ -17,11 +17,7 @@ |
17 | android:supportsRtl="true" | 17 | android:supportsRtl="true" |
18 | android:theme="@style/AppTheme"> | 18 | android:theme="@style/AppTheme"> |
19 | <activity android:name=".BootActivity"> | 19 | <activity android:name=".BootActivity"> |
20 | <intent-filter> | ||
21 | <action android:name="android.intent.action.MAIN" /> | ||
22 | 20 | ||
23 | <category android:name="android.intent.category.LAUNCHER" /> | ||
24 | </intent-filter> | ||
25 | </activity> | 21 | </activity> |
26 | <activity | 22 | <activity |
27 | android:name=".MainActivity" | 23 | android:name=".MainActivity" |
... | @@ -30,7 +26,11 @@ | ... | @@ -30,7 +26,11 @@ |
30 | android:theme="@style/AppTheme.NoActionBar"> <!-- 禁止屏幕旋转 --> | 26 | android:theme="@style/AppTheme.NoActionBar"> <!-- 禁止屏幕旋转 --> |
31 | </activity> | 27 | </activity> |
32 | <activity android:name=".GoogleMapActivity"> | 28 | <activity android:name=".GoogleMapActivity"> |
29 | <intent-filter> | ||
30 | <action android:name="android.intent.action.MAIN" /> | ||
33 | 31 | ||
32 | <category android:name="android.intent.category.LAUNCHER" /> | ||
33 | </intent-filter> | ||
34 | </activity> | 34 | </activity> |
35 | </application> | 35 | </application> |
36 | 36 | ... | ... |
... | @@ -11,6 +11,10 @@ import com.esri.android.map.LocationDisplayManager; | ... | @@ -11,6 +11,10 @@ import com.esri.android.map.LocationDisplayManager; |
11 | import com.esri.android.map.MapView; | 11 | import com.esri.android.map.MapView; |
12 | import com.esri.android.runtime.ArcGISRuntime; | 12 | import com.esri.android.runtime.ArcGISRuntime; |
13 | import com.esri.core.geometry.Point; | 13 | import com.esri.core.geometry.Point; |
14 | import com.pashanhoo.landsurvey.layers.Geoq.GeoQMapLayerTypes; | ||
15 | import com.pashanhoo.landsurvey.layers.Geoq.GeoQMapsTiledServiceLayer; | ||
16 | import com.pashanhoo.landsurvey.layers.gaode.GaodeMapLayerTypes; | ||
17 | import com.pashanhoo.landsurvey.layers.gaode.GaodeMapsTiledServiceLayer; | ||
14 | import com.pashanhoo.landsurvey.layers.google.GoogleMapLayerTypes; | 18 | import com.pashanhoo.landsurvey.layers.google.GoogleMapLayerTypes; |
15 | import com.pashanhoo.landsurvey.layers.google.GoogleMapsTiledServiceLayer; | 19 | import com.pashanhoo.landsurvey.layers.google.GoogleMapsTiledServiceLayer; |
16 | import com.pashanhoo.landsurvey.layers.tianditu.TDTTileinfo; | 20 | import com.pashanhoo.landsurvey.layers.tianditu.TDTTileinfo; |
... | @@ -37,11 +41,17 @@ public class GoogleMapActivity extends AppCompatActivity { | ... | @@ -37,11 +41,17 @@ public class GoogleMapActivity extends AppCompatActivity { |
37 | 41 | ||
38 | // GoogleMapsTiledServiceLayer GOOGLE_VECTOR_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.VECTOR_GOOGLE_MAP); | 42 | // GoogleMapsTiledServiceLayer GOOGLE_VECTOR_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.VECTOR_GOOGLE_MAP); |
39 | // GoogleMapsTiledServiceLayer GOOGLE_TER_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.TERRAIN_GOOGLE_MAP); | 43 | // GoogleMapsTiledServiceLayer GOOGLE_TER_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.TERRAIN_GOOGLE_MAP); |
40 | GoogleMapsTiledServiceLayer GOOGLE_IMAGE_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.IMAGE_GOOGLE_MAP); | 44 | // GoogleMapsTiledServiceLayer GOOGLE_IMAGE_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.IMAGE_GOOGLE_MAP); |
41 | mapView.addLayer(GOOGLE_IMAGE_Layer); | 45 | // mapView.addLayer(GOOGLE_IMAGE_Layer); |
42 | // GoogleMapsTiledServiceLayer GOOGLE_ANNO_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.ANNOTATION_GOOGLE_MAP); | 46 | // GoogleMapsTiledServiceLayer GOOGLE_ANNO_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.IMAGE_ANNO_GOOGLE_MAP); |
43 | // mapView.addLayer(GOOGLE_ANNO_Layer); | 47 | // mapView.addLayer(GOOGLE_ANNO_Layer); |
44 | 48 | ||
49 | // GaodeMapsTiledServiceLayer gaodeMapsTiledServiceLayer = new GaodeMapsTiledServiceLayer(GaodeMapLayerTypes.VECTOR_Gaode_MAP); | ||
50 | // mapView.addLayer(gaodeMapsTiledServiceLayer); | ||
51 | |||
52 | GeoQMapsTiledServiceLayer geoQMapsTiledServiceLayer = new GeoQMapsTiledServiceLayer(GeoQMapLayerTypes.ChinaOnlineCommunity_Mobile); | ||
53 | mapView.addLayer(geoQMapsTiledServiceLayer); | ||
54 | |||
45 | mapView.setMaxResolution(156543.03392800014); | 55 | mapView.setMaxResolution(156543.03392800014); |
46 | mapView.setMinResolution(0.29858214164761665); | 56 | mapView.setMinResolution(0.29858214164761665); |
47 | 57 | ... | ... |
1 | package com.pashanhoo.landsurvey.layers.Geoq; | ||
2 | |||
3 | import com.pashanhoo.landsurvey.layers.BaseTiledMapServiceType; | ||
4 | |||
5 | public enum GeoQMapLayerTypes implements BaseTiledMapServiceType { | ||
6 | |||
7 | /** * Google vector map service by city map*/ | ||
8 | ChinaOnlineCommunity, | ||
9 | /** * Google image map service by satellite map */ | ||
10 | ChinaOnlineCommunity_Mobile, | ||
11 | /** * Google topographic map service ======= topographic map */ | ||
12 | ChinaOnlineCommunityENG, | ||
13 | |||
14 | ChinaOnlineStreetGray, | ||
15 | |||
16 | ChinaOnlineStreetPurplishBlue, | ||
17 | |||
18 | ChinaOnlineStreetWarm; | ||
19 | |||
20 | @Override | ||
21 | public String getName() | ||
22 | { | ||
23 | return this.name().toString(); | ||
24 | } | ||
25 | } |
1 | package com.pashanhoo.landsurvey.layers.Geoq; | ||
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.layers.gaode.GaodeMapLayerTypes; | ||
17 | import com.pashanhoo.landsurvey.utils.AppInfo; | ||
18 | import com.pashanhoo.landsurvey.utils.GADBHelper; | ||
19 | |||
20 | import java.util.concurrent.RejectedExecutionException; | ||
21 | |||
22 | /** | ||
23 | * Created by jiangbotao on 2018/3/28. | ||
24 | */ | ||
25 | |||
26 | public class GeoQMapsTiledServiceLayer extends TiledServiceLayer { | ||
27 | private static final double xmin = -22041257.773878; | ||
28 | private static final double ymin = -32673939.6727517; | ||
29 | private static final double xmax = 22041257.773878; | ||
30 | private static final double ymax = 20851350.0432886; | ||
31 | |||
32 | private static final double XMin = 110.35992000000005; | ||
33 | private static final double YMin = 31.382360000000062; | ||
34 | private static final double XMax = 116.65036000000009; | ||
35 | private static final double YMax = 36.36647000000005; | ||
36 | |||
37 | private static final double[] res = {156543.03392800014, | ||
38 | 78271.516963999937, | ||
39 | 39135.758482000092, | ||
40 | 19567.879240999919, | ||
41 | 9783.9396204999593, | ||
42 | 4891.9698102499797, | ||
43 | 2445.9849051249898, | ||
44 | 1222.9924525624949, | ||
45 | 611.49622628138, | ||
46 | 305.748113140558, | ||
47 | 152.874056570411, | ||
48 | 76.4370282850732, | ||
49 | 38.2185141425366, | ||
50 | 19.1092570712683, | ||
51 | 9.55462853563415, | ||
52 | 4.7773142679493699, | ||
53 | 2.3886571339746849, | ||
54 | 1.1943285668550503, | ||
55 | 0.59716428355981721, | ||
56 | 0.29858214164761665}; | ||
57 | |||
58 | private static final double[] scale = {591657527.591555, | ||
59 | 295828763.79577702, | ||
60 | 147914381.89788899, | ||
61 | 73957190.948944002, | ||
62 | 36978595.474472001, | ||
63 | 18489297.737236001, | ||
64 | 9244648.8686180003, | ||
65 | 4622324.4343090001, | ||
66 | 2311162.217155, | ||
67 | 1155581.108577, | ||
68 | 577790.554289, | ||
69 | 288895.277144, | ||
70 | 144447.638572, | ||
71 | 72223.819286, 6111.909643, | ||
72 | 18055.954822, | ||
73 | 9027.9774109999998, | ||
74 | 4513.9887049999998 | ||
75 | , 2256.994353, | ||
76 | 1128.4971760000001}; | ||
77 | |||
78 | private static String URL = "http://maps.iwxlh.com"; | ||
79 | private ResponseListener responseListener; | ||
80 | private static Point origin = new Point(-20037508.342787, 20037508.342787); | ||
81 | |||
82 | private GeoQMapLayerTypes geoQMapLayerTypes; | ||
83 | |||
84 | public GeoQMapsTiledServiceLayer(GeoQMapLayerTypes layerType) { | ||
85 | this(true); | ||
86 | this.geoQMapLayerTypes = layerType; | ||
87 | // 新建数据表,主要在Activity中必须有AppInfo.Settings()初始数据库 | ||
88 | GADBHelper.createTable(AppInfo.mapcachedb, this.geoQMapLayerTypes.getName()); | ||
89 | } | ||
90 | |||
91 | public GeoQMapsTiledServiceLayer(boolean initLayer) { | ||
92 | super(URL); | ||
93 | this.isBingMap = true; | ||
94 | |||
95 | if (!(initLayer)) | ||
96 | return; | ||
97 | try { | ||
98 | getServiceExecutor().submit(new Runnable() { | ||
99 | public void run() { | ||
100 | GeoQMapsTiledServiceLayer.this.initLayer(); | ||
101 | } | ||
102 | }); | ||
103 | } catch (RejectedExecutionException localRejectedExecutionException) { | ||
104 | Log.e("ArcGIS", "initialization of the layer failed.", localRejectedExecutionException); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | public static double[] getRes() { | ||
109 | return res; | ||
110 | } | ||
111 | |||
112 | protected void initLayer() { | ||
113 | if (getID() == 0L) { | ||
114 | this.nativeHandle = create(); | ||
115 | } | ||
116 | if (getID() == 0L) { | ||
117 | this.changeStatus(OnStatusChangedListener.STATUS.fromInt(-1000)); | ||
118 | } else { | ||
119 | try { | ||
120 | this.setDefaultSpatialReference(SpatialReference.create(102100)); | ||
121 | this.setFullExtent(new Envelope(xmin, ymin, xmax, ymax)); | ||
122 | this.setTileInfo(new TileInfo(origin, scale, res, scale.length, 96, 256, 256)); | ||
123 | super.initLayer(); | ||
124 | } catch (Exception localException) { | ||
125 | this.changeStatus(OnStatusChangedListener.STATUS.fromInt(-1005)); | ||
126 | Log.e("ArcGIS", "Bing map url =" + getUrl(), localException); | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | |||
131 | @SuppressLint("DefaultLocale") | ||
132 | protected byte[] getTile(int level, int col, int row) throws Exception { | ||
133 | byte[] result = null; | ||
134 | |||
135 | String url = ""; | ||
136 | String s = "Galil"; | ||
137 | switch (geoQMapLayerTypes) { | ||
138 | case ChinaOnlineCommunity: | ||
139 | url= "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer/tile/"+level+"/"+row+"/"+col; | ||
140 | break; | ||
141 | case ChinaOnlineCommunity_Mobile: | ||
142 | url= "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity_Mobile/MapServer/tile/"+level+"/"+row+"/"+col; | ||
143 | break; | ||
144 | case ChinaOnlineCommunityENG: | ||
145 | url= "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunityENG/MapServer/tile/"+level+"/"+row+"/"+col; | ||
146 | break; | ||
147 | case ChinaOnlineStreetGray: | ||
148 | url= "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetGray/MapServer/tile/"+level+"/"+row+"/"+col; | ||
149 | break; | ||
150 | case ChinaOnlineStreetPurplishBlue: | ||
151 | url= "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/"+level+"/"+row+"/"+col; | ||
152 | break; | ||
153 | case ChinaOnlineStreetWarm: | ||
154 | url= "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetWarm/MapServer/tile/"+level+"/"+row+"/"+col; | ||
155 | break; | ||
156 | } | ||
157 | |||
158 | try { | ||
159 | // 首先从离线数据库中读取 | ||
160 | result = getOfflineCacheDB(level, col, row); | ||
161 | // 如果没有就直接从web上读取 | ||
162 | if (result == null) { | ||
163 | result = a.a(url, null, null, this.responseListener); | ||
164 | // 将读取的数据存入mbtiles中 | ||
165 | AddOfflineCacheDB(level, col, row, result); | ||
166 | } | ||
167 | } catch (Exception ex) { | ||
168 | ex.printStackTrace(); | ||
169 | } | ||
170 | |||
171 | return result; | ||
172 | } | ||
173 | |||
174 | public void refresh() { | ||
175 | try { | ||
176 | getServiceExecutor().submit(new Runnable() { | ||
177 | public void run() { | ||
178 | if (!(GeoQMapsTiledServiceLayer.this.isInitialized())) | ||
179 | return; | ||
180 | try { | ||
181 | GeoQMapsTiledServiceLayer.this.clearTiles(); | ||
182 | } catch (Exception localException) { | ||
183 | Log.e("ArcGIS", "Re-initialization of the layer failed.", localException); | ||
184 | } | ||
185 | } | ||
186 | }); | ||
187 | } catch (RejectedExecutionException localRejectedExecutionException) { | ||
188 | return; | ||
189 | } | ||
190 | } | ||
191 | |||
192 | public void reinitializeLayer(UserCredentials usercredentials) { | ||
193 | } | ||
194 | |||
195 | public void reinitializeLayer(String appID) { | ||
196 | super.reinitializeLayer(null); | ||
197 | } | ||
198 | |||
199 | private byte[] getOfflineCacheDB(int level, int col, int row) throws Exception { | ||
200 | |||
201 | byte[] result = null; | ||
202 | String sql = "select * from " + this.geoQMapLayerTypes.getName() + " where TILELEVEL = " + level + " and TILECOL = " + col + " and TILEROW = " + row; | ||
203 | Cursor mCursor = AppInfo.mapcachedb.rawQuery(sql, null); | ||
204 | boolean hasData = false; | ||
205 | |||
206 | while (mCursor.moveToNext()) {//判断是否存在数据 | ||
207 | hasData = true; | ||
208 | } | ||
209 | if (hasData) {//数据库中有数据 | ||
210 | try { | ||
211 | if (mCursor.moveToFirst()) { | ||
212 | result = mCursor.getBlob(mCursor.getColumnIndex("TILEDATA")); | ||
213 | } | ||
214 | mCursor.close(); | ||
215 | } catch (Exception e) { | ||
216 | e.printStackTrace(); | ||
217 | result = null; | ||
218 | } | ||
219 | } | ||
220 | return result; | ||
221 | } | ||
222 | |||
223 | private void AddOfflineCacheDB(int level, int col, int row, byte[] bytes) { | ||
224 | ContentValues values = new ContentValues(); | ||
225 | values.put("TILELEVEL", level); | ||
226 | values.put("TILECOL", col); | ||
227 | values.put("TILEROW", row); | ||
228 | values.put("TILEDATA", bytes); | ||
229 | |||
230 | AppInfo.mapcachedb.insert(this.geoQMapLayerTypes.getName(), null, values); | ||
231 | } | ||
232 | } |
1 | package com.pashanhoo.landsurvey.layers.gaode; | ||
2 | |||
3 | import com.pashanhoo.landsurvey.layers.BaseTiledMapServiceType; | ||
4 | |||
5 | public enum GaodeMapLayerTypes implements BaseTiledMapServiceType { | ||
6 | |||
7 | /** * Google vector map service by city map*/ | ||
8 | VECTOR_Gaode_MAP, | ||
9 | |||
10 | /** * Google image map service by satellite map */ | ||
11 | IMAGE_Gaode_MAP, | ||
12 | |||
13 | Anno_Gaode_Map; | ||
14 | /** * Google topographic map service ======= topographic map */ | ||
15 | /** * Google road POI map service = = = = net road map */ | ||
16 | |||
17 | @Override | ||
18 | public String getName() | ||
19 | { | ||
20 | return this.name().toString(); | ||
21 | } | ||
22 | } |
1 | package com.pashanhoo.landsurvey.layers.gaode; | ||
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.layers.google.GoogleMapLayerTypes; | ||
17 | import com.pashanhoo.landsurvey.utils.AppInfo; | ||
18 | import com.pashanhoo.landsurvey.utils.GADBHelper; | ||
19 | |||
20 | import java.util.concurrent.RejectedExecutionException; | ||
21 | |||
22 | /** | ||
23 | * Created by jiangbotao on 2018/3/28. | ||
24 | */ | ||
25 | |||
26 | public class GaodeMapsTiledServiceLayer extends TiledServiceLayer { | ||
27 | private static final double xmin = -22041257.773878; | ||
28 | private static final double ymin = -32673939.6727517; | ||
29 | private static final double xmax = 22041257.773878; | ||
30 | private static final double ymax = 20851350.0432886; | ||
31 | |||
32 | private static final double XMin = 110.35992000000005; | ||
33 | private static final double YMin = 31.382360000000062; | ||
34 | private static final double XMax = 116.65036000000009; | ||
35 | private static final double YMax = 36.36647000000005; | ||
36 | |||
37 | private static final double[] res = {156543.03392800014, | ||
38 | 78271.516963999937, | ||
39 | 39135.758482000092, | ||
40 | 19567.879240999919, | ||
41 | 9783.9396204999593, | ||
42 | 4891.9698102499797, | ||
43 | 2445.9849051249898, | ||
44 | 1222.9924525624949, | ||
45 | 611.49622628138, | ||
46 | 305.748113140558, | ||
47 | 152.874056570411, | ||
48 | 76.4370282850732, | ||
49 | 38.2185141425366, | ||
50 | 19.1092570712683, | ||
51 | 9.55462853563415, | ||
52 | 4.7773142679493699, | ||
53 | 2.3886571339746849, | ||
54 | 1.1943285668550503, | ||
55 | 0.59716428355981721, | ||
56 | 0.29858214164761665}; | ||
57 | |||
58 | private static final double[] scale = {591657527.591555, | ||
59 | 295828763.79577702, | ||
60 | 147914381.89788899, | ||
61 | 73957190.948944002, | ||
62 | 36978595.474472001, | ||
63 | 18489297.737236001, | ||
64 | 9244648.8686180003, | ||
65 | 4622324.4343090001, | ||
66 | 2311162.217155, | ||
67 | 1155581.108577, | ||
68 | 577790.554289, | ||
69 | 288895.277144, | ||
70 | 144447.638572, | ||
71 | 72223.819286, 6111.909643, | ||
72 | 18055.954822, | ||
73 | 9027.9774109999998, | ||
74 | 4513.9887049999998 | ||
75 | , 2256.994353, | ||
76 | 1128.4971760000001}; | ||
77 | |||
78 | private static String URL = "http://maps.iwxlh.com"; | ||
79 | private ResponseListener responseListener; | ||
80 | private static Point origin = new Point(-20037508.342787, 20037508.342787); | ||
81 | |||
82 | private GaodeMapLayerTypes gaodeMapLayerTypes; | ||
83 | |||
84 | public GaodeMapsTiledServiceLayer(GaodeMapLayerTypes layerType) { | ||
85 | this(true); | ||
86 | this.gaodeMapLayerTypes = layerType; | ||
87 | // 新建数据表,主要在Activity中必须有AppInfo.Settings()初始数据库 | ||
88 | GADBHelper.createTable(AppInfo.mapcachedb, this.gaodeMapLayerTypes.getName()); | ||
89 | } | ||
90 | |||
91 | public GaodeMapsTiledServiceLayer(boolean initLayer) { | ||
92 | super(URL); | ||
93 | this.isBingMap = true; | ||
94 | |||
95 | if (!(initLayer)) | ||
96 | return; | ||
97 | try { | ||
98 | getServiceExecutor().submit(new Runnable() { | ||
99 | public void run() { | ||
100 | GaodeMapsTiledServiceLayer.this.initLayer(); | ||
101 | } | ||
102 | }); | ||
103 | } catch (RejectedExecutionException localRejectedExecutionException) { | ||
104 | Log.e("ArcGIS", "initialization of the layer failed.", localRejectedExecutionException); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | public static double[] getRes() { | ||
109 | return res; | ||
110 | } | ||
111 | |||
112 | protected void initLayer() { | ||
113 | if (getID() == 0L) { | ||
114 | this.nativeHandle = create(); | ||
115 | } | ||
116 | if (getID() == 0L) { | ||
117 | this.changeStatus(OnStatusChangedListener.STATUS.fromInt(-1000)); | ||
118 | } else { | ||
119 | try { | ||
120 | this.setDefaultSpatialReference(SpatialReference.create(102100)); | ||
121 | this.setFullExtent(new Envelope(xmin, ymin, xmax, ymax)); | ||
122 | this.setTileInfo(new TileInfo(origin, scale, res, scale.length, 96, 256, 256)); | ||
123 | super.initLayer(); | ||
124 | } catch (Exception localException) { | ||
125 | this.changeStatus(OnStatusChangedListener.STATUS.fromInt(-1005)); | ||
126 | Log.e("ArcGIS", "Bing map url =" + getUrl(), localException); | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | |||
131 | @SuppressLint("DefaultLocale") | ||
132 | protected byte[] getTile(int level, int col, int row) throws Exception { | ||
133 | byte[] result = null; | ||
134 | |||
135 | String url = ""; | ||
136 | String s = "Galil"; | ||
137 | switch (gaodeMapLayerTypes) { | ||
138 | case VECTOR_Gaode_MAP: | ||
139 | url= "http://webrd01.is.autonavi.com/appmaptile?&x=" + col + "&y=" + row + "&z=" + level + "&lang=zh_cn&size=1&scale=1&style=7"; | ||
140 | break; | ||
141 | case IMAGE_Gaode_MAP: | ||
142 | url = "http://webst02.is.autonavi.com/appmaptile?style=6&x="+col+"&y="+row+"&z="+level; | ||
143 | break; | ||
144 | case Anno_Gaode_Map: | ||
145 | url = "http://webst02.is.autonavi.com/appmaptile?style=8&x=" + col + "&y=" + row + "&z=" + level; | ||
146 | break; | ||
147 | } | ||
148 | |||
149 | try { | ||
150 | // 首先从离线数据库中读取 | ||
151 | result = getOfflineCacheDB(level, col, row); | ||
152 | // 如果没有就直接从web上读取 | ||
153 | if (result == null) { | ||
154 | result = a.a(url, null, null, this.responseListener); | ||
155 | // 将读取的数据存入mbtiles中 | ||
156 | AddOfflineCacheDB(level, col, row, result); | ||
157 | } | ||
158 | } catch (Exception ex) { | ||
159 | ex.printStackTrace(); | ||
160 | } | ||
161 | |||
162 | return result; | ||
163 | } | ||
164 | |||
165 | public void refresh() { | ||
166 | try { | ||
167 | getServiceExecutor().submit(new Runnable() { | ||
168 | public void run() { | ||
169 | if (!(GaodeMapsTiledServiceLayer.this.isInitialized())) | ||
170 | return; | ||
171 | try { | ||
172 | GaodeMapsTiledServiceLayer.this.clearTiles(); | ||
173 | } catch (Exception localException) { | ||
174 | Log.e("ArcGIS", "Re-initialization of the layer failed.", localException); | ||
175 | } | ||
176 | } | ||
177 | }); | ||
178 | } catch (RejectedExecutionException localRejectedExecutionException) { | ||
179 | return; | ||
180 | } | ||
181 | } | ||
182 | |||
183 | public void reinitializeLayer(UserCredentials usercredentials) { | ||
184 | } | ||
185 | |||
186 | public void reinitializeLayer(String appID) { | ||
187 | super.reinitializeLayer(null); | ||
188 | } | ||
189 | |||
190 | private byte[] getOfflineCacheDB(int level, int col, int row) throws Exception { | ||
191 | |||
192 | byte[] result = null; | ||
193 | String sql = "select * from " + this.gaodeMapLayerTypes.getName() + " where TILELEVEL = " + level + " and TILECOL = " + col + " and TILEROW = " + row; | ||
194 | Cursor mCursor = AppInfo.mapcachedb.rawQuery(sql, null); | ||
195 | boolean hasData = false; | ||
196 | |||
197 | while (mCursor.moveToNext()) {//判断是否存在数据 | ||
198 | hasData = true; | ||
199 | } | ||
200 | if (hasData) {//数据库中有数据 | ||
201 | try { | ||
202 | if (mCursor.moveToFirst()) { | ||
203 | result = mCursor.getBlob(mCursor.getColumnIndex("TILEDATA")); | ||
204 | } | ||
205 | mCursor.close(); | ||
206 | } catch (Exception e) { | ||
207 | e.printStackTrace(); | ||
208 | result = null; | ||
209 | } | ||
210 | } | ||
211 | return result; | ||
212 | } | ||
213 | |||
214 | private void AddOfflineCacheDB(int level, int col, int row, byte[] bytes) { | ||
215 | ContentValues values = new ContentValues(); | ||
216 | values.put("TILELEVEL", level); | ||
217 | values.put("TILECOL", col); | ||
218 | values.put("TILEROW", row); | ||
219 | values.put("TILEDATA", bytes); | ||
220 | |||
221 | AppInfo.mapcachedb.insert(this.gaodeMapLayerTypes.getName(), null, values); | ||
222 | } | ||
223 | } |
... | @@ -15,7 +15,7 @@ public enum GoogleMapLayerTypes implements BaseTiledMapServiceType { | ... | @@ -15,7 +15,7 @@ public enum GoogleMapLayerTypes implements BaseTiledMapServiceType { |
15 | /** * Google topographic map service ======= topographic map */ | 15 | /** * Google topographic map service ======= topographic map */ |
16 | TERRAIN_GOOGLE_MAP, | 16 | TERRAIN_GOOGLE_MAP, |
17 | /** * Google road POI map service = = = = net road map */ | 17 | /** * Google road POI map service = = = = net road map */ |
18 | ANNOTATION_GOOGLE_MAP; | 18 | IMAGE_ANNO_GOOGLE_MAP; |
19 | 19 | ||
20 | @Override | 20 | @Override |
21 | public String getName() | 21 | public String getName() | ... | ... |
... | @@ -143,9 +143,9 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer { | ... | @@ -143,9 +143,9 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer { |
143 | case TERRAIN_GOOGLE_MAP: | 143 | case TERRAIN_GOOGLE_MAP: |
144 | url = "http://mt" + (col % 4) + ".google.cn/vt/lyrs=t@131,r@227000000&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&" + "s=" + s; | 144 | url = "http://mt" + (col % 4) + ".google.cn/vt/lyrs=t@131,r@227000000&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&" + "s=" + s; |
145 | break; | 145 | break; |
146 | case ANNOTATION_GOOGLE_MAP: | 146 | case IMAGE_ANNO_GOOGLE_MAP: |
147 | // url = "http://mt2.google.cn/vt/lyrs=m@161000000&v=w2.114&hl=zh-CN&gl=CN&src=app&x=" + col + "&y=" + row + "&z=" + level + "&s=" + s; | 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; |
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; |
149 | break; | 149 | break; |
150 | } | 150 | } |
151 | 151 | ... | ... |
-
Please register or sign in to post a comment