javascript - google maps infowindow shows first infowindow only even for other markers -
I have seen other questions related to this and none of the solutions I have seen have probably been helpful I'm looking for something.
Any help would be appreciated.
I have a map which I am loading over 1000 markers. When a user performs a mouse over the marker, I need infowindow to display for that marker for the marker.
The problem I am facing is that same Infinite is seen on the same marker, it does not matter if the marker is the mouseover.
I had provided a screenshot below which shows a map with markers and an infondova. So, no matter what marker I got mouseover, the same Infondondo was shown.
This is the code (GM is an immediate Google.maps object):
for (var I = 0; i & lt; opts.LocationsData.length; i ++) {var data = opts.LocationsData [i]; Var icon = new gm.MarkerImage (datum.map_pin_loc + datum.map_marker + '.svg', null, null, null, new google.maps.size (31,51)); Var loc = new gm.LatLng (datum.latitude, datum.longitude); Var zi = 500; If (i> 9) {datum.map_pin_icon = datum.map_pin_loc + 'dot1.svg'; Icon = new village Marquez (datum.map_pin_icon, null, null, null, new google.maps.Size (8,8)); Ze = 450; } Var marker = new village Marker ({Status: Public, / ** Title: Datam. Moles! = ''? Datamatital: Data Decipherment, ** / icon: Icon, Zandx: G, Map: Map}); Marker.type = 'point'; Marker.post_id = datum.pin_id; Marker. ScrollAndAnimate = True; / ** (for marker management and other purposes this is used in other places in my code) ** / marker peach (marker); MarkersLatLngObjs.push (loc); Var infowindow = new gm.InfoWindow ({content: 'strong & gt;' + (datum.title! = ''? Datum.title: datum.description) + '& lt; / strong & gt;'} ); Gm.event.addListener (marker, 'mouseover', function () {infowindow.open (map, marker);}); }
function is called in the context of showInfo () {//) a marker var dramat = option. Lectional data [this.placeindex]; Var infowindow = new gm.InfoWindow ({content: 'strong & gt;' + (datum.title! = ''? Datum.title: datum.description) + '& lt; / strong & gt;'} ); Infowindow.open (map, this); } Just before your loop, then tag the marker in your loop with a property placeIndex (for example): Marker.placeIndex = i; And finally bind the handler like this:
gm.event.addListener (marker, 'mouseover', showInfo); EDIT: Oh, my bad, forgot about other references, same pb. You could possibly change the marker within this handler by 'this'. I updated the code.
Comments
Post a Comment