• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Xml data to hashmap for onInfowindowclick Google Maps v2

 
Greenhorn
Posts: 15
MyEclipse IDE Chrome
  • 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
 
Rancher
Posts: 43009
76
  • 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
MyEclipse IDE Chrome
  • 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
MyEclipse IDE Chrome
  • 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
Boost this thread!