I have a URL which contains a lot of LatLng . I have to parse all of them and display marker on Google Map I am new in Android. So please help me.
My JSON URL is here - JSON URL for LatLng
and my code is to fetch data is
public class AsyncTaskParseJson extends AsyncTask<String, String, String> {
final String TAG = "AsyncTaskParseJson.java";
// set your json string url here
String yourJsonStringUrl = "http://djs-corner.appspot.com/getClosestClubs?lat=40.7600624&lon=-73.98558";
// contacts JSONArray
JSONArray dataJsonArr = null;
@Override
protected void onPreExecute() {}
@Override
protected String doInBackground(String... arg0) {
try {
// instantiate our json parser
JsonParser jParser = new JsonParser();
// get json string from url
JSONObject json = jParser.getJSONFromUrl(yourJsonStringUrl);
// get the array of users
dataJsonArr = json.getJSONArray("0");
// loop through all users
for (int i = 0; i < dataJsonArr.length(); i++) {
JSONObject c = dataJsonArr.getJSONObject(i);
// Storing each json item in variable
String zip= c.getString("zip");
String lattitude= c.getString("lat");
String longitude= c.getString("lng");
// show the values in our logcat
Log.e(TAG, "Zip: " + zip
+ ", Lattitude: " + lat
+ ", Longitude: " + lng);
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String strFromDoInBg) {}
}
}