a437ef42 by chiangbt

update 3.27.10.49

1 parent 9502c15b
This file is too large to display.
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"com.pashanhoo.landsurvey","split":"","minSdkVersion":"21"}}]
\ No newline at end of file
......@@ -14,30 +14,35 @@ import android.widget.TextView;
import com.androidnetworking.AndroidNetworking;
import com.androidnetworking.error.ANError;
import com.androidnetworking.interfaces.JSONArrayRequestListener;
import com.androidnetworking.interfaces.JSONObjectRequestListener;
import com.arlib.floatingsearchview.FloatingSearchView;
import com.arlib.floatingsearchview.suggestions.model.SearchSuggestion;
import com.esri.android.map.GraphicsLayer;
import com.esri.android.map.LocationDisplayManager;
import com.esri.android.map.MapView;
import com.esri.android.map.event.OnStatusChangedListener;
import com.esri.android.map.event.OnZoomListener;
import com.esri.android.runtime.ArcGISRuntime;
import com.esri.core.geometry.Point;
import com.esri.core.map.Graphic;
import com.esri.core.symbol.PictureMarkerSymbol;
import com.pashanhoo.landsurvey.layers.tianditu.TDTTileinfo;
import com.pashanhoo.landsurvey.layers.tianditu.TianDiTuLocalTiledMapServiceLayer;
import com.pashanhoo.landsurvey.layers.tianditu.TianDiTuTiledMapServiceLayer;
import com.pashanhoo.landsurvey.layers.tianditu.TianDiTuTiledMapServiceType;
import com.pashanhoo.landsurvey.search.DataHelper;
import com.pashanhoo.landsurvey.search.POISuggestion;
import com.pashanhoo.landsurvey.utils.AppInfo;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
private MapView mapView;
private GraphicsLayer graphicsLayer;
private LocationDisplayManager locationDisplayManager;
private TianDiTuTiledMapServiceLayer t_vec;
private TianDiTuTiledMapServiceLayer t_cva;
......@@ -56,8 +61,8 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
mapinfoView = (TextView)findViewById(R.id.mapinfo);
floatingSearchView = (FloatingSearchView)findViewById(R.id.floating_search_view);
mapinfoView = (TextView) findViewById(R.id.mapinfo);
floatingSearchView = (FloatingSearchView) findViewById(R.id.floating_search_view);
setSupportActionBar(toolbar);
//初始化-------------------------------------------------------------------
AppInfo.Settings();
......@@ -66,10 +71,10 @@ public class MainActivity extends AppCompatActivity {
zoomin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(locationDisplayManager!=null){
if (locationDisplayManager != null) {
locationDisplayManager.stop();
}
if(curLevel < 19) {
if (curLevel < 20) {
mapView.zoomin(true);
}
}
......@@ -78,10 +83,10 @@ public class MainActivity extends AppCompatActivity {
zoomout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(locationDisplayManager!=null){
if (locationDisplayManager != null) {
locationDisplayManager.stop();
}
if(curLevel > 0) {
if (curLevel > 0) {
mapView.zoomout(true);
}
}
......@@ -93,16 +98,16 @@ public class MainActivity extends AppCompatActivity {
locationDisplayManager.stop();
mapView.zoomToResolution(AppInfo.initPoint, AppInfo.initRes);
curLevel = TDTTileinfo.getCurrentLevel(AppInfo.initRes);
mapinfoView.setText("当前地图级别为:"+ String.valueOf(curLevel));
mapinfoView.setText("当前地图级别为:" + String.valueOf(curLevel));
}
});
FloatingActionButton gps = (FloatingActionButton) findViewById(R.id.gps);
gps.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(locationDisplayManager.isStarted()){
if (locationDisplayManager.isStarted()) {
locationDisplayManager.stop();
}else{
} else {
locationDisplayManager.start();
mapView.zoomToResolution(locationDisplayManager.getPoint(), TDTTileinfo.getRes4490()[18]);
}
......@@ -110,7 +115,7 @@ public class MainActivity extends AppCompatActivity {
});
//地图初始化-------------------------------------------------------------------
ArcGISRuntime.setClientId("1eFHW78avlnRUPHm");
mapView = (MapView)findViewById(R.id.map);
mapView = (MapView) findViewById(R.id.map);
mapView.setEsriLogoVisible(false);
mapView.enableWrapAround(false);
......@@ -130,17 +135,21 @@ public class MainActivity extends AppCompatActivity {
mapView.addLayer(t_cia);
mapType = "VEC";
graphicsLayer = new GraphicsLayer();
mapView.addLayer(graphicsLayer);
mapView.setMaxResolution(TDTTileinfo.getRes4490()[1]);
mapView.setMinResolution(TDTTileinfo.getRes4490()[18]);
mapView.setOnStatusChangedListener(new OnStatusChangedListener() {
private static final long serialVersionUID = 1L;
@Override
public void onStatusChanged(Object o, STATUS status) {
if(status == STATUS.INITIALIZED){
if (status == STATUS.INITIALIZED) {
mapView.zoomToResolution(AppInfo.initPoint, AppInfo.initRes);
curLevel= TDTTileinfo.getCurrentLevel(AppInfo.initRes);
mapinfoView.setText("当前地图级别为:"+ String.valueOf(curLevel));
curLevel = TDTTileinfo.getCurrentLevel(AppInfo.initRes);
mapinfoView.setText("当前地图级别为:" + String.valueOf(curLevel));
}
}
});
......@@ -152,11 +161,11 @@ public class MainActivity extends AppCompatActivity {
@Override
public void postAction(float v, float v1, double v2) {
curLevel = TDTTileinfo.getCurrentLevel(mapView.getResolution());
mapinfoView.setText("当前地图级别为:"+ String.valueOf(curLevel));
mapinfoView.setText("当前地图级别为:" + String.valueOf(curLevel));
// t_local只有8和9级数据
if(curLevel > 9 | curLevel <8){
if (curLevel > 9 | curLevel < 8) {
t_local.setVisible(false);
}else{
} else {
t_local.setVisible(true);
}
}
......@@ -186,16 +195,28 @@ public class MainActivity extends AppCompatActivity {
}
});
// 处理浮动查询条
floatingSearchView.setOnSearchListener(new FloatingSearchView.OnSearchListener() {
@Override
public void onSuggestionClicked(SearchSuggestion searchSuggestion) {
graphicsLayer.removeAll();
POISuggestion colorSuggestion = (POISuggestion) searchSuggestion;
Point poipt = new Point(colorSuggestion.getLng(), colorSuggestion.getLat());
mapView.zoomToResolution(poipt, TDTTileinfo.getRes4490()[18]);
graphicsLayer.addGraphic(new Graphic(poipt,
new PictureMarkerSymbol(getResources().getDrawable(R.mipmap.locator)).setOffsetY(16)));
// floatingSearchView.clearSuggestions();
curLevel = TDTTileinfo.getCurrentLevel(mapView.getResolution());
mapinfoView.setText("当前地图级别为:" + String.valueOf(curLevel));
}
@Override
public void onSearchAction(String currentQuery) {
if(currentQuery.length() > 3) {
String str = "{\"keyWord\":\""+ currentQuery +"\",\"level\":\"11\",\"mapBound\":\"76.24832,30.1129,156.40458,49.97618\",\"queryType\":\"1\",\"count\":\"10\",\"start\":\"0\",\"queryTerminal\":\"1000\"}";
if (currentQuery.length() > 3) {
floatingSearchView.clearSuggestions();
String str = "{\"keyWord\":\"" + currentQuery + "\",\"level\":\"11\",\"mapBound\":\"76.24832,30.1129,156.40458,49.97618\",\"queryType\":\"1\",\"count\":\"10\",\"start\":\"0\",\"queryTerminal\":\"1000\"}";
AndroidNetworking.post("http://map.tianditu.com/query.shtml")
.addBodyParameter("type", "query")
.addBodyParameter("postStr", str)
......@@ -207,12 +228,14 @@ public class MainActivity extends AppCompatActivity {
JSONArray Jarray = null;
try {
Jarray = response.getJSONArray("pois");
for (int i = 0; i < Jarray.length(); i++)
{
ArrayList<POISuggestion> poiSuggestions = new ArrayList<POISuggestion>();
for (int i = 0; i < Jarray.length(); i++) {
JSONObject Jasonobject = Jarray.getJSONObject(i);
Log.i("b", Jasonobject.getString("name"));
poiSuggestions.add(new POISuggestion(Jasonobject.getString("name"),
Jasonobject.getString("address"),
Jasonobject.getString("lonlat")));
}
floatingSearchView.swapSuggestions(poiSuggestions);
} catch (JSONException e) {
e.printStackTrace();
}
......@@ -226,25 +249,13 @@ public class MainActivity extends AppCompatActivity {
}
}
});
// floatingSearchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() {
// @Override
// public void onSearchTextChanged(String oldQuery, String newQuery) {
// if (!oldQuery.equals("") && newQuery.equals("")) {
// floatingSearchView.clearSuggestions();
// } else{
// if(newQuery.length()>3){
//
// }
// }
// }
// });
}
@Override
public void onResume() {
super.onResume();
mapView.unpause();
if(locationDisplayManager!=null){
if (locationDisplayManager != null) {
locationDisplayManager.resume();
}
}
......@@ -253,7 +264,7 @@ public class MainActivity extends AppCompatActivity {
public void onPause() {
super.onPause();
mapView.pause();
if(locationDisplayManager!=null){
if (locationDisplayManager != null) {
locationDisplayManager.pause();
}
}
......@@ -261,7 +272,7 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onStop() {
super.onStop();
if(locationDisplayManager!=null){
if (locationDisplayManager != null) {
locationDisplayManager.stop();
}
......@@ -283,10 +294,10 @@ public class MainActivity extends AppCompatActivity {
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
if(mapType == "VEC"){
if (mapType == "VEC") {
setLayer("IMG");
mapType = "IMG";
}else{
} else {
setLayer("VEC");
mapType = "VEC";
}
......@@ -297,8 +308,8 @@ public class MainActivity extends AppCompatActivity {
}
// 切换地图形式
private void setLayer(String type){
switch (type){
private void setLayer(String type) {
switch (type) {
case "VEC":
t_vec.setVisible(true);
t_cva.setVisible(true);
......
package com.pashanhoo.landsurvey.search;
import android.content.Context;
import android.support.v4.view.AsyncLayoutInflater;
import android.widget.Filter;
import com.arlib.floatingsearchview.FloatingSearchView;
/**
* Created by jiangbotao on 2018/3/27.
*/
public class DataHelper {
public interface OnFindSuggestionsListener {
void onResults(String[] results);
}
public static void findSuggestions(FloatingSearchView.OnQueryChangeListener context, String query, final int limit, final long simulatedDelay, final OnFindSuggestionsListener listener){
new Filter(){
@Override
protected FilterResults performFiltering(CharSequence constraint) {
try {
Thread.sleep(simulatedDelay);
} catch (InterruptedException e) {
e.printStackTrace();
}
FilterResults results = new FilterResults();
return results;
}
@Override
protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
}
}.filter(query);
}
}
package com.pashanhoo.landsurvey.search;
import android.annotation.SuppressLint;
import android.os.Parcel;
import com.arlib.floatingsearchview.suggestions.model.SearchSuggestion;
/**
* Created by jiangbotao on 2018/3/27.
*/
@SuppressLint("ParcelCreator")
public class POISuggestion implements SearchSuggestion {
private String name;
private String address;
private float lng;
private float lat;
private boolean mIsHistory = false;
public POISuggestion(String suggestion){
this.name = suggestion.toLowerCase();
}
public POISuggestion(String name, String address, String lonlat){
this.name = name;
this.address = address;
String[] position = lonlat.split(" ");
this.lng = Float.parseFloat((position[0]));
this.lat = Float.parseFloat(position[1]);
}
public POISuggestion(Parcel source) {
this.name = source.readString();
this.mIsHistory = source.readInt() != 0;
}
public void setIsHistory(boolean isHistory) {
this.mIsHistory = isHistory;
}
public boolean getIsHistory() {
return this.mIsHistory;
}
@Override
public String getBody() {
return name;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(name);
parcel.writeInt(mIsHistory ? 1 : 0);
}
public static final Creator<POISuggestion> CREATOR = new Creator<POISuggestion>() {
@Override
public POISuggestion createFromParcel(Parcel in) {
return new POISuggestion(in);
}
@Override
public POISuggestion[] newArray(int size) {
return new POISuggestion[size];
}
};
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public float getLng() {
return lng;
}
public void setLng(long lng) {
this.lng = lng;
}
public float getLat() {
return lat;
}
public void setLat(long lat) {
this.lat = lat;
}
}
......@@ -33,6 +33,7 @@
app:floatingSearch_searchHint="地名地址检索..."
app:floatingSearch_suggestionsListAnimDuration="250"
app:floatingSearch_showSearchKey="false"
app:floatingSearch_leftActionMode="showSearch"
app:floatingSearch_menu="@menu/menu_main"
app:floatingSearch_close_search_on_keyboard_dismiss="true"/>
......