Reputation: 267
QUestion
I'm trying to show a google map with markers and a list refering to those markers next to it and link each list item with a the markers on the map.
So When I hover over link 1, the map should move to marker 1 on the same map. When I hover over link 2, the map should move to marker 2 on the map.
Findings
I found a solution very similar to what I want, but I cant seem to figure our how to call the funciton moveMarker( map, marker )
on hovering a link.
You can see a working JS fidde here : API Fiddle link
Can you guys please give me some thoughts?
Upvotes: 0
Views: 685
Reputation: 31930
How I've done this before is, have a global array of markers. Have your links numbered 1..x. Pass that number into the moveMarker function to indicate which marker is being hovered (or figure it out from the ID of the link). Use that to determine the position of which marker in the array to move to.
Also from your code snippet it seems map
is a global variable (you don't do var map
in your initialize function), so you shouldn't have to pass that in as an argument to moveMarker.
Upvotes: 1