I'm trying to make a page that lists properties for rent on the left, and they are mapped on the right via the Google Maps API. So far, I have all of the properties on the left (all dummy-data now, but it's dynamically generated), and then on the right the Google Maps APi plots out all of the data (also dynamically). The sample page has 20 or so markers. What I'm looking to do now is: Whenever someone hovers over a property on the left, I want to bounce the marker on the map so people know which one to open.
My dev page is at: https://www.commercialrealestate-portland.com/available-now/
I've tried a number of suggestions, none of which worked so far. Based on my research, it looks like maybe I need to assign an ID to each individual Google Maps marker, so that I could then call the bounce on mouseover of a div.
I was thinking I'd put something like this in each div on the left:
<div class="listingBox" onmouseover="marker['unit145_the_waterman_building'].setAnimation(google.maps.Animation.BOUNCE);"></div>
But I'm not sure if that will work. When I go to my console, I get an uncaught reference error -- marker is not defined.
To get my markers, I build out an array of locations (the title/etc, the latitude, the longitude, and an ID). Then, I iterate through those locations and do a:
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
animation: google.maps.Animation.DROP,
map: map,
id: locations[i][3]
})
But, I don't think the ID (which is the value in locations[i][3]) is carrying through, as the onmouseover doesn't work.
Actually, I'm not even sure if this approach is best. Really, my fundamental challenge is: I have X properties (divs) on the left (will always be changing as it's data-driven), and I want to be able to bounce that div's map marker on the right. I'm open to any types of suggestions -- suggested fixes to the above, links that might help, or different approaches altogether.