Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Xml data to hashmap for onInfowindowclick Google Maps v2

 
Jason Flaherty
Greenhorn
Posts: 15
Chrome MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
Chrome MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
Chrome MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic