|
77 | 77 | import org.json.JSONObject;
|
78 | 78 |
|
79 | 79 | import java.io.IOException;
|
| 80 | +import java.io.InputStream; |
80 | 81 | import java.security.SecureRandom;
|
81 | 82 | import java.security.cert.X509Certificate;
|
82 | 83 | import java.util.ArrayList;
|
@@ -238,7 +239,9 @@ public boolean verify(String arg0, SSLSession arg1) {
|
238 | 239 | public void onResume() {
|
239 | 240 | super.onResume();
|
240 | 241 | // put your code here...
|
241 |
| - GetDataForMap(); |
| 242 | + GetDataForMap(); //Load from server |
| 243 | + /*loadJSONFromAsset(); |
| 244 | + ParseJSONFromAsset();*/ |
242 | 245 | setupMapIfNeeded();
|
243 | 246 |
|
244 | 247 | }
|
@@ -290,7 +293,7 @@ public void onMapReady(GoogleMap googleMap) {
|
290 | 293 | mGoogleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
|
291 | 294 | @Override
|
292 | 295 | public boolean onMarkerClick(Marker marker) {
|
293 |
| - showDialogProject(marker.getSnippet(),marker.getTitle()); |
| 296 | + showDialogProject(marker.getSnippet(), marker.getTitle()); |
294 | 297 | return false;
|
295 | 298 | }
|
296 | 299 | });
|
@@ -522,14 +525,65 @@ public void onPointerCaptureChanged(boolean hasCapture) {
|
522 | 525 |
|
523 | 526 | }
|
524 | 527 |
|
| 528 | + public void ParseJSONFromAsset() { |
| 529 | + try { |
| 530 | + JSONObject obj = new JSONObject(loadJSONFromAsset()); |
| 531 | + JSONArray m_jArry = obj.getJSONArray("route_data"); |
| 532 | + Log.e("Details-->", String.valueOf(m_jArry)); |
| 533 | + proPlaceListRoute = new ArrayList<>(); |
| 534 | + |
| 535 | + for (int i = 0; i < m_jArry.length(); i++) { |
| 536 | + JSONObject jo_inside = m_jArry.getJSONObject(i); |
| 537 | + PlaceModel placeModel = new PlaceModel(); |
| 538 | + placeModel.id = jo_inside.getString("id"); |
| 539 | + placeModel.bde_id = jo_inside.getString("bde_id"); |
| 540 | + placeModel.route_id = jo_inside.getString("route_id"); |
| 541 | + placeModel.sequence_id = jo_inside.getString("sequence_id"); |
| 542 | + placeModel.name = jo_inside.getString("name"); |
| 543 | + placeModel.latitude = jo_inside.getString("latitude"); |
| 544 | + placeModel.longitude = jo_inside.getString("longitude"); |
| 545 | + placeModel.isDeleted = jo_inside.getString("isDeleted"); |
| 546 | + placeModel.branchAssigned = jo_inside.getString("branchAssigned"); |
| 547 | + placeModel.city = jo_inside.getString("city"); |
| 548 | + placeModel.state = jo_inside.getString("state"); |
| 549 | + placeModel.contactPerson = jo_inside.getString("contactPerson"); |
| 550 | + placeModel.mobile = jo_inside.getString("mobile"); |
| 551 | + placeModel.phone = jo_inside.getString("phone"); |
| 552 | + placeModel.email = jo_inside.getString("email"); |
| 553 | + placeModel.category = jo_inside.getString("category"); |
| 554 | + placeModel.photo = jo_inside.getString("photo"); |
| 555 | + |
| 556 | + |
| 557 | + proPlaceListRoute.add(placeModel); |
| 558 | + } |
| 559 | + On_Data_Map(); |
| 560 | + } catch (JSONException e) { |
| 561 | + Log.e(TAG, "ParseJSONFromAsset: "+e.toString() ); |
| 562 | + } |
| 563 | + } |
| 564 | + |
| 565 | + public String loadJSONFromAsset() { |
| 566 | + String json = null; |
| 567 | + try { |
| 568 | + InputStream is = getAssets().open("polyline_data.json"); |
| 569 | + int size = is.available(); |
| 570 | + byte[] buffer = new byte[size]; |
| 571 | + is.read(buffer); |
| 572 | + is.close(); |
| 573 | + json = new String(buffer, "UTF-8"); |
| 574 | + } catch (IOException ex) { |
| 575 | + ex.printStackTrace(); |
| 576 | + return null; |
| 577 | + } |
| 578 | + return json; |
| 579 | + } |
525 | 580 |
|
526 | 581 | public void GetDataForMap() {
|
527 | 582 | final ProgressDialog progressDialog = new ProgressDialog(PolyLineMapsActivity.this);
|
528 | 583 | progressDialog.setCancelable(false);
|
529 | 584 | progressDialog.setMessage("Loading..");
|
530 | 585 | progressDialog.show();
|
531 |
| - String FatchPlaceByRoute = "https://myjson.dit.upm.es/api/bins/4ld3"; |
532 |
| - //String FatchPlaceByRoute = "http://myjson.dit.upm.es/api/bins/2nx3"; |
| 586 | + String FatchPlaceByRoute = "https://pixeldev.in/webservices/json_file/polyline_data.json"; |
533 | 587 | StringRequest stringRequest = new StringRequest(Request.Method.GET, FatchPlaceByRoute, new Response.Listener<String>() {
|
534 | 588 | @Override
|
535 | 589 | public void onResponse(String response) {
|
@@ -718,7 +772,7 @@ private Bitmap getMarkerBitmapFromView(@DrawableRes int resId, String tittle) {
|
718 | 772 |
|
719 | 773 | Dialog dialog_details;
|
720 | 774 |
|
721 |
| - private void showDialogProject(String someid,String subtitle) { |
| 775 | + private void showDialogProject(String someid, String subtitle) { |
722 | 776 | dialog_details = new Dialog(this);
|
723 | 777 | dialog_details.requestWindowFeature(Window.FEATURE_NO_TITLE); // before
|
724 | 778 | dialog_details.setContentView(R.layout.dialog_info);
|
|
0 commit comments