update 3.26
Showing
4 changed files
with
46 additions
and
28 deletions
... | @@ -10,6 +10,7 @@ import android.util.Log; | ... | @@ -10,6 +10,7 @@ import android.util.Log; |
10 | import android.view.View; | 10 | import android.view.View; |
11 | import android.view.Menu; | 11 | import android.view.Menu; |
12 | import android.view.MenuItem; | 12 | import android.view.MenuItem; |
13 | import android.widget.TextView; | ||
13 | 14 | ||
14 | import com.esri.android.map.LocationDisplayManager; | 15 | import com.esri.android.map.LocationDisplayManager; |
15 | import com.esri.android.map.MapView; | 16 | import com.esri.android.map.MapView; |
... | @@ -35,12 +36,15 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -35,12 +36,15 @@ public class MainActivity extends AppCompatActivity { |
35 | private TianDiTuLocalTiledMapServiceLayer t_local; | 36 | private TianDiTuLocalTiledMapServiceLayer t_local; |
36 | 37 | ||
37 | private String mapType; | 38 | private String mapType; |
39 | private TextView mapinfoView; | ||
40 | private int curLevel = 0; | ||
38 | 41 | ||
39 | @Override | 42 | @Override |
40 | protected void onCreate(Bundle savedInstanceState) { | 43 | protected void onCreate(Bundle savedInstanceState) { |
41 | super.onCreate(savedInstanceState); | 44 | super.onCreate(savedInstanceState); |
42 | setContentView(R.layout.activity_main); | 45 | setContentView(R.layout.activity_main); |
43 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | 46 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); |
47 | mapinfoView = (TextView)findViewById(R.id.mapinfo); | ||
44 | setSupportActionBar(toolbar); | 48 | setSupportActionBar(toolbar); |
45 | //初始化------------------------------------------------------------------- | 49 | //初始化------------------------------------------------------------------- |
46 | AppInfo.Settings(); | 50 | AppInfo.Settings(); |
... | @@ -52,8 +56,10 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -52,8 +56,10 @@ public class MainActivity extends AppCompatActivity { |
52 | if(locationDisplayManager!=null){ | 56 | if(locationDisplayManager!=null){ |
53 | locationDisplayManager.stop(); | 57 | locationDisplayManager.stop(); |
54 | } | 58 | } |
59 | if(curLevel < 19) { | ||
55 | mapView.zoomin(true); | 60 | mapView.zoomin(true); |
56 | } | 61 | } |
62 | } | ||
57 | }); | 63 | }); |
58 | FloatingActionButton zoomout = (FloatingActionButton) findViewById(R.id.zoomout); | 64 | FloatingActionButton zoomout = (FloatingActionButton) findViewById(R.id.zoomout); |
59 | zoomout.setOnClickListener(new View.OnClickListener() { | 65 | zoomout.setOnClickListener(new View.OnClickListener() { |
... | @@ -62,8 +68,10 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -62,8 +68,10 @@ public class MainActivity extends AppCompatActivity { |
62 | if(locationDisplayManager!=null){ | 68 | if(locationDisplayManager!=null){ |
63 | locationDisplayManager.stop(); | 69 | locationDisplayManager.stop(); |
64 | } | 70 | } |
71 | if(curLevel > 0) { | ||
65 | mapView.zoomout(true); | 72 | mapView.zoomout(true); |
66 | } | 73 | } |
74 | } | ||
67 | }); | 75 | }); |
68 | FloatingActionButton fullmap = (FloatingActionButton) findViewById(R.id.fullmap); | 76 | FloatingActionButton fullmap = (FloatingActionButton) findViewById(R.id.fullmap); |
69 | fullmap.setOnClickListener(new View.OnClickListener() { | 77 | fullmap.setOnClickListener(new View.OnClickListener() { |
... | @@ -116,6 +124,8 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -116,6 +124,8 @@ public class MainActivity extends AppCompatActivity { |
116 | public void onStatusChanged(Object o, STATUS status) { | 124 | public void onStatusChanged(Object o, STATUS status) { |
117 | if(status == STATUS.INITIALIZED){ | 125 | if(status == STATUS.INITIALIZED){ |
118 | mapView.zoomToResolution(AppInfo.initPoint, AppInfo.initRes); | 126 | mapView.zoomToResolution(AppInfo.initPoint, AppInfo.initRes); |
127 | curLevel= TDTTileinfo.getCurrentLevel(AppInfo.initRes); | ||
128 | mapinfoView.setText("当前地图级别为:"+ String.valueOf(curLevel)); | ||
119 | } | 129 | } |
120 | } | 130 | } |
121 | }); | 131 | }); |
... | @@ -126,10 +136,13 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -126,10 +136,13 @@ public class MainActivity extends AppCompatActivity { |
126 | 136 | ||
127 | @Override | 137 | @Override |
128 | public void postAction(float v, float v1, double v2) { | 138 | public void postAction(float v, float v1, double v2) { |
129 | Log.i("map", String.valueOf(TDTTileinfo.getCurrentLevel(mapView.getResolution()))); | 139 | curLevel = TDTTileinfo.getCurrentLevel(mapView.getResolution()); |
130 | int level = TDTTileinfo.getCurrentLevel(mapView.getResolution()); | 140 | mapinfoView.setText("当前地图级别为:"+ String.valueOf(curLevel)); |
131 | if(level > 7 || level < 10){ | 141 | // t_local只有8和9级数据 |
132 | t_local.clearTiles(); | 142 | if(curLevel > 9 | curLevel <8){ |
143 | t_local.setVisible(false); | ||
144 | }else{ | ||
145 | t_local.setVisible(true); | ||
133 | } | 146 | } |
134 | } | 147 | } |
135 | }); | 148 | }); | ... | ... |
1 | package com.pashanhoo.landsurvey.layers.tianditu; | 1 | package com.pashanhoo.landsurvey.layers.tianditu; |
2 | 2 | ||
3 | import android.util.Log; | ||
4 | |||
3 | import com.esri.core.geometry.Point; | 5 | import com.esri.core.geometry.Point; |
4 | 6 | ||
5 | /** | 7 | /** |
... | @@ -144,7 +146,7 @@ public class TDTTileinfo { | ... | @@ -144,7 +146,7 @@ public class TDTTileinfo { |
144 | 146 | ||
145 | public static int getCurrentLevel(double resolution){ | 147 | public static int getCurrentLevel(double resolution){ |
146 | for(int i=0; i< res4490.length;i++){ | 148 | for(int i=0; i< res4490.length;i++){ |
147 | if((res4490[i] -resolution)<0.001){ | 149 | if((res4490[i] -resolution)<0.00000001){ |
148 | return i; | 150 | return i; |
149 | } | 151 | } |
150 | } | 152 | } | ... | ... |
... | @@ -24,14 +24,15 @@ import java.util.concurrent.RejectedExecutionException; | ... | @@ -24,14 +24,15 @@ import java.util.concurrent.RejectedExecutionException; |
24 | 24 | ||
25 | public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer { | 25 | public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer { |
26 | 26 | ||
27 | String sqlitedb = ""; | ||
28 | private TileInfo tiandituTileInfo; | 27 | private TileInfo tiandituTileInfo; |
29 | private String layername = ""; | 28 | private String layername = ""; |
29 | private SQLiteDatabase sqLiteDatabase; | ||
30 | 30 | ||
31 | public TianDiTuLocalTiledMapServiceLayer(String url, String layername) { | 31 | public TianDiTuLocalTiledMapServiceLayer(String dbname, String layername) { |
32 | super(url); | 32 | super(dbname); |
33 | this.sqlitedb = url; | ||
34 | this.layername = layername; | 33 | this.layername = layername; |
34 | this.sqLiteDatabase = SQLiteDatabase.openOrCreateDatabase(Environment.getExternalStorageDirectory()+"/keymapinfo/" + dbname, | ||
35 | null); | ||
35 | try { | 36 | try { |
36 | getServiceExecutor().submit(new Runnable() { | 37 | getServiceExecutor().submit(new Runnable() { |
37 | 38 | ||
... | @@ -67,24 +68,8 @@ public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer { | ... | @@ -67,24 +68,8 @@ public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer { |
67 | protected byte[] getTile(int level, int col, int row) throws Exception { | 68 | protected byte[] getTile(int level, int col, int row) throws Exception { |
68 | byte[] result = null; | 69 | byte[] result = null; |
69 | try{ | 70 | try{ |
70 | result = getOfflineCacheDB(level, col, row); | 71 | String sql = "SELECT * FROM " + this.layername + " where TILELEVEL = " + level + " and TILECOL = " + col + " and TILEROW = " + row; |
71 | }catch (Exception ex) { | 72 | Cursor mCursor = this.sqLiteDatabase.rawQuery(sql, null); |
72 | ex.printStackTrace(); | ||
73 | } | ||
74 | |||
75 | return result; | ||
76 | } | ||
77 | |||
78 | private byte[] getOfflineCacheDB(int level, int col, int row) throws Exception { | ||
79 | |||
80 | byte[] result = null; | ||
81 | // Log.i("local", level + ":"+ col + ":" + row); | ||
82 | // row = (int) (Math.pow(2, level) - col - row); | ||
83 | String sql = "select * from " + this.layername + " where TILELEVEL = " + level + " and TILECOL = " + col + " and TILEROW = " + row; | ||
84 | |||
85 | Cursor mCursor = | ||
86 | SQLiteDatabase.openOrCreateDatabase(Environment.getExternalStorageDirectory()+"/keymapinfo/" + this.sqlitedb, null) | ||
87 | .rawQuery(sql, null); | ||
88 | boolean hasData = false; | 73 | boolean hasData = false; |
89 | 74 | ||
90 | while (mCursor.moveToNext()) {//判断是否存在数据 | 75 | while (mCursor.moveToNext()) {//判断是否存在数据 |
... | @@ -97,10 +82,13 @@ public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer { | ... | @@ -97,10 +82,13 @@ public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer { |
97 | } | 82 | } |
98 | mCursor.close(); | 83 | mCursor.close(); |
99 | } catch (Exception e) { | 84 | } catch (Exception e) { |
100 | e.printStackTrace(); | ||
101 | result = null; | 85 | result = null; |
102 | } | 86 | } |
103 | } | 87 | } |
88 | }catch (Exception ex) { | ||
89 | result = null; | ||
90 | } | ||
91 | |||
104 | return result; | 92 | return result; |
105 | } | 93 | } |
106 | 94 | ... | ... |
... | @@ -64,5 +64,20 @@ | ... | @@ -64,5 +64,20 @@ |
64 | app:srcCompat="@mipmap/ic_home_white_48dp" /> | 64 | app:srcCompat="@mipmap/ic_home_white_48dp" /> |
65 | </android.support.v7.widget.LinearLayoutCompat> | 65 | </android.support.v7.widget.LinearLayoutCompat> |
66 | 66 | ||
67 | <android.support.v7.widget.LinearLayoutCompat | ||
68 | android:layout_width="match_parent" | ||
69 | android:layout_height="20dp" | ||
70 | android:orientation="vertical" | ||
71 | android:layout_marginLeft="16dp" | ||
72 | android:layout_marginRight="16dp" | ||
73 | android:layout_marginBottom="16dp" | ||
74 | android:layout_gravity="bottom|left"> | ||
67 | 75 | ||
76 | <TextView | ||
77 | android:id="@+id/mapinfo" | ||
78 | android:layout_width="match_parent" | ||
79 | android:layout_height="wrap_content" | ||
80 | android:textColor="@color/colorAccent" | ||
81 | android:text="地图信息" /> | ||
82 | </android.support.v7.widget.LinearLayoutCompat> | ||
68 | </android.support.design.widget.CoordinatorLayout> | 83 | </android.support.design.widget.CoordinatorLayout> | ... | ... |
-
Please register or sign in to post a comment