Select to view content in your preferred language

Add points from JSON file?

2457
0
06-25-2014 07:52 PM
Mohammad_NaserSobhan_Noorzai
Emerging Contributor
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
0 Kudos
0 Replies