Edit: The site is working properly again. I deleted the line of code flagged by commentors below (referencing a nonexistent div), experimented with version syntax, and also with the order of parameters in my contentBox function). Also deleted the syntax and added a line of code to call the function from the DOM. Thanks to all who commented. Some combination of the above worked. Cheers, Cheryl)
Note: I asked this question in the main forum yesterday — didn’t realize that the google maps user group had its own tag in Stack Overflow. Here’s the Q:
I have an application that uses Google maps API v. 3 and accesses content from a database to display in google’s infowindows and a sidebar. See the code for the main file here: http://www.corkmemorymap.org.
My problem is that, periodically, the function that brings up content in the sidebar when a user clicks on a marker stops working. You can still access sidebar content via the topic search at the top of the page (that is done with jquery, and not tied to google or the markers) but I can’t get sidebar content through the markers.
The last time this happened, it was a version issue. I added a version to the script code that calls the API, and all was well.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3.9&sensor=false"></script>
This time I thought it was the same thing, as I saw Google had deprecated that version. So I updated to the new version and… nada. So now I am stumped. I tried messing around with different versions, or no version, and had it briefly working again. Then not. Does anyone else have experience with this? Are the versions unstable? Any suggestions?
If it helps, this is the function that calls the change in sidebar content:
function contentBox(marker, map, sidebar, winHtml, infoWindow) {
google.maps.event.addListener(marker, 'click', function() {
document.getElementById('sidebar').innerHTML=winHtml;
infoWindow.close(map, marker);
});
}
Oh, one other thing — I’m not using an API key as this is a non-profit website. Do I need an API key (it’s been working without one since December 2011)? Is there anything tricky about them?
Regards, Cheryl
This question was answered in comments above. There were two issues: I needed to update the version of the Google Maps API I was referencing in the header, and I had a line of code pointing to a nonexistent div. I updated the former and deleted the latter. Thanks to those who responded.