nasersobhan

Add points from JSON file?

Discussion created by nasersobhan on Jun 25, 2014
hi guys,
I need to load Points from a JSON file and put the points on the map, can you please check my function.

  this.pointLayer.removeAll();
     try
     {
       JSONArray localJSONArray = new JSONObject(paramString).getJSONArray("points");
       for (int i = 0;; i++)
       {
         if (i >= localJSONArray.length())
         {
       
           return;
         }
         String str = localJSONArray.getJSONObject(i).getString("name");
         Double localDouble1 = Double.valueOf(localJSONArray.getJSONObject(i).getDouble("lat"));
         Double localDouble2 = Double.valueOf(localJSONArray.getJSONObject(i).getDouble("lon"));
         Point localPoint = Utils.MakeWebMapPoint(new Point(localDouble1.doubleValue(), localDouble2.doubleValue()));
         HashMap localHashMap = new HashMap();
         localHashMap.put("name", str);
         Graphic localGraphic = new Graphic(localPoint, PointMarker());
         this.pointLayer.addGraphic(localGraphic);
       }
       //return;
     }
     catch (JSONException localJSONException)
     {
       localJSONException.printStackTrace();
   
     }



paramString is the link of the file.

thanks

Outcomes