问题
Here I am adding marker on map:
hereMap.addMapObject(new MapMarker(new GeoCoordinate(lat,lng), myImage)
.setTitle("marker"+geoCounter)
.setDescription(" \nLatitude :" +lati+ "\nLongitude : "+ lng));
adding lat lng with array list of lat lng but when I add the marker with the help of:
@Override
public void onLocationChanged(Location location) {...}
List<ViewObject>
list gives me the exact size of the added marker.
In this case, I get lat long with:
location.getLatitude()
location.getLongitude()
Here are the map markers on map:

Here I get size like this:

回答1:
Seems
public abstract boolean onMapObjectsSelected (java.util.List <ViewObject> objects)
A callback indicating that at least one ViewObject has been selected as a result of a user tapping on the map. So objects
has only selected markers. For get access to all markers on map You should save the resulting Marker object in a collection (for example ArrayList<MapMarker>
) of your choice after you call addMarker()
, like in this answer. For example:
ArrayList<MapMarker> mMarkersList = new ArrayList();
...
MapMarker marker = new MapMarker(new GeoCoordinate(lat,lng), myImage)
.setTitle("marker"+geoCounter)
.setDescription(" \nLatitude :" +lati+ "\nLongitude : "+ lng)
mMarkersList.add(marker);
hereMap.addMapObject(marker);
then get it from mMarkersList
:
MapMarker marker = mMarkersList.get(<number_of_marker>)
来源:https://stackoverflow.com/questions/40585600/listviewobject-list-always-return-list-size-1-here-map