I have created a google map located at: http://calwestcultural.com/sgs/example_map.html
I am trying to link some text in my spry menu to the left with my google map markers/infowindow.
My javascript is limited as I tried to create ID’s for each marker and link to that id but it did not work. I am stumped at this point.
I also would like my markers to display the name when you hover your mouse over it. I achieved this using a different style map but had problems creating markers so the current one I am using above will be my final, I just have to get the links to reference correctly.
PLEASE ANY HELP WITH THIS WOULD GET RID OF MY JS HEADACHE RIGHT NOW!!!!!!!!!
This page shows one way of connecting a sidebar link to your markers
http://www.wolfpil.de/v3/toggle-cats.html
Copying this page’s patterns to your case, you need a
gmarkersglobal variableThe order in which markers are added matters, they should match the order of the businesses in the sidebar.
gmarkerswill be updated increateMarker.With the array in place, we can address them by index. Wolfpil simply triggers a click event when a sidebar entry (link) is clicked:
And each link can be written like this, replacing 0 and 1 with the order each marker was added:
About the marker hover showing a title, the easiest way is adding a
titleoption when creating your markers, but it would mean adding a new parameter to your createMarkers function:A better alternative in the long run is to use an object for
gmarkersinstead of the array, because adding an item in the middle of the list will disorganize the existing items in the HTML.Then, places can be called by a string ID, such as
gmarkers['safeway']. Instead of pushing a marker to the array increateMarker, we assign the id to the marker:If you run into trouble write comments below please! I didn’t test the code above.