Check out my jsFiddle code below:
var marker = new google.maps.Marker({
position: new google.maps.LatLng(-25.363882,131.044922),
map: map,
title:"Hello World!",
icon: CanvasCrear("hola", 15)
});
I'm attempting to style the marker similar to this example:
function CanvasCrear(texto, height_) {
var canvas = document.createElement("canvas");
var context;
var txtWidth;
txtWidth = canvas.getContext("2d");
txtWidth.font = "12px Sans-Serif";
var width_ = txtWidth.measureText(texto).width;
canvas.setAttribute("width", (width_ + "px"));
canvas.setAttribute("height", (height_ +"px"));
context = canvas.getContext("2d");
context.font = "12px Sans-Serif";
context.fillStyle = "black";
context.fillText(texto, 0, 12);
document.body.appendChild(canvas);
}
window.onload = function() {
var texto = " " + "hola mundo" + " ";
var height = 15;
CanvasCrear(texto, height);
};
I have limited experience with canvas manipulation and would appreciate any suggestions or tips on how to improve this. Thank you!