I may be missing some fundamental law in JavaScript here, quite possibly, but I have a question regarding the latlng position of a Google Maps marker after it is dragged.
I am successfully adding markers to a map, and assigning those added markers to a variable, or to be more precise, I'm using jQuery to add those markers to the data of the map's div element, using jQuery.data().
Now, the problem I have arises when I drag those markers around the map. I understand the dragend event, and how to fire/capture it and it's data, including the new latlng position after the drag. That being said, I was of the understanding that objects in JavaScript are passed by reference, so what I can't understand is why the position of the marker reference stored in the element isn't updated to reflect the new position automatically?
I guess it could be one of the following:
- Objects passed into the
dataof an element are duplicated, not passed by reference, and therefore a jQuery problem. - Google Maps doesn't automatically update the latlng positions of it's markers, stored in variables or
datanodes, and therefore a Google Maps problem. - I have to physically fire the
dragendevent myself to update the position (sounds like an odd solution).
I'm basically querying this to see if I need to log it as an issue anywhere, or whether I'm just being an idiot. Any input from other hardened Google Mappers would really help me here.
Cheers in advance.