コード例 #1
0
ファイル: ParserTask.java プロジェクト: gtemta/ACOplanner
  // Parsing the data in non-ui thread
  @Override
  protected List<List<HashMap<String, String>>> doInBackground(String... jsonData) {

    JSONObject jObject;
    int ptdistance = 0;
    List<List<HashMap<String, String>>> routes = null;

    try {
      jObject = new JSONObject(jsonData[0]);
      DirectionsJSONParser mParser;
      mParser = new DirectionsJSONParser();

      // Starts parsing data

      routes = mParser.parse(jObject);
      ptdistance = mParser.getjsonDis();
      Log.i("distance", Integer.toString(ptdistance) + "               ParserTask distance");
    } catch (Exception e) {
      e.printStackTrace();
    }
    dis = ptdistance;
    Log.i("distance", Integer.toString(dis) + "        ParserTaskOutOfCatch");
    GlobalVariable.dis[i][j] = dis;
    GlobalVariable.doingnum += 1;
    return routes;
  }
コード例 #2
0
ファイル: VetFirstActivity.java プロジェクト: gkffzs/TAVOO
 protected void onPostExecute(String result) {
   try {
     jObject = new JSONObject(result);
     DirectionsJSONParser parser = new DirectionsJSONParser();
     routes = parser.parseFeed(jObject);
     Log.d("VetFirstActivity", "successfully parsed routes data");
   } catch (JSONException e) {
     e.printStackTrace();
   }
   drawRoute(routes);
 }
コード例 #3
0
    // Parsing the data in non-ui thread
    @Override
    protected List<List<HashMap<String, String>>> doInBackground(String... jsonData) {

      JSONObject jObject;
      List<List<HashMap<String, String>>> routes = null;

      try {
        jObject = new JSONObject(jsonData[0]);
        DirectionsJSONParser parser = new DirectionsJSONParser();

        // Starts parsing data
        routes = parser.parse(jObject);
      } catch (Exception e) {
        e.printStackTrace();
      }
      return routes;
    }
コード例 #4
0
  private void getMap(String json) {
    Log.d("TAG", "getMap");
    JSONObject jObject;
    List<List<HashMap<String, String>>> result = null;
    ArrayList<LatLng> points = null;
    PolylineOptions lineOptions = null;
    try {
      Log.d("TAG", "TAG");
      jObject = new JSONObject(json);
      DirectionsJSONParser parser = new DirectionsJSONParser();
      // parse出畫在地圖上的經緯度組
      result = parser.parse(jObject);

      Log.d("TAG", "routes=" + String.valueOf(result.size()));
    } catch (JSONException e) {
      e.printStackTrace();
    }

    try {

      lineOptions = new PolylineOptions();
      // Fetching all the points in all routes,用2層迴圈
      Log.d("TAG", "000");
      // 假設印出第一條路
      points = new ArrayList<LatLng>();
      for (int e = 0; e < result.get(0).size(); e++) {
        HashMap<String, String> point = result.get(0).get(e);
        double Lat = Double.parseDouble(point.get("lat"));
        double Lng = Double.parseDouble(point.get("lng"));
        LatLng p = new LatLng(Lat, Lng);
        points.add(p);
      }
    } catch (NullPointerException e) {
      e.printStackTrace();
    }
    lineOptions.addAll(points);
    lineOptions.width(8);
    lineOptions.color(Color.RED);
    Log.d("TAG", "mapmove_end");
    map.addPolyline(lineOptions);
  }