0

I'm making a Google Maps application that should support a high degree of customization of the displayed data. I want to allow the user to (among other things) pick between a wide assortment of shapes and colors for those shapes. Currently I have created PNGs of these shapes, each with 8 different color variations.

Not only is it a lot of work to add additional shapes, but the color setting is also severely limited. I would like to allow the user to tune a few settings and create a brand new icon with them. For this to be possible in pure JavaScript, the Google Maps markers must be able to display Canvas data, which according to a (relatively old) blog post I found, it doesn't.

Another option I can think of would be creating SVG images, but how do I apply the SVG to a Google Maps marker if I only have the SVG data in a JavaScript string?

Anyway, the summarize the question; How can I create custom graphics on the fly and use them for a Google Maps marker?

Hubro
  • 56,214
  • 69
  • 228
  • 381
  • http://stackoverflow.com/questions/1055367/how-can-i-overlay-svg-diagrams-on-google-maps tells you a bit about how to overlay svg graphics on google maps. – Erik Dahlström Jun 15 '12 at 11:28
  • Just thinking out loud here. If you don't want to create PNG markers for every colour, you could display two on top of each other, with the top one having a varying opacity. So a red one with a 50% opacity on top of a white one will be pink, for example. That would give you a lot of colour choices for a small number of predefined images. – halfer Jun 15 '12 at 14:30
  • Interesting idea indeed. It would be a total pain to implement though, since it requires two Markers per Marker, and I already have a large application build around "one marker per data row". It would also be a big performance hit – Hubro Jun 15 '12 at 14:34

1 Answers1

1

Use Canvas2Image to save your canvases as images, then apply those to the Google map.

Ashley Strout
  • 6,107
  • 5
  • 25
  • 45
  • Very cool! No IE8 support though. I'm holding out for a better answer for a little while – Hubro Jun 15 '12 at 08:29