Created
September 4, 2012 19:18
-
-
Save siannopollo/3625275 to your computer and use it in GitHub Desktop.
Google map marker using canvas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.