Skip to content

Instantly share code, notes, and snippets.

@siannopollo
Created September 4, 2012 19:18
Show Gist options
  • Save siannopollo/3625275 to your computer and use it in GitHub Desktop.
Save siannopollo/3625275 to your computer and use it in GitHub Desktop.
Google map marker using canvas
var canvas = document.createElement("canvas")
document.body.appendChild(canvas)
var c = canvas.getContext("2d")
c.beginPath()
c.strokeStyle = 'darkred'
c.arc(11,11,10,0.8*Math.PI,0.2*Math.PI,false)
c.stroke()
c.lineTo(11,34)
c.stroke()
c.lineTo(2,16)
c.stroke()
var g = c.createLinearGradient(11,0,11,34)
g.addColorStop(0,"pink")
g.addColorStop(1,"red")
c.fillStyle=g
c.fill()
c.closePath()
canvas.toDataURL() // returns data-uri to be used in the google marker
@siannopollo
Copy link
Author

People were only making square markers using canvases, so I decided to take a crack at making a marker that looked more similar to the default map markers. Not a finished product, just a starting point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment