39325

List list always return list size() =1 Here map

Question:

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:

<img alt="Image1" class="b-lazy" data-src="https://i.stack.imgur.com/2gsTA.jpg" data-original="https://i.stack.imgur.com/2gsTA.jpg" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Here I get size like this:

<img alt="Image2" class="b-lazy" data-src="https://i.stack.imgur.com/AjUBL.png" data-original="https://i.stack.imgur.com/AjUBL.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Answer1:

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 <strong>selected</strong> 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 <a href="https://stackoverflow.com/a/16367644/6950238" rel="nofollow">this</a> 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>)

Recommend

  • Add class to even elements when even element is clicked and add class to odd elements when odd eleme
  • Link conversion in mod rewrite .htaccess
  • Get user current position with gps/network android MapView
  • How to excute AsyncTask inside onLocationChanged() method in Android
  • LocationManager uses FusedLocationProviderApi?
  • Android Device Movement Speed
  • WebApp in AppServices vs CloudService
  • Swipe Gesture Recognizer not working for me
  • how to set id for each item in ListView
  • Android application not restoring state when installed from .apk, works fine from eclipse
  • Galaxy S4 Android Custom Camera Issue
  • Python cosine function precision [duplicate]
  • HttpClient: disabling chunked encoding
  • Clear fused location provider's location for testing
  • Trying to get the char code of ENTER key
  • Clarification on min distance on LocationManager.requestLocationUpdates method, min Distance paramet
  • accepts_nested_attributes_for practical form use for in Rails 3
  • Android Activity.onWindowFocusChanged doesn't get called from within TabHost
  • Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
  • Zoom in and out of jPanel
  • Firefox Extension - Monitor refresh and change of tab
  • Saving Changes After In-App Purchase Has Been Purchased
  • To display the title for the current loaction in map in iphone
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Benchmarking RAM performance - UWP and C#
  • JTable with a ScrollPane misbehaving
  • Angular 2 constructor injection vs direct access
  • Java static initializers and reflection
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • Android Google Maps API OnLocationChanged only called once
  • Turn off referential integrity in Derby? is it possible?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Add sale price programmatically to product variations
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • failed to connect to specific WiFi in android programmatically
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app
  • How can I use threading to 'tick' a timer to be accessed by other threads?
  • How do I use LINQ to get all the Items that have a particular SubItem?