Is it possible to programmatically generate markers in Google? For example, I have a database of services and locations that I want to plot on a Google Map using PHP.
Using the Maps API v3, I have created a map and plotted the services fine using markers and info windows, but what I really want to do is generate numbers (1,2,3,4… etc.) in the default marker bubbles based on the order they get retrieved from the DB. Also, I’d like to change the colour of the marker icon programmatically based on the service type in the database.
I’m using PHP, so don’t know if there’s a script to do this, but I had hoped that Google would provide this custom marker generation through the API.
Have PHP spit out javascript code.
Here’s a little convenience javascript function that I wrote to add a marker with a window associated.
So after declaring that in some javascripty place, you’d then have some PHP that’d probably resemble (and assuming your map is a global called ‘map’):
I haven’t tested any of this nor do I have any idea what the data looks like, but that method should work for what you’re wanting. I’m not 100% sure what you mean by custom marker generation, because it sounds like you’re already doing that, just not through PHP.