I want to read latitude and longitude from json, the json file looks like this, and get plot the latitude and longitude on the google map in android. The latitude is name and longitude is country.
[{"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"},{"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"},{"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"},{"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"},{"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"},{"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"},{"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"}]
Here is my android maps code.
public class Maps extends Activity {
private static String url = "http://ift.tt/1kpxaCr";
static final LatLng College = new LatLng(13.1172245 , 77.6341758);
private GoogleMap googleMap;
float lat,lon;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maps);
try {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(College, 15));
}
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
@SuppressWarnings("unused")
Marker TP = googleMap.addMarker(new MarkerOptions().position(College).title("Revamp 15,click on the arrow below for directions"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
How should i replace the static final LatLng College = new LatLng(13.1172245 , 77.6341758); witht the json data ?
Aucun commentaire:
Enregistrer un commentaire