添加标记以从ArrayList映射(Adding markers to map from ArrayList)

我在LatLng arraylist中有我的标记的坐标。 我将所有标记添加到标记arraylist。

for(int i=0; i<markers_location.length; i++){ coords_markers.add(new LatLng(lat_markers.get(i), lon_markers.get(i)));} List<Marker> markers = new ArrayList<>(); for(int i=0; i<markers_location.length; i++){ Marker marker = mMap.addMarker(new MarkerOptions().position(coords_markers.get(i))); markers.add(marker); }

如何将这些标记添加到地图中? 我试过这个:

mMap.addMarker(markers.get(0));

但它不起作用。

I have the coordinates of my markers in a LatLng arraylist. I add all the markers to a marker arraylist.

for(int i=0; i<markers_location.length; i++){ coords_markers.add(new LatLng(lat_markers.get(i), lon_markers.get(i)));} List<Marker> markers = new ArrayList<>(); for(int i=0; i<markers_location.length; i++){ Marker marker = mMap.addMarker(new MarkerOptions().position(coords_markers.get(i))); markers.add(marker); }

How can I then add these markers to the map? I tried this:

mMap.addMarker(markers.get(0));

But it doesn't work.

最满意答案

尝试这个:

for(int i=0; i<markers_location.length; i++){ coords_markers.add(new LatLng( lat_markers.get(i).getLatitude, lon_markers.get(i).getLongitude));}

Try this:

for(int i=0; i<markers_location.length; i++){ coords_markers.add(new LatLng( lat_markers.get(i).getLatitude, lon_markers.get(i).getLongitude));}

更多推荐