Fill Mapview with bookmarks from Json with Retrofit (Help)

0

I am working on an app that fills a MapView with markers brought from a Web Service using Retrofit, and I have been trying to create a method to add all the markers from Json to the MapView, but it only adds 1, Does anyone know in that Could I be failing or am I missing? It should be noted that when I try to show them to me by console it does it without problems.

This is the Json link: link

Marker Method:

private void cargarMarcadores() {
        markerService = retrofit.create (CoordenadaService.class);
        Call<CoordenadaRespuesta> call = markerService.obtenerMarcadores ();
        call.enqueue (new Callback<CoordenadaRespuesta> () {
            @Override
            public void onResponse(@NonNull Call<CoordenadaRespuesta> call, @NonNull Response<CoordenadaRespuesta> response) {
                if (response.isSuccessful ()) {
                    try {
                        CoordenadaRespuesta coordenadaRespuesta = response.body ();
                        listaMarker = Objects.requireNonNull (coordenadaRespuesta).getData ();

                    for (int i = 0; i<listaMarker.size (); i++){
                        Coordenada I = listaMarker.get (i);
//                        Log.i (TAG," Local Latitud: " + I.getLatitud ());
//                        Log.i(TAG, " Local Longitud: " + I.getLongitud ());
                        Double lat = Double.parseDouble (I.getLatitud ());
                        Double lng = Double.parseDouble (I.getLongitud ());
                        String title = I.getNombreEmpresa ();
                        MarkerOptions markerOptions = new MarkerOptions();
                        LatLng latLng = new LatLng(lat, lng);
                        markerOptions.position (latLng);
                        markerOptions.title (title);
                        markerOptions.icon (BitmapDescriptorFactory.fromResource (R.drawable.mini_logo_marker));
                        Marker m = mGoogleMap.addMarker (markerOptions);
                    }

                    } catch (Exception e) {
                        Log.d (TAG_ERROR, "Hay un error");
                        e.printStackTrace ();
                    }
                } else {
                    Log.i (TAG,"El metodo try ha fallado: " + response.errorBody ());
                }
            }

            @Override
            public void onFailure(Call<CoordenadaRespuesta> call, Throwable t) {
                Log.i (TAG,"Hay un error en la respuesta: " + t.getMessage ());
            }
        });
    }

Thanks in advance

    
asked by Wilberth Rosas 08.12.2018 в 22:27
source

0 answers