update 3.28
Showing
2 changed files
with
93 additions
and
1 deletions
1 | package com.pashanhoo.landsurvey.layers.google; | ||
2 | |||
3 | import com.esri.android.map.TiledServiceLayer; | ||
4 | import com.esri.core.geometry.Envelope; | ||
5 | import com.esri.core.geometry.Point; | ||
6 | import com.esri.core.geometry.SpatialReference; | ||
7 | |||
8 | import java.util.Map; | ||
9 | import java.util.concurrent.RejectedExecutionException; | ||
10 | |||
11 | /** | ||
12 | * Created by jiangbotao on 2018/3/28. | ||
13 | */ | ||
14 | |||
15 | public class GoogleMapLayer extends TiledServiceLayer { | ||
16 | |||
17 | private int minLevel = 0; | ||
18 | private int maxLevel = 19; | ||
19 | |||
20 | private String[] subDomains = new String[]{"mt1", "mt2", "mt3"}; | ||
21 | |||
22 | private double[] scales = new double[]{591657527.591555, | ||
23 | 295828763.79577702, 147914381.89788899, 73957190.948944002, | ||
24 | 36978595.474472001, 18489297.737236001, 9244648.8686180003, | ||
25 | 4622324.4343090001, 2311162.217155, 1155581.108577, 577790.554289, | ||
26 | 288895.277144, 144447.638572, 72223.819286, 36111.909643, | ||
27 | 18055.954822, 9027.9774109999998, 4513.9887049999998, 2256.994353, | ||
28 | 1128.4971760000001}; | ||
29 | private double[] resolutions = new double[]{156543.03392800014, | ||
30 | 78271.516963999937, 39135.758482000092, 19567.879240999919, | ||
31 | 9783.9396204999593, 4891.9698102499797, 2445.9849051249898, | ||
32 | 1222.9924525624949, 611.49622628138, 305.748113140558, | ||
33 | 152.874056570411, 76.4370282850732, 38.2185141425366, | ||
34 | 19.1092570712683, 9.55462853563415, 4.7773142679493699, | ||
35 | 2.3886571339746849, 1.1943285668550503, 0.59716428355981721, | ||
36 | 0.29858214164761665}; | ||
37 | |||
38 | private Point origin = new Point(-20037508.342787, 20037508.342787); | ||
39 | |||
40 | private int dpi = 96; | ||
41 | |||
42 | private int tileWidth = 256; | ||
43 | private int tileHeight = 256; | ||
44 | |||
45 | public GoogleMapLayer() { | ||
46 | super(true); | ||
47 | this.init(); | ||
48 | } | ||
49 | |||
50 | private void init() { | ||
51 | try { | ||
52 | getServiceExecutor().submit(new Runnable() { | ||
53 | public void run() { | ||
54 | GoogleMapLayer.this.initLayer(); | ||
55 | } | ||
56 | }); | ||
57 | } catch (RejectedExecutionException rejectedexecutionexception) { | ||
58 | |||
59 | } | ||
60 | } | ||
61 | |||
62 | protected byte[] getTile(int level, int col, int row) throws Exception { | ||
63 | if (level > maxLevel || level < minLevel) | ||
64 | return new byte[0]; | ||
65 | String subDomain = subDomains[(level + col + row) % subDomains.length]; | ||
66 | |||
67 | //构建待拼接字符串 | ||
68 | String _mapType = "m@225000000"; | ||
69 | String url = "http://" + subDomain | ||
70 | + ".google.cn/vt/lyrs=" + _mapType + "&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=Ga"; | ||
71 | |||
72 | |||
73 | Map<String, String> map = null; | ||
74 | return com.esri.core.internal.io.handler.a.a(url, map); | ||
75 | } | ||
76 | |||
77 | protected void initLayer() { | ||
78 | if (getID() == 0L) { | ||
79 | nativeHandle = create(); | ||
80 | changeStatus(com.esri.android.map.event.OnStatusChangedListener.STATUS | ||
81 | .fromInt(-1000)); | ||
82 | } else { | ||
83 | this.setDefaultSpatialReference(SpatialReference.create(102113)); | ||
84 | this.setFullExtent(new Envelope(-22041257.773878, | ||
85 | -32673939.6727517, 22041257.773878, 20851350.0432886)); | ||
86 | this.setTileInfo(new TileInfo(origin, scales, resolutions,scales.length, dpi, tileWidth, tileHeight)); | ||
87 | super.initLayer(); | ||
88 | } | ||
89 | } | ||
90 | } |
... | @@ -21,7 +21,9 @@ public class AppInfo { | ... | @@ -21,7 +21,9 @@ public class AppInfo { |
21 | 21 | ||
22 | public static Point initPoint = new Point(121.56, 29.862149); | 22 | public static Point initPoint = new Point(121.56, 29.862149); |
23 | 23 | ||
24 | public static double initRes = TDTTileinfo.getRes4490()[6]; | 24 | // public static double initRes = TDTTileinfo.getRes4490()[6]; |
25 | public static double initRes = TDTTileinfo.getRes4326()[6]; | ||
26 | |||
25 | 27 | ||
26 | public static void Settings(){ | 28 | public static void Settings(){ |
27 | // 新建地图缓存数据库,不要试图新建多级目录,切记切记,如keymapinfo/cache | 29 | // 新建地图缓存数据库,不要试图新建多级目录,切记切记,如keymapinfo/cache | ... | ... |
-
Please register or sign in to post a comment