Add multiple markers on Google Map from JSON response

Viewed 4855

Json response:

{"status":true,"message":"Successfully Alert Message","Data":[{"longitude":"70.7652417","latitude":"22.2889975","alert_message":"abcd"},{"longitude":"70.7652417","latitude":"22.2888975","alert_message":"pqr",},{longitude":"70.7662417","latitude":"22.2898975","alert_message":"xyz"}]}

What I have done:

arraylist = parseContent.getUsers(response);
adapter = new ListViewAdapter(getApplicationContext(), arraylist);
Log.d("typelist", arraylist.toString());
lv.setAdapter(adapter);

for (int i =0;i<arraylist.size();i++)
{
    longitude1 = arraylist.get(i).get("longitude");
    latitude1 = arraylist.get(i).get("latitude");

    // MarkerOptions mp = new MarkerOptions();

    Double long1= Double.parseDouble(longitude1);
    Double lat1= Double.parseDouble(latitude1);

    /* mp.position(new LatLng(long1,lat1));
    mp.title("my position");
    googleMap.addMarker(mp);*/
    /*  Marker marker =  googleMap.addMarker(new MarkerOptions()
        .position(new LatLng(long1, lat1))
        .title("Hello world")
        .icon(BitmapDescriptorFactory.fromResource(R.drawable.flag)));*/
    // marker.add(marker);
    // arraylist.add(marker);
    // googleMap.addMarker(marker);

    googleMap.addMarker(new MarkerOptions().position(new LatLng(long1, lat1)));
    Log.e("PlaceLL",lat1+" "+long1);
}

Latitude and longitude I am getting:

LL: 22.2889975 70.7652417
LL: 22.2888975 70.7652417
LL: 22.2898975 70.7662417

What I want is to put multiple markers with place name on Google Map, from my JSON response. But I am not able to place markers.

3 Answers
Related