aspose file tools*
The moose likes Android and the fly likes Xml data to hashmap for onInfowindowclick Google Maps v2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Xml data to hashmap for onInfowindowclick Google Maps v2" Watch "Xml data to hashmap for onInfowindowclick Google Maps v2" New topic
Author

Xml data to hashmap for onInfowindowclick Google Maps v2

Jason Flaherty
Greenhorn

Joined: Sep 23, 2011
Posts: 15

Hi all,

I am just running into a wall and thought before I get frustrated should ask what i am doing wrong.

I have a xml file with a few entries in it. It gets parsed like so and the markers get put on the map with the correct titles:


I can get that to show data just fine on my map. However, when I click on the info window on a marker I get a force close with Null pointer on that eventInfo.getDesc()....

I created a class called MapMarkers that has the getters/setters with a constructor that looks like:



What I would like to do is populate an array with the data from the xml file so when I click on the map markers info window I can get the description.

Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42908
    
  69
My guess would be that the problem is in line 53 - you're allocating a new HashMap for each marker, whereas you should only allocate a single one before the loop even starts.
Jason Flaherty
Greenhorn

Joined: Sep 23, 2011
Posts: 15

Thanks for the reply. I moved the map out of the for loop so that it would not be new everytime. I am getting the description, however, each time it is the final description/title in the loop rather than the one associated with the Marker m.

I am using m as the key in the eventMarkerMap.put(m,marks);

Why isn't the marks for each m containing the unique info for each loop through? Why is it being overwritten if I am putting new info into a certain KEY each time?

Thanks again for helping me understand this.



Jason Flaherty
Greenhorn

Joined: Sep 23, 2011
Posts: 15

Holy Moose, I wasn't creating a new MapMarker each time my for loop went. It seems to be good now. That must be the case.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Xml data to hashmap for onInfowindowclick Google Maps v2