Tengo el siguiente arraylist
: Polylines,el arraylist
tiene 190 elementos, el cual al compilar me genera el siguiente error:
error: code too large
Según lo que investigue es un error de java, pero no sé como solucionarlo, espero puedan ayudarme
edit:
Aquí dejo la clase:
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
ArrayList<FormatoPolyline> Poly=new ArrayList<>();
String previus;
Polyline line;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
previus="";
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
int height = 50;
int width = 50;
BitmapDrawable bitmapdraw = (BitmapDrawable) getResources().getDrawable(R.drawable.marker);
Bitmap b = bitmapdraw.getBitmap();
Bitmap smallMarker = Bitmap.createScaledBitmap(b, width, height, false);
marcadores(mMap,smallMarker);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-33.502482,-70.573841), 15f));
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
Polylines(mMap,marker.getTitle());
return false;
}
});
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
if(line!=null) {
line.remove();
line=null;
Log.d("Polyline","no es nula");
}else {
Log.d("Polyline","es nula");
}
}
});
}
public int getRandomColor(){
Random rnd = new Random();
return Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
}
public void Polylines(GoogleMap map, String ruta){
lineas();
PolylineOptions polylineOptions = new PolylineOptions();
if(line!=null) {
line.remove();
line=null;
Log.d("Polyline","no es nula");
}
for(int i=0;i<Poly.size();i++){
polylineOptions=null;
if (Poly.get(i).getTitulo().equals(ruta)){
polylineOptions=Poly.get(i).getLine();
break;
}
}
polylineOptions.width(8).color(getRandomColor()).geodesic(true).clickable(false);
line = map.addPolyline(polylineOptions);
Log.d("puntos",""+line.getPoints());
Log.d("tamaño",""+line.getPoints().size());
}
public void lineas(){
// aqui va el arraylist, el link esta en la pregunta, no puedo publicar una pregunta con tanto texto
}
public void marcadores(GoogleMap map, Bitmap smallMarker){
map.addMarker(new MarkerOptions().position(new LatLng(-33.510449,-70.742893)).title("5 de Abril / Esquina Blanca").snippet("Vereda y bandejón / Bidireccional / Primera Transversal a Concepción del Oro ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.472688,-70.72111)).title("5 de Abril / Parque por Simón Bolívar").snippet("Bandejón / Bidireccional / Vostok a Las Torres ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.460697,-70.716328)).title("Alameda / Pajaritos").snippet("Bandejón y Calle / Bidireccional / Teatinos a Escr. Jorge Inostroza ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.516518,-70.755622)).title("Alberto Llona").snippet("Vereda / Bidireccional / Vicente Reyes a 5 de Abril ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.457891,-70.669612)).title("Almirante Blanco Encalada").snippet("Calle / Bidireccional / Club Hípico a San Alfonso ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.6148516,-70.6874084)).title("Almirante Riveros").snippet("Bandejón y Vereda / Bidireccional / Padre Hurtado a Portales oriente").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.4405378,-70.5177802)).title("Alvaro Casanova").snippet("Vía Ciclística (Calle) / Bidireccional / Valenzuela Pulema a Alcalde Fernando Castillo Velasco ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.442017,-70.612768)).title("Antonio Varas").snippet("Calle y Vereda / Bidireccional / Nueva Providencia a Irarrázaval ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.411492,-70.630575)).title("Arzobispo Valdivieso").snippet("Vereda / Bidireccional / Comandante Véliz a Ocho Norte ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.5825107,-70.6341505)).title("Baldomero Lillo").snippet("Vereda / Bidireccional / Aníbal Pinto a Andrés Bello").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.603182,-70.7019353)).title("Barros Arana").snippet("Vereda / Bidireccional / Ramón Liborio a Esmeralda ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.346124,-70.728705)).title("Bernardo OHiggins").snippet("Bandejón / Bidireccional / Colbún a San Ignacio ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.43618,-70.664602)).title("Brasil").snippet("Calle / Bidireccional / Huérfanos a Mapocho ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.625698,-70.780365)).title("Calera De Tango / Manuel Castillo").snippet("Vereda / Bidireccional / Los Almendros a Autopista Del Sol ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.558337,-70.615721)).title("Callao").snippet("Calle / Bidireccional / Alcántara a Sánchez Fontecilla ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.6003962,-70.7806125)).title("Calle 2").snippet("Vereda / Bidireccional / Camino a Lonquén a Calle 2 ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.41897,-70.596611)).title("Calle G").snippet("Bandejón / Bidireccional / Juan Cristóbal a Juan Muñoz ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.6404369,-70.8165622)).title("Camino a Lonquén").snippet("Vereda / Bidireccional / Fuente Bella a Carampangue ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.377763,-70.655048)).title("Camino a Melipilla / Pedro Aguirre Cerda").snippet("Calle y vereda / Bidireccional / Avenida Cuatro a Esquina Blanca ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.4133171,-70.846045)).title("Camino a Noviciado").snippet("Calle / Bidireccional / Ruta 68 a Puente El Noviciado ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.6238216,-70.7570601)).title("Camino Catemito (a)").snippet("Vereda / Bidireccional / Calera De Tango a San Agustín ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.6086507,-70.7206249)).title("Camino Catemito (b)").snippet("Vereda / Bidireccional / Pdte. Jorge Alessandri Rodríguez a Universidad Santo Tomás ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.6025744,-70.7810068)).title("Camino El Tanguito").snippet("Camino a Lonquén a Calle 2 ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.502332,-70.710687)).title("Cardenal Raúl Silva Henríquez").snippet("Vereda / Bidireccional / Jorge Quevedo a San Gregorio ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.540047,-70.620863)).title("Cardenal Raúl Silva Henríquez / Américo Vespucio").snippet("Vereda, Calle y Bandejón / Bidireccional / Canal Torrente a Porvenir ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.4206649,-70.6697112)).title("Carlos Medina / Soberanía").snippet("Calle / Bidireccional / Pdte Edurado Frei Montalva a Domingo Santa María ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.4776212,-70.6421864)).title("Carlos Silva Vildosola / Santa Rosa ").snippet("Bandejón / Bidireccional / San Diego a Locarno ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.484084,-70.63058)).title("Carlos Valdovinos").snippet("Vereda / Bidireccional / Santa Rosa a Vicuña Mackenna ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.474207,-70.6351)).title("Carmen / Las Industrias").snippet("Vereda / Bidireccional / General Jofré a Comercio ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.47574,-70.6684)).title("Centenario (a)").snippet("Bandejón / Bidireccional / Club Hípico a Bascuñán Guerrero ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.476516,-70.6540203)).title("Centenario (b)").snippet("Vereda / Bidireccional / San Ignacio a Nataniel Cox ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.4764936,-70.6464887)).title("Centenario (c)").snippet("Vereda y Bandejón / Bidireccional / San Diego a Santa Rosa ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.515617,-70.693722)).title("Central Cardenal Silva Henríquez").snippet("Vereda / Bidireccional / Buenaventura a Américo Vespucio ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.378249,-70.5032533)).title("Charles Hamilton").snippet("Vereda / Bidireccional / San José de la Sierra a Fray Montalva ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.450696,-70.598056)).title("Chile España").snippet("Calle / Bidireccional / Simón Bolívar a Miguel de Cervantes ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.4267047,-70.6190336)).title("Cirujano Guzmán").snippet("Calle / Norte a Sur / Pérez Valenzuela a Providencia").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.493925,-70.676427)).title("Clotario Blest").snippet("Vereda / Bidireccional / Carlos Valdovinos a Lo Ovalle ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.462861,-70.664945)).title("Club Hípico").snippet("Vereda / Norte a Sur / Grajales a Pedro Montt ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.588785,-70.7079756)).title("Colón").snippet("Bandejón / Bidireccional / Freire a Patria Nueva ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.4098781,-70.7016993)).title("Costanera Sur").snippet("Vereda y Bandejón / Bidireccional / Santos Luis Medel a Pdte. Balmaceda ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.609573,-70.602758)).title("Cuatro Oriente / Caletera Acceso Sur (a)").snippet("Vereda y Calle / Bidireccional / Sargento Menadier a Primavera ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.632777,-70.611025)).title("Cuatro Oriente / Caletera Acceso Sur (b)").snippet("Vereda / Bidireccional / Cerro Yaretas a Camino El Retiro ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.446171,-70.644541)).title("Curicó / Tarapacá / Padre Felipe Gómez de Vidaurre").snippet("Calle / Oriente a Poniente / Vicuña Mackenna a San Ignacio ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.50735,-70.62666)).title("Departamental (a)").snippet("Vereda / Bidireccional / Vicuña Mackenna a Nueva Berlioz ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.51031,-70.587872)).title("Departamental (b)").snippet("Vereda / Bidireccional / Tobalaba a Entrada Florida Center ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.393366,-70.655756)).title("Diagonal José María Caro").snippet("Vereda / Bidireccional / El Guanaco a Quebrada del Obispo ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.461932,-70.594078)).title("Doctor Johow").snippet("Vereda / Bidireccional / Grecia a José Ignacio Vergara ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.396488,-70.6618416)).title("Dorsal / Roma").snippet("Vereda y Bandejón / Recoleta a Bajos de Jiménez ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.459932,-70.574753)).title("Dublé Almeyda").snippet("Vereda / Poniente a Oriente / Los Corteses a Exequiel Figueroa ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.4442263,-70.560658)).title("Echeñique").snippet("Vereda / Bidireccional / Tobalaba a Vicente Pérez Rosales ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.401914,-70.629014)).title("Einstein / Las Torres").snippet("Vereda / Bidireccional / Antonia Prado a Los Zapadores ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.6410041,-70.7339984)).title("El Barrancón").snippet("Vereda / Norte a Sur / Camino Calera De Tango a Santa Inés ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.589223,-70.800941)).title("El Copihue").snippet("Vereda / Bidireccional / Los Nogales a Camino a Lonquén ").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(new LatLng(-33.502482,-70.573841)).title("Los Cerezos").snippet("Los Cerezos").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
}
}