Generating a Google Map with multiple markers and info windows8/2/13
By Chris Johnson
I recently needed to generate a Google Map with multiple markers and popup info windows. Easy, right? The twist was that I also wanted the marker pins to be different colors and I needed the map to auto center.
Here’s the script I pulled together to make it happen:
Here’s a screenshot of what it should look like:
This script is a combination of code I found on Colin Wiseman’s website and Stack Overflow with a bit of my own to handle the different marker colors.
Update 2/17/2015: I removed the code that added separate shadow images behind the markers. As of version 3.14 of the Google Maps API, these shadows were being ignored. If you want shadows, you’ll need to use marker images with the shadows already in them. I also took this opportunity to clean up the code a bit, and remove the dependency on jQuery.