Skip to content Skip to sidebar Skip to footer

Adding Overlay Items To Osmdroid-map In Asynctask

What I want: I want a map with a marker at the user´s current location and 10 more, loaded in an AsyncTask from a Database after loading the map. What doenst work Everything is wo

Solution 1:

  1. Regarding the new items not showing in the ItemizedIconOverlay - what method are you using to add the items()? For some reason it looks like the addItem(location, item) method does not call populate() so the internal list never gets updated. Use the addItem(item) method for now. I should point out that ItemizedIconOverlay is a user-submitted class and is really just a starting point for a solution.

  2. You mention having nulls in your item list. That is the way Java's ArrayList works. The list is backed by an immutable array so when the backing array is full and you want to add a new item, the list has to create a new larger backing array. Since that is an expensive operation, the new array will be double the size of the old one. The unused "slots" in the backing array are set to null. The only thing that matters is what is returned by mItemList.size().

Solution 2:

Your items will be equals to null as long as the Asynctask is not finished. You need to initalize everyting in the onPostExecute of your LoadChooseShop.

Post a Comment for "Adding Overlay Items To Osmdroid-map In Asynctask"