я установил красный текстовый маркер, но я хочу показать, как изменить цвет маркера в секунду (например, красный и синий меняются в секунду)? Это возможно?
function createMarkerIcon(text, opt) {
var defaultOptions =
{
fontStyle: "normal", //normal, bold, italic
fontName: "Arival",
fontSize: 12,
bgColor: "#999999",
fgColor: "white",
padding: 4,
arrowHeight: 6
};
options = $.extend(defaultOptions, opt);
var canvas = document.createElement("canvas"),
context = canvas.getContext("2d");
var font = options.fontStyle + " " + options.fontSize + "px " +
options.fontName;
context.font = font;
var metrics = context.measureText(text);
var w = metrics.width + options.padding * 2;
var h = options.fontSize + options.padding * 2 +options.arrowHeight;
canvas.width = w;
canvas.height = h;
context.beginPath();
context.rect(0, 0, w, h - options.arrowHeight);
context.fillStyle = options.bgColor;
context.fill();
context.beginPath();
var x = w / 2, y = h, arwSz = options.arrowHeight;
context.moveTo(x, y);
context.lineTo(x - arwSz, y - arwSz);
context.lineTo(x + arwSz, y - arwSz);
context.lineTo(x, y);
context.fill();
context.textAlign = "center";
context.fillStyle = options.fgColor;
context.font = font;
context.fillText(text,
w / 2,
(h - options.arrowHeight) / 2 + options.padding);
return canvas.toDataURL();
}
marker = new google.maps.Marker({
position: lat,
map: map,
content: redloc[j][1],
title: addressDetails[5],
icon: createMarkerIcon(addressDetails[3], {
bgColor:"#FF0000" })
//icon: "http://labs.google.com/ridefinder/images/mm_20_green.png"
});
Любая помощь будет оценена!? Андрей