How do I add bookmarks to my map dynamically?

1

Well guys, I'm developing a mobile application in AS, and I'm using the map to add markers to each location of a new registered form, that is, when I make a registration, I send my latitude and longitude to the server together. On the map I get this list of objects passing latitude and longitude and I try to add markers to these positions, but I can not do this dynamically. Can anyone help me?

The code that generates the map with the object's locations:

private void gerarMapa(){

    for(int i = 0; i < palhetas.size(); i++) {
        double lat = Double.parseDouble( palhetas.get(i).getEndereco().getLatitude() );
        double lon = Double.parseDouble( palhetas.get(i).getEndereco().getLongitude() );
        LatLng locale = new LatLng( lat, lon );

        MarkerOptions options = new MarkerOptions()
                .position( locale )
                .title( palhetas.get(i).getCodigo() )
                .snippet( palhetas.get(i).getEndereco().getRua() )
                .icon( BitmapDescriptorFactory
                        .fromResource( R.drawable.marker ) );
        mMap.addMarker( options );
        mMap.moveCamera( CameraUpdateFactory.newLatLng( locale ) );
    }
}

The way it is, it just marks the location of the first object. Another problem I have is to get the location of the object, I need to first convert it to double, because my object is bringing via gson.

Gson gson = new Gson();
Type usuariosListType = new TypeToken<ArrayList<Palheta>>(){}.getType();
palhetas = gson.fromJson(response, usuariosListType);
    
asked by anonymous 16.01.2018 / 18:27

0 answers