1

I wonder whether someone could help me please.

I have put together a form shown here which allows the user to select and deselect marker categories on the map.

What I'm now trying to do, is on a marker click populate a text box called 'address' with the address details.

I've tried placing this line document.getElementById('address').value = address; where I thought it should be placed which is after

google.maps.event.addListener(marker, 'click', function() { 

But I receive the error saying that the 'address is undefined'. I must admit I'm not sure why because the address is part of the marker data pulled from my php script.

Would it be at all possible that someone could provide some guidance please on where I've gone wrong.

Many thanks

IRHM
  • 1,326
  • 11
  • 77
  • 130

1 Answers1

0

You need to recover the address from the "marker" object.

If you try the code below in FireFox you will see the "marker" objects inner structure and then be able to workout how to access the data within it

    google.maps.event.addListener(marker, 'click', function() { 
            alert(marker.toSource());   
    }
blacktea
  • 142
  • 1
  • 2
  • 12
  • Hi many thanks for this. I've run this through the Firefox, quite an eye opener and a bit confusing, but I'll work through this. Kind regards – IRHM Nov 16 '11 at 18:26
  • Post the output here and I'll try and explain whats going on. Have a look at http://stackoverflow.com/questions/1345939/how-do-i-count-javascript-objects-attributes which may help explain how objects can hold variables. So, in the question you could get the value of "key1" you would type alert(object.key1) – blacktea Nov 17 '11 at 09:11