update 3.28
Showing
5 changed files
with
66 additions
and
96 deletions
| ... | @@ -57,8 +57,6 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -57,8 +57,6 @@ public class MainActivity extends AppCompatActivity { |
| 57 | private TextView mapinfoView; | 57 | private TextView mapinfoView; |
| 58 | // 浮动查询条 | 58 | // 浮动查询条 |
| 59 | private FloatingSearchView floatingSearchView; | 59 | private FloatingSearchView floatingSearchView; |
| 60 | // 当前地图层级 | ||
| 61 | private int curLevel = 0; | ||
| 62 | // 地图类型名称 | 60 | // 地图类型名称 |
| 63 | private String mapType; | 61 | private String mapType; |
| 64 | 62 | ||
| ... | @@ -86,9 +84,10 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -86,9 +84,10 @@ public class MainActivity extends AppCompatActivity { |
| 86 | locationDisplayManager.stop(); | 84 | locationDisplayManager.stop(); |
| 87 | } | 85 | } |
| 88 | // 保证地图级别小于20 | 86 | // 保证地图级别小于20 |
| 89 | if (curLevel < 20) { | 87 | if (t_vec.getCurrentLevel() < 20) { |
| 90 | mapView.zoomin(true); | 88 | mapView.zoomin(true); |
| 91 | } | 89 | } |
| 90 | mapinfoView.setText("当前地图级别为:" + String.valueOf(t_vec.getCurrentLevel())); | ||
| 92 | } | 91 | } |
| 93 | }); | 92 | }); |
| 94 | // 缩小按钮 | 93 | // 缩小按钮 |
| ... | @@ -100,9 +99,10 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -100,9 +99,10 @@ public class MainActivity extends AppCompatActivity { |
| 100 | locationDisplayManager.stop(); | 99 | locationDisplayManager.stop(); |
| 101 | } | 100 | } |
| 102 | // 保证地图级别大于0 | 101 | // 保证地图级别大于0 |
| 103 | if (curLevel > 0) { | 102 | if (t_vec.getCurrentLevel() > 0) { |
| 104 | mapView.zoomout(true); | 103 | mapView.zoomout(true); |
| 105 | } | 104 | } |
| 105 | mapinfoView.setText("当前地图级别为:" + String.valueOf(t_vec.getCurrentLevel())); | ||
| 106 | } | 106 | } |
| 107 | }); | 107 | }); |
| 108 | // 回到初始页面 | 108 | // 回到初始页面 |
| ... | @@ -114,8 +114,7 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -114,8 +114,7 @@ public class MainActivity extends AppCompatActivity { |
| 114 | graphicsLayer.removeAll(); | 114 | graphicsLayer.removeAll(); |
| 115 | // 恢复初始设置地图范围 | 115 | // 恢复初始设置地图范围 |
| 116 | mapView.zoomToResolution(AppInfo.initPoint, AppInfo.initRes); | 116 | mapView.zoomToResolution(AppInfo.initPoint, AppInfo.initRes); |
| 117 | curLevel = TDTTileinfo.getCurrentLevel(AppInfo.initRes); | 117 | mapinfoView.setText("当前地图级别为:" + String.valueOf(t_vec.getCurrentLevel())); |
| 118 | mapinfoView.setText("当前地图级别为:" + String.valueOf(curLevel)); | ||
| 119 | } | 118 | } |
| 120 | }); | 119 | }); |
| 121 | // GPS按钮 | 120 | // GPS按钮 |
| ... | @@ -129,6 +128,7 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -129,6 +128,7 @@ public class MainActivity extends AppCompatActivity { |
| 129 | } else { | 128 | } else { |
| 130 | locationDisplayManager.start(); | 129 | locationDisplayManager.start(); |
| 131 | mapView.zoomToResolution(locationDisplayManager.getPoint(), t_vec.getRes()[18]); | 130 | mapView.zoomToResolution(locationDisplayManager.getPoint(), t_vec.getRes()[18]); |
| 131 | mapinfoView.setText("当前地图级别为:" + String.valueOf(t_vec.getCurrentLevel())); | ||
| 132 | } | 132 | } |
| 133 | } | 133 | } |
| 134 | }); | 134 | }); |
| ... | @@ -172,7 +172,7 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -172,7 +172,7 @@ public class MainActivity extends AppCompatActivity { |
| 172 | graphicsLayer = new GraphicsLayer(); | 172 | graphicsLayer = new GraphicsLayer(); |
| 173 | mapView.addLayer(graphicsLayer); | 173 | mapView.addLayer(graphicsLayer); |
| 174 | // 设置地图的最小和最大分辨率 | 174 | // 设置地图的最小和最大分辨率 |
| 175 | mapView.setMaxResolution(t_vec.getRes()[1]); | 175 | mapView.setMaxResolution(t_vec.getRes()[2]); |
| 176 | mapView.setMinResolution(t_vec.getRes()[19]); | 176 | mapView.setMinResolution(t_vec.getRes()[19]); |
| 177 | // 监听地图状态变化事件 | 177 | // 监听地图状态变化事件 |
| 178 | mapView.setOnStatusChangedListener(new OnStatusChangedListener() { | 178 | mapView.setOnStatusChangedListener(new OnStatusChangedListener() { |
| ... | @@ -183,8 +183,7 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -183,8 +183,7 @@ public class MainActivity extends AppCompatActivity { |
| 183 | // 刚刚打开时,将地图缩放到指定位置及层级 | 183 | // 刚刚打开时,将地图缩放到指定位置及层级 |
| 184 | if (status == STATUS.INITIALIZED) { | 184 | if (status == STATUS.INITIALIZED) { |
| 185 | mapView.zoomToResolution(AppInfo.initPoint, AppInfo.initRes); | 185 | mapView.zoomToResolution(AppInfo.initPoint, AppInfo.initRes); |
| 186 | curLevel = TDTTileinfo.getCurrentLevel(AppInfo.initRes); | 186 | mapinfoView.setText("当前地图级别为:" + String.valueOf(t_vec.getCurrentLevel())); |
| 187 | mapinfoView.setText("当前地图级别为:" + String.valueOf(curLevel)); | ||
| 188 | } | 187 | } |
| 189 | } | 188 | } |
| 190 | }); | 189 | }); |
| ... | @@ -195,10 +194,9 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -195,10 +194,9 @@ public class MainActivity extends AppCompatActivity { |
| 195 | 194 | ||
| 196 | @Override | 195 | @Override |
| 197 | public void postAction(float v, float v1, double v2) { | 196 | public void postAction(float v, float v1, double v2) { |
| 198 | curLevel = TDTTileinfo.getCurrentLevel(mapView.getResolution()); | 197 | mapinfoView.setText("当前地图级别为:" + String.valueOf(t_vec.getCurrentLevel())); |
| 199 | mapinfoView.setText("当前地图级别为:" + String.valueOf(curLevel)); | ||
| 200 | // t_local只有8和9级数据 | 198 | // t_local只有8和9级数据 |
| 201 | if (curLevel > 9 | curLevel < 8) { | 199 | if (t_vec.getCurrentLevel() > 9 | t_vec.getCurrentLevel() < 8) { |
| 202 | t_local.setVisible(false); | 200 | t_local.setVisible(false); |
| 203 | } else { | 201 | } else { |
| 204 | t_local.setVisible(true); | 202 | t_local.setVisible(true); |
| ... | @@ -215,7 +213,7 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -215,7 +213,7 @@ public class MainActivity extends AppCompatActivity { |
| 215 | @Override | 213 | @Override |
| 216 | public void onLocationChanged(Location location) { | 214 | public void onLocationChanged(Location location) { |
| 217 | mapView.zoomToResolution(new Point(location.getLongitude(), location.getLatitude()), t_vec.getRes()[18]); | 215 | mapView.zoomToResolution(new Point(location.getLongitude(), location.getLatitude()), t_vec.getRes()[18]); |
| 218 | mapinfoView.setText("当前地图级别为:18"); | 216 | mapinfoView.setText("当前地图级别为:" + t_vec.getCurrentLevel()); |
| 219 | } | 217 | } |
| 220 | 218 | ||
| 221 | @Override | 219 | @Override |
| ... | @@ -242,8 +240,7 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -242,8 +240,7 @@ public class MainActivity extends AppCompatActivity { |
| 242 | mapView.zoomToResolution(poipt, t_vec.getRes()[19]); | 240 | mapView.zoomToResolution(poipt, t_vec.getRes()[19]); |
| 243 | graphicsLayer.addGraphic(new Graphic(poipt, | 241 | graphicsLayer.addGraphic(new Graphic(poipt, |
| 244 | new PictureMarkerSymbol(getResources().getDrawable(R.mipmap.locator)).setOffsetY(16))); | 242 | new PictureMarkerSymbol(getResources().getDrawable(R.mipmap.locator)).setOffsetY(16))); |
| 245 | // floatingSearchView.clearSuggestions(); | 243 | mapinfoView.setText("当前地图级别为:"+ t_vec.getCurrentLevel()); |
| 246 | mapinfoView.setText("当前地图级别为:19"); | ||
| 247 | } | 244 | } |
| 248 | 245 | ||
| 249 | @Override | 246 | @Override | ... | ... |
| ... | @@ -17,7 +17,6 @@ import com.esri.core.internal.io.handler.a; | ... | @@ -17,7 +17,6 @@ import com.esri.core.internal.io.handler.a; |
| 17 | import com.esri.core.io.UserCredentials; | 17 | import com.esri.core.io.UserCredentials; |
| 18 | import com.pashanhoo.landsurvey.utils.AppInfo; | 18 | import com.pashanhoo.landsurvey.utils.AppInfo; |
| 19 | import com.pashanhoo.landsurvey.utils.GADBHelper; | 19 | import com.pashanhoo.landsurvey.utils.GADBHelper; |
| 20 | import com.pashanhoo.landsurvey.utils.GISHelper; | ||
| 21 | 20 | ||
| 22 | /** | 21 | /** |
| 23 | * Created by jiangbotao on 2018/3/28. | 22 | * Created by jiangbotao on 2018/3/28. | ... | ... |
| ... | @@ -144,12 +144,4 @@ public class TDTTileinfo { | ... | @@ -144,12 +144,4 @@ public class TDTTileinfo { |
| 144 | return tileHeight; | 144 | return tileHeight; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | public static int getCurrentLevel(double resolution){ | ||
| 148 | for(int i=0; i< res4490.length;i++){ | ||
| 149 | if((res4490[i] -resolution)<0.00000001){ | ||
| 150 | return i; | ||
| 151 | } | ||
| 152 | } | ||
| 153 | return 0; | ||
| 154 | } | ||
| 155 | } | 147 | } | ... | ... |
| 1 | package com.pashanhoo.landsurvey.layers.tianditu; | 1 | package com.pashanhoo.landsurvey.layers.tianditu; |
| 2 | 2 | ||
| 3 | import android.content.res.Resources; | ||
| 4 | import android.database.Cursor; | 3 | import android.database.Cursor; |
| 5 | import android.database.sqlite.SQLiteDatabase; | 4 | import android.database.sqlite.SQLiteDatabase; |
| 6 | import android.graphics.Bitmap; | ||
| 7 | import android.graphics.BitmapFactory; | ||
| 8 | import android.graphics.Color; | ||
| 9 | import android.os.Environment; | 5 | import android.os.Environment; |
| 10 | import android.util.Log; | ||
| 11 | 6 | ||
| 12 | import com.esri.android.map.TiledServiceLayer; | 7 | import com.esri.android.map.TiledServiceLayer; |
| 13 | import com.esri.core.geometry.Envelope; | 8 | import com.esri.core.geometry.Envelope; |
| 14 | import com.esri.core.geometry.Point; | 9 | import com.esri.core.geometry.Point; |
| 15 | import com.esri.core.geometry.SpatialReference; | 10 | import com.esri.core.geometry.SpatialReference; |
| 16 | import com.pashanhoo.landsurvey.R; | ||
| 17 | import com.pashanhoo.landsurvey.utils.AppInfo; | ||
| 18 | 11 | ||
| 19 | import java.util.concurrent.RejectedExecutionException; | 12 | import java.util.concurrent.RejectedExecutionException; |
| 20 | 13 | ||
| ... | @@ -24,7 +17,59 @@ import java.util.concurrent.RejectedExecutionException; | ... | @@ -24,7 +17,59 @@ import java.util.concurrent.RejectedExecutionException; |
| 24 | 17 | ||
| 25 | public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer { | 18 | public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer { |
| 26 | 19 | ||
| 27 | private TileInfo tiandituTileInfo; | 20 | private static final Point originalPoint = new Point(-180, 90); |
| 21 | |||
| 22 | private static final double[] res = { | ||
| 23 | 1.40625, | ||
| 24 | 0.703125, | ||
| 25 | 0.3515625, | ||
| 26 | 0.17578125, | ||
| 27 | 0.087890625, | ||
| 28 | 0.0439453125, | ||
| 29 | 0.02197265625, | ||
| 30 | 0.010986328125, | ||
| 31 | 0.0054931640625, | ||
| 32 | 0.00274658203125, | ||
| 33 | 0.001373291015625, | ||
| 34 | 0.0006866455078125, | ||
| 35 | 0.00034332275390625, | ||
| 36 | 0.000171661376953125, | ||
| 37 | 8.58306884765629E-05, | ||
| 38 | 4.29153442382814E-05, | ||
| 39 | 2.14576721191407E-05, | ||
| 40 | 1.07288360595703E-05, | ||
| 41 | 5.36441802978515E-06, | ||
| 42 | 2.68220901489258E-06, | ||
| 43 | 1.34110450744629E-06 | ||
| 44 | }; | ||
| 45 | private static final double[] scale = { | ||
| 46 | 400000000, | ||
| 47 | 295497598.5708346, | ||
| 48 | 147748799.285417, | ||
| 49 | 73874399.6427087, | ||
| 50 | 36937199.8213544, | ||
| 51 | 18468599.9106772, | ||
| 52 | 9234299.95533859, | ||
| 53 | 4617149.97766929, | ||
| 54 | 2308574.98883465, | ||
| 55 | 1154287.49441732, | ||
| 56 | 577143.747208662, | ||
| 57 | 288571.873604331, | ||
| 58 | 144285.936802165, | ||
| 59 | 72142.9684010827, | ||
| 60 | 36071.4842005414, | ||
| 61 | 18035.7421002707, | ||
| 62 | 9017.87105013534, | ||
| 63 | 4508.93552506767, | ||
| 64 | 2254.467762533835, | ||
| 65 | 1127.2338812669175, | ||
| 66 | 563.616940 | ||
| 67 | }; | ||
| 68 | private static final int levels = 21; | ||
| 69 | private static final int dpi = 96; | ||
| 70 | private static final int tileWidth = 256; | ||
| 71 | private static final int tileHeight = 256; | ||
| 72 | |||
| 28 | private String layername = ""; | 73 | private String layername = ""; |
| 29 | private SQLiteDatabase sqLiteDatabase; | 74 | private SQLiteDatabase sqLiteDatabase; |
| 30 | 75 | ||
| ... | @@ -42,7 +87,6 @@ public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer { | ... | @@ -42,7 +87,6 @@ public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer { |
| 42 | 87 | ||
| 43 | final TianDiTuLocalTiledMapServiceLayer a; | 88 | final TianDiTuLocalTiledMapServiceLayer a; |
| 44 | 89 | ||
| 45 | |||
| 46 | { | 90 | { |
| 47 | a = TianDiTuLocalTiledMapServiceLayer.this; | 91 | a = TianDiTuLocalTiledMapServiceLayer.this; |
| 48 | //super(); | 92 | //super(); |
| ... | @@ -55,7 +99,7 @@ public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer { | ... | @@ -55,7 +99,7 @@ public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer { |
| 55 | 99 | ||
| 56 | 100 | ||
| 57 | protected void initLayer() { | 101 | protected void initLayer() { |
| 58 | this.buildTileInfo(); | 102 | this.setTileInfo(new com.esri.android.map.TiledServiceLayer.TileInfo(originalPoint, scale, res, levels, dpi, tileWidth, tileHeight)); |
| 59 | this.setFullExtent(new Envelope(-180, -90, 180, 90)); | 103 | this.setFullExtent(new Envelope(-180, -90, 180, 90)); |
| 60 | this.setDefaultSpatialReference(SpatialReference.create(4490)); //CGCS2000 | 104 | this.setDefaultSpatialReference(SpatialReference.create(4490)); //CGCS2000 |
| 61 | //this.setDefaultSpatialReference(SpatialReference.create(4326)); | 105 | //this.setDefaultSpatialReference(SpatialReference.create(4326)); |
| ... | @@ -91,61 +135,4 @@ public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer { | ... | @@ -91,61 +135,4 @@ public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer { |
| 91 | 135 | ||
| 92 | return result; | 136 | return result; |
| 93 | } | 137 | } |
| 94 | |||
| 95 | private void buildTileInfo() { | ||
| 96 | Point originalPoint = new Point(-180, 90); | ||
| 97 | |||
| 98 | double[] res = { | ||
| 99 | 1.40625, | ||
| 100 | 0.703125, | ||
| 101 | 0.3515625, | ||
| 102 | 0.17578125, | ||
| 103 | 0.087890625, | ||
| 104 | 0.0439453125, | ||
| 105 | 0.02197265625, | ||
| 106 | 0.010986328125, | ||
| 107 | 0.0054931640625, | ||
| 108 | 0.00274658203125, | ||
| 109 | 0.001373291015625, | ||
| 110 | 0.0006866455078125, | ||
| 111 | 0.00034332275390625, | ||
| 112 | 0.000171661376953125, | ||
| 113 | 8.58306884765629E-05, | ||
| 114 | 4.29153442382814E-05, | ||
| 115 | 2.14576721191407E-05, | ||
| 116 | 1.07288360595703E-05, | ||
| 117 | 5.36441802978515E-06, | ||
| 118 | 2.68220901489258E-06, | ||
| 119 | 1.34110450744629E-06 | ||
| 120 | }; | ||
| 121 | double[] scale = { | ||
| 122 | 400000000, | ||
| 123 | 295497598.5708346, | ||
| 124 | 147748799.285417, | ||
| 125 | 73874399.6427087, | ||
| 126 | 36937199.8213544, | ||
| 127 | 18468599.9106772, | ||
| 128 | 9234299.95533859, | ||
| 129 | 4617149.97766929, | ||
| 130 | 2308574.98883465, | ||
| 131 | 1154287.49441732, | ||
| 132 | 577143.747208662, | ||
| 133 | 288571.873604331, | ||
| 134 | 144285.936802165, | ||
| 135 | 72142.9684010827, | ||
| 136 | 36071.4842005414, | ||
| 137 | 18035.7421002707, | ||
| 138 | 9017.87105013534, | ||
| 139 | 4508.93552506767, | ||
| 140 | 2254.467762533835, | ||
| 141 | 1127.2338812669175, | ||
| 142 | 563.616940 | ||
| 143 | }; | ||
| 144 | int levels = 21; | ||
| 145 | int dpi = 96; | ||
| 146 | int tileWidth = 256; | ||
| 147 | int tileHeight = 256; | ||
| 148 | this.tiandituTileInfo = new com.esri.android.map.TiledServiceLayer.TileInfo(originalPoint, scale, res, levels, dpi, tileWidth, tileHeight); | ||
| 149 | this.setTileInfo(this.tiandituTileInfo); | ||
| 150 | } | ||
| 151 | } | 138 | } | ... | ... |
| ... | @@ -9,15 +9,10 @@ import com.esri.core.geometry.Envelope; | ... | @@ -9,15 +9,10 @@ import com.esri.core.geometry.Envelope; |
| 9 | import com.esri.core.geometry.Point; | 9 | import com.esri.core.geometry.Point; |
| 10 | import com.esri.core.geometry.SpatialReference; | 10 | import com.esri.core.geometry.SpatialReference; |
| 11 | import com.esri.core.internal.io.handler.ResponseListener; | 11 | import com.esri.core.internal.io.handler.ResponseListener; |
| 12 | import com.esri.core.internal.io.handler.a; | ||
| 13 | import com.esri.core.io.UserCredentials; | 12 | import com.esri.core.io.UserCredentials; |
| 14 | import com.pashanhoo.landsurvey.utils.AppInfo; | 13 | import com.pashanhoo.landsurvey.utils.AppInfo; |
| 15 | import com.pashanhoo.landsurvey.utils.GADBHelper; | 14 | import com.pashanhoo.landsurvey.utils.GADBHelper; |
| 16 | 15 | ||
| 17 | import java.io.BufferedInputStream; | ||
| 18 | import java.io.ByteArrayOutputStream; | ||
| 19 | import java.net.HttpURLConnection; | ||
| 20 | import java.net.URL; | ||
| 21 | import java.util.Random; | 16 | import java.util.Random; |
| 22 | import java.util.concurrent.RejectedExecutionException; | 17 | import java.util.concurrent.RejectedExecutionException; |
| 23 | 18 | ... | ... |
-
Please register or sign in to post a comment