title: how to mark latitude and longitude on google map from an online json
body: <p>I want to read latitude and longitude from json(online), the json file looks like this.<b>The latitude is name and longitude is country.</b></p>
  
  <pre><code>[
    {
      "name": "13.0714562",
      "country": "77.55946348",
      "twitter": "Current Location"
    },
    {
      "name": "13.0714562",
      "country": "77.55946348",
      "twitter": "Current Location"
    },
    {
      "name": "13.0714562",
      "country": "77.55946348",
      "twitter": "Current Location"
    },
  
    ...................
  
  ]
  </code></pre>
  
  <p>I want to plot the latitude and longitude on the google map in android by the above json. </p>
  
  <p>The url for json is:- <a href="http://hmkcode.appspot.com/jsonservlet" rel="nofollow">http://hmkcode.appspot.com/jsonservlet</a></p>
  
  <p>I am trying to use asynctask to download the json. Below is my android code.</p>
  
  <pre><code>public class Maps extends Activity {
      private ProgressDialog pDialog;
      private static String url = "http://hmkcode.appspot.com/jsonservlet";
      private static final String latitude = "name";
      private static final String longitude = "country";
      private GoogleMap googleMap;
      float lat, lon;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.maps);
          new GetMap().execute();
      }
  
      private class GetMap extends AsyncTask&lt;Void, Void, Void&gt; {
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              // Showing progress dialog
              pDialog = new ProgressDialog(Maps.this);
              pDialog.setMessage("Please wait...");
              pDialog.setCancelable(false);
              pDialog.show();
          }
  
          @Override
          protected Void doInBackground(Void... arg0) {
              // Creating service handler class instance
              ServiceHandler sh = new ServiceHandler();
  
              // Making a request to url and getting response
              String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
  
              Log.d("Response: ", "&gt; " + jsonStr);
  
              if (jsonStr != null) {
                  try {
                      JSONArray jsonArr = new JSONArray(jsonStr);
                      for (int i = 0; i &lt; jsonArr.length(); i++) {
                          JSONObject c = jsonArr.getJSONObject(i);
  
                          String name = c.getString(latitude);
                          String time = c.getString(longitude);
                          double LAT = Double.parseDouble(name);
                          double LON = Double.parseDouble(time);
                          final LatLng Marker = new LatLng(LAT, LON);
                      }
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              } else {
                  Log.e("ServiceHandler", "Couldn't get any data from the url");
              }
  
              return null;
          }
  
          @Override
          protected void onPostExecute(Void result) {
              super.onPostExecute(result);
              // Dismiss the progress dialog
              if (pDialog.isShowing())
                  pDialog.dismiss();
              try {
                  if (googleMap == null) {
                      googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
                      googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(Marker, 15));
                      @SuppressWarnings("unused")
                      Marker TP = googleMap.addMarker(new MarkerOptions().position(Marker).title("Revamp 15,click on the arrow below for directions"));
                  }
  
                  googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
  
                  @SuppressWarnings("unused")
                  Marker TP = googleMap.addMarker(new MarkerOptions().position(Marker).title("Revamp 15,click on the arrow below for directions"));
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }
  }
  </code></pre>
  
  <p>But I get an error in <b>onPostExecute</b> part of asynctask that <b> Marker cannot be resolved to a variable.</b> So I tried to intialize marker by null. If I do that the json does not get loaded in to the Marker variable.</p>
  
  <p>How can I load the json in Marker Variable?</p>