update 3.27
Showing
3 changed files
with
58 additions
and
6 deletions
| ... | @@ -27,6 +27,7 @@ dependencies { | ... | @@ -27,6 +27,7 @@ dependencies { |
| 27 | compile 'com.esri.arcgis.android:arcgis-android:10.2.9' | 27 | compile 'com.esri.arcgis.android:arcgis-android:10.2.9' |
| 28 | compile 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar' | 28 | compile 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar' |
| 29 | compile 'com.github.arimorty:floatingsearchview:2.1.1' | 29 | compile 'com.github.arimorty:floatingsearchview:2.1.1' |
| 30 | compile 'com.amitshekhar.android:android-networking:0.2.0' | ||
| 30 | 31 | ||
| 31 | implementation fileTree(dir: 'libs', include: ['*.jar']) | 32 | implementation fileTree(dir: 'libs', include: ['*.jar']) |
| 32 | //noinspection GradleCompatible | 33 | //noinspection GradleCompatible | ... | ... |
| ... | @@ -12,7 +12,12 @@ import android.view.Menu; | ... | @@ -12,7 +12,12 @@ import android.view.Menu; |
| 12 | import android.view.MenuItem; | 12 | import android.view.MenuItem; |
| 13 | import android.widget.TextView; | 13 | import android.widget.TextView; |
| 14 | 14 | ||
| 15 | import com.androidnetworking.AndroidNetworking; | ||
| 16 | import com.androidnetworking.error.ANError; | ||
| 17 | import com.androidnetworking.interfaces.JSONArrayRequestListener; | ||
| 18 | import com.androidnetworking.interfaces.JSONObjectRequestListener; | ||
| 15 | import com.arlib.floatingsearchview.FloatingSearchView; | 19 | import com.arlib.floatingsearchview.FloatingSearchView; |
| 20 | import com.arlib.floatingsearchview.suggestions.model.SearchSuggestion; | ||
| 16 | import com.esri.android.map.LocationDisplayManager; | 21 | import com.esri.android.map.LocationDisplayManager; |
| 17 | import com.esri.android.map.MapView; | 22 | import com.esri.android.map.MapView; |
| 18 | import com.esri.android.map.event.OnStatusChangedListener; | 23 | import com.esri.android.map.event.OnStatusChangedListener; |
| ... | @@ -26,6 +31,10 @@ import com.pashanhoo.landsurvey.layers.tianditu.TianDiTuTiledMapServiceType; | ... | @@ -26,6 +31,10 @@ import com.pashanhoo.landsurvey.layers.tianditu.TianDiTuTiledMapServiceType; |
| 26 | import com.pashanhoo.landsurvey.search.DataHelper; | 31 | import com.pashanhoo.landsurvey.search.DataHelper; |
| 27 | import com.pashanhoo.landsurvey.utils.AppInfo; | 32 | import com.pashanhoo.landsurvey.utils.AppInfo; |
| 28 | 33 | ||
| 34 | import org.json.JSONArray; | ||
| 35 | import org.json.JSONException; | ||
| 36 | import org.json.JSONObject; | ||
| 37 | |||
| 29 | public class MainActivity extends AppCompatActivity { | 38 | public class MainActivity extends AppCompatActivity { |
| 30 | 39 | ||
| 31 | private MapView mapView; | 40 | private MapView mapView; |
| ... | @@ -177,16 +186,58 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -177,16 +186,58 @@ public class MainActivity extends AppCompatActivity { |
| 177 | } | 186 | } |
| 178 | }); | 187 | }); |
| 179 | 188 | ||
| 180 | floatingSearchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() { | 189 | floatingSearchView.setOnSearchListener(new FloatingSearchView.OnSearchListener() { |
| 181 | @Override | 190 | @Override |
| 182 | public void onSearchTextChanged(String oldQuery, String newQuery) { | 191 | public void onSuggestionClicked(SearchSuggestion searchSuggestion) { |
| 183 | if (!oldQuery.equals("") && newQuery.equals("")) { | 192 | |
| 184 | floatingSearchView.clearSuggestions(); | 193 | } |
| 185 | } else{ | 194 | |
| 195 | @Override | ||
| 196 | public void onSearchAction(String currentQuery) { | ||
| 197 | if(currentQuery.length() > 3) { | ||
| 198 | String str = "{\"keyWord\":\""+ currentQuery +"\",\"level\":\"11\",\"mapBound\":\"76.24832,30.1129,156.40458,49.97618\",\"queryType\":\"1\",\"count\":\"10\",\"start\":\"0\",\"queryTerminal\":\"1000\"}"; | ||
| 199 | AndroidNetworking.post("http://map.tianditu.com/query.shtml") | ||
| 200 | .addBodyParameter("type", "query") | ||
| 201 | .addBodyParameter("postStr", str) | ||
| 202 | .setTag("test") | ||
| 203 | .build() | ||
| 204 | .getAsJSONObject(new JSONObjectRequestListener() { | ||
| 205 | @Override | ||
| 206 | public void onResponse(JSONObject response) { | ||
| 207 | JSONArray Jarray = null; | ||
| 208 | try { | ||
| 209 | Jarray = response.getJSONArray("pois"); | ||
| 210 | for (int i = 0; i < Jarray.length(); i++) | ||
| 211 | { | ||
| 212 | JSONObject Jasonobject = Jarray.getJSONObject(i); | ||
| 213 | Log.i("b", Jasonobject.getString("name")); | ||
| 214 | |||
| 215 | } | ||
| 216 | } catch (JSONException e) { | ||
| 217 | e.printStackTrace(); | ||
| 218 | } | ||
| 219 | } | ||
| 220 | |||
| 221 | @Override | ||
| 222 | public void onError(ANError anError) { | ||
| 186 | 223 | ||
| 224 | } | ||
| 225 | }); | ||
| 187 | } | 226 | } |
| 188 | } | 227 | } |
| 189 | }); | 228 | }); |
| 229 | // floatingSearchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() { | ||
| 230 | // @Override | ||
| 231 | // public void onSearchTextChanged(String oldQuery, String newQuery) { | ||
| 232 | // if (!oldQuery.equals("") && newQuery.equals("")) { | ||
| 233 | // floatingSearchView.clearSuggestions(); | ||
| 234 | // } else{ | ||
| 235 | // if(newQuery.length()>3){ | ||
| 236 | // | ||
| 237 | // } | ||
| 238 | // } | ||
| 239 | // } | ||
| 240 | // }); | ||
| 190 | } | 241 | } |
| 191 | 242 | ||
| 192 | @Override | 243 | @Override | ... | ... |
| ... | @@ -29,10 +29,10 @@ | ... | @@ -29,10 +29,10 @@ |
| 29 | android:layout_height="match_parent" | 29 | android:layout_height="match_parent" |
| 30 | android:layout_marginTop="70dp" | 30 | android:layout_marginTop="70dp" |
| 31 | android:layout_marginLeft="16dp" | 31 | android:layout_marginLeft="16dp" |
| 32 | android:layout_marginBottom="16dp" | ||
| 32 | app:floatingSearch_searchHint="地名地址检索..." | 33 | app:floatingSearch_searchHint="地名地址检索..." |
| 33 | app:floatingSearch_suggestionsListAnimDuration="250" | 34 | app:floatingSearch_suggestionsListAnimDuration="250" |
| 34 | app:floatingSearch_showSearchKey="false" | 35 | app:floatingSearch_showSearchKey="false" |
| 35 | app:floatingSearch_leftActionMode="showHamburger" | ||
| 36 | app:floatingSearch_menu="@menu/menu_main" | 36 | app:floatingSearch_menu="@menu/menu_main" |
| 37 | app:floatingSearch_close_search_on_keyboard_dismiss="true"/> | 37 | app:floatingSearch_close_search_on_keyboard_dismiss="true"/> |
| 38 | 38 | ... | ... |
-
Please register or sign in to post a comment