Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ig_markerfactory

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ig_markerfactory - npm Package Compare versions

Comparing version 2.12.4 to 2.12.5

767

dist/markerfactory.es6.js
function hslaString(hslcolor) {
if (hslcolor.a) {
if (hslcolor.a !== undefined) {
return (

@@ -11,3 +11,3 @@ "hsla(" +

"%," +
hslcolor.a +
parseFloat(hslcolor.a, 10) +
")"

@@ -20,3 +20,3 @@ );

function rgbaString(hexcolor) {
if (hexcolor.a) {
if (hexcolor.a !== undefined) {
return (

@@ -30,3 +30,3 @@ "rgba(" +

"," +
hexcolor.a +
parseFloat(hexcolor.a, 10) +
")"

@@ -71,5 +71,25 @@ );

function IconObject(canvas, markerOpts) {
this.url = canvas.toDataURL();
this.fillColor = canvas.fillColor;
function serializeOptions(options) {
if (typeof options !== "object") {
return null;
}
var cleanOptions = omit(options, function(prop) {
return prop.indexOf("gm_") === 0;
}),
sortedOpts = Object.entries(cleanOptions)
.filter(function(item) {
return (
typeof item[1] !== "function" &&
typeof item[1] !== "object" &&
item[1] !== null &&
typeof item[1] !== "undefined"
);
})
.sort();
return JSON.stringify(sortedOpts);
}
function IconObject(url, fillColor, markerOpts) {
this.url = url;
this.fillColor = fillColor;
this.markerOpts = markerOpts;

@@ -81,55 +101,40 @@ Object.assign(this, markerOpts);

IconObject.prototype.toJSON = function() {
return omit(this.markerOpts, function(prop) {
var serialized = omit(this.markerOpts, function(prop) {
return prop.indexOf("gm_") === 0 || prop === "url";
});
serialized.fillColor = this.fillColor;
return serialized;
};
/** global: google */
function createClusterIcon(theoptions) {
var generateClusterCanvas = function(options) {
var canvas = options.canvas || document.createElement("canvas"),
anchorX = 27,
anchorY = 53,
radius = anchorX - 9,
color1,
font = options.font || "fontello",
fontsize = options.fontsize || 14,
context = canvas.getContext("2d");
canvas.width = anchorX * 2;
canvas.height = anchorY + 1;
var generateClusterCanvas = function(options) {
var canvas = options.canvas || document.createElement("canvas"),
anchorX = 27,
anchorY = 53,
radius = anchorX - 9,
color1,
font = options.font || "fontello",
fontsize = options.fontsize || 14,
context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
context.moveTo(anchorX, anchorY);
canvas.width = anchorX * 2;
canvas.height = anchorY + 1;
var labelvalue = parseInt(options.label, 10);
if (labelvalue < 10) {
color1 = "orange";
fontsize = 14;
} else if (labelvalue < 30) {
color1 = "red";
fontsize = 15;
} else {
color1 = "purple";
fontsize = 16;
}
if (labelvalue > 99) {
radius = radius + 3;
context.setLineDash([5, 5]);
context.beginPath();
context.arc(
anchorX,
2 + 0.5 * anchorY,
radius + 7,
0,
2 * Math.PI,
false
);
context.fillStyle = "transparent";
context.strokeStyle = color1;
context.lineWidth = 2;
context.fill();
context.stroke();
}
context.clearRect(0, 0, canvas.width, canvas.height);
context.moveTo(anchorX, anchorY);
var labelvalue = parseInt(options.label, 10);
if (labelvalue < 10) {
color1 = "orange";
fontsize = 14;
} else if (labelvalue < 30) {
color1 = "red";
fontsize = 15;
} else {
color1 = "purple";
fontsize = 16;
}
if (labelvalue > 99) {
radius = radius + 3;
context.setLineDash([5, 5]);

@@ -140,3 +145,3 @@ context.beginPath();

2 + 0.5 * anchorY,
radius + 2,
radius + 7,
0,

@@ -151,36 +156,40 @@ 2 * Math.PI,

context.stroke();
}
// Círculo blanco
context.setLineDash([5, 0]);
context.beginPath();
context.arc(
anchorX,
2 + 0.5 * anchorY,
radius - 3,
0,
2 * Math.PI,
false
);
context.fillStyle = "white";
context.strokeStyle = color1;
context.lineWidth = 4;
context.fill();
context.stroke();
context.setLineDash([5, 5]);
context.beginPath();
context.arc(anchorX, 2 + 0.5 * anchorY, radius + 2, 0, 2 * Math.PI, false);
context.fillStyle = "transparent";
context.strokeStyle = color1;
context.lineWidth = 2;
context.fill();
context.stroke();
context.beginPath();
// Círculo blanco
context.setLineDash([5, 0]);
context.beginPath();
context.arc(anchorX, 2 + 0.5 * anchorY, radius - 3, 0, 2 * Math.PI, false);
context.fillStyle = "white";
context.strokeStyle = color1;
context.lineWidth = 4;
context.fill();
context.stroke();
context.font = "normal normal normal " + fontsize + "px " + font;
context.fillStyle = "#333";
context.textBaseline = "top";
context.beginPath();
var textWidth = context.measureText(options.label),
text_x = options.label,
label_x = Math.floor(canvas.width / 2 - textWidth.width / 2),
label_y = 1 + Math.floor(canvas.height / 2 - fontsize / 2);
context.font = "normal normal normal " + fontsize + "px " + font;
context.fillStyle = "#333";
context.textBaseline = "top";
// centre the text.
context.fillText(text_x, label_x, label_y);
var textWidth = context.measureText(options.label),
text_x = options.label,
label_x = Math.floor(canvas.width / 2 - textWidth.width / 2),
label_y = 1 + Math.floor(canvas.height / 2 - fontsize / 2);
return canvas;
};
// centre the text.
context.fillText(text_x, label_x, label_y);
return canvas;
};
function createClusterIcon(theoptions) {
theoptions.scale = theoptions.scale || 1;

@@ -193,12 +202,12 @@ var markerCanvas = generateClusterCanvas(theoptions),

if (window && window.google && window.google.maps) {
Object.assign(markerOpts, {
size: new google.maps.Size(54, 48),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(27 * scale, 24 * scale),
scaledSize: new google.maps.Size(54 * scale, 48 * scale)
});
}
Object.assign(markerOpts, {
origin: { x: 0, y: 0 },
anchor: { x: 27 * scale, y: 24 * scale },
size: { width: 54, height: 48 },
scaledSize: { width: 54 * scale, height: 48 * scale }
});
var iconObj = new IconObject(markerCanvas, markerOpts);
var url = markerCanvas.toDataURL(),
fillColor = markerCanvas.fillColor,
iconObj = new IconObject(url, fillColor, markerOpts);

@@ -482,102 +491,103 @@ return iconObj;

/** global: google */
function createTextMarker(theoptions) {
var generateCanvas = function(options) {
var canvas = document.createElement("canvas");
var ancho = 30,
alto = 40;
canvas.width = ancho + 18;
canvas.height = alto;
var x = canvas.width / 2,
y = canvas.height - 2,
radius = ancho / 2,
angulo = 0.6;
var generateCanvas = function(options) {
var canvas = document.createElement("canvas");
var ancho = 30,
alto = 40;
canvas.width = ancho + 18;
canvas.height = alto;
var x = canvas.width / 2,
y = canvas.height - 2,
radius = ancho / 2,
angulo = 0.6;
var font = "'" + options.font + "'" || "Arial";
var fontsize = options.fontsize || 11;
var font = "'" + options.font + "'" || "Arial";
var fontsize = options.fontsize || 11;
var context = canvas.getContext("2d");
var context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
context.clearRect(0, 0, canvas.width, canvas.height);
var radius0 = 2 * radius,
cx = x + 0.95 * radius0,
cy = y + 0.45 * radius0;
var radius0 = 2 * radius,
cx = x + 0.95 * radius0,
cy = y + 0.45 * radius0;
var grad = context.createLinearGradient(0, 0, 0, canvas.height),
colors = getColors(options),
color0 = colors[0],
color1 = colors[1];
var grad = context.createLinearGradient(0, 0, 0, canvas.height),
colors = getColors(options),
color0 = colors[0],
color1 = colors[1];
grad.addColorStop(0, color0);
grad.addColorStop(1, color1);
grad.addColorStop(0, color0);
grad.addColorStop(1, color1);
context.fillStyle = grad;
context.strokeStyle = "rgba(200,200,200,0.7)";
context.fillStyle = grad;
context.strokeStyle = "rgba(200,200,200,0.7)";
context.beginPath();
context.beginPath();
//arco izquierdo
context.arc(
cx - 1,
cy,
radius0,
(9 * Math.PI) / 8,
(-6 * Math.PI) / 8,
false
);
//arco izquierdo
context.arc(
cx - 1,
cy,
radius0,
(9 * Math.PI) / 8,
(-6 * Math.PI) / 8,
false
);
// arco superior
context.arc(x, (y - 7) / 2, radius, angulo, Math.PI - angulo, true);
// arco superior
context.arc(x, (y - 7) / 2, radius, angulo, Math.PI - angulo, true);
//arco derecho
context.arc(
2 * x - cx + 1,
cy,
radius0,
(-0.95 * Math.PI) / 3,
-Math.PI / 8,
false
);
context.fill();
context.stroke();
//arco derecho
context.arc(
2 * x - cx + 1,
cy,
radius0,
(-0.95 * Math.PI) / 3,
-Math.PI / 8,
false
);
context.fill();
context.stroke();
context.beginPath();
context.arc(x, 0.4 * y, (2 * radius) / 3, 0, 2 * Math.PI, false);
context.fillStyle = "white";
context.fill();
context.beginPath();
context.arc(x, 0.4 * y, (2 * radius) / 3, 0, 2 * Math.PI, false);
context.fillStyle = "white";
context.fill();
context.beginPath();
context.beginPath();
// Render Label
//context.font = "11pt Arial";
context.font = fontsize + "pt " + font;
context.textBaseline = "top";
// Render Label
//context.font = "11pt Arial";
context.font = fontsize + "pt " + font;
context.textBaseline = "top";
var textWidth = context.measureText(options.label);
var textWidth = context.measureText(options.label);
if (textWidth.width > ancho || String(options.label).length > 3) {
context.rect(
x - 2 - textWidth.width / 2,
y - 30,
x - 2 + textWidth.width / 2,
y - 23
);
context.fillStyle = "#F7F0F0";
context.fill();
context.stroke();
}
context.fillStyle = "black";
context.strokeStyle = "black";
// centre the text.
context.fillText(
options.label,
1 + Math.floor(canvas.width / 2 - textWidth.width / 2),
8
if (textWidth.width > ancho || String(options.label).length > 3) {
context.rect(
x - 2 - textWidth.width / 2,
y - 30,
x - 2 + textWidth.width / 2,
y - 23
);
context.fillStyle = "#F7F0F0";
context.fill();
context.stroke();
}
return canvas;
};
theoptions.scale = theoptions.scale || 0.75;
var markerCanvas = generateCanvas(theoptions),
context.fillStyle = "black";
context.strokeStyle = "black";
// centre the text.
context.fillText(
options.label,
1 + Math.floor(canvas.width / 2 - textWidth.width / 2),
8
);
canvas.fillColor = color0;
return canvas;
};
function createTextMarker(theoptions) {
var scale = theoptions.scale || 0.75,
markerCanvas = generateCanvas(theoptions),
markerOpts = {};

@@ -589,18 +599,13 @@

if (window && window.google && window.google.maps) {
Object.assign(markerOpts, {
size: new google.maps.Size(48, 40),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(
24 * theoptions.scale,
40 * theoptions.scale
),
scaledSize: new google.maps.Size(
48 * theoptions.scale,
40 * theoptions.scale
)
});
}
var iconObj = new IconObject(markerCanvas, markerOpts);
Object.assign(markerOpts, {
origin: { x: 0, y: 0 },
anchor: { x: 24 * scale, y: 40 * scale },
size: { width: 48, height: 40 },
scaledSize: { width: 48 * scale, height: 40 * scale }
});
var url = markerCanvas.toDataURL(),
fillColor = markerCanvas.fillColor,
iconObj = new IconObject(url, fillColor, markerOpts);
return iconObj;

@@ -610,79 +615,72 @@ }

/** global: google */
function createFatMarkerIcon(theoptions) {
var generateFatCanvas = function(options) {
var canvas = options.canvas || document.createElement("canvas"),
anchorX = 27,
anchorY = 53,
radius = anchorX - 9,
angulo = 1.1,
font = options.font || "fontello",
fontsize = options.fontsize || 14,
context = canvas.getContext("2d"),
grad = context.createLinearGradient(0, 0, 0, anchorY);
var generateFatCanvas = function(options) {
var canvas = options.canvas || document.createElement("canvas"),
anchorX = 27,
anchorY = 53,
radius = anchorX - 9,
angulo = 1.1,
font = options.font || "fontello",
fontsize = options.fontsize || 14,
context = canvas.getContext("2d"),
grad = context.createLinearGradient(0, 0, 0, anchorY);
canvas.width = anchorX * 2;
canvas.height = anchorY + 1;
canvas.width = anchorX * 2;
canvas.height = anchorY + 1;
var colors = getColors(options),
color0 = colors[0],
color1 = colors[1];
var colors = getColors(options),
color0 = colors[0],
color1 = colors[1];
context.clearRect(0, 0, canvas.width, canvas.height);
context.clearRect(0, 0, canvas.width, canvas.height);
grad.addColorStop(0, color0);
grad.addColorStop(1, color1);
grad.addColorStop(0, color0);
grad.addColorStop(1, color1);
context.fillStyle = grad;
context.strokeStyle = color1;
context.beginPath();
context.fillStyle = grad;
context.strokeStyle = color1;
context.beginPath();
context.moveTo(anchorX, anchorY);
context.moveTo(anchorX, anchorY);
// arco superior
context.arc(
anchorX,
2 + 0.5 * anchorY,
radius,
angulo,
Math.PI - angulo,
true
);
// arco superior
context.arc(
anchorX,
2 + 0.5 * anchorY,
radius,
angulo,
Math.PI - angulo,
true
);
//punta inferior
context.lineTo(anchorX, anchorY);
//punta inferior
context.lineTo(anchorX, anchorY);
context.fill();
context.stroke();
context.fill();
context.stroke();
// Círculo blanco
context.beginPath();
context.arc(
anchorX,
2 + 0.5 * anchorY,
radius - 3,
0,
2 * Math.PI,
false
);
context.fillStyle = "white";
context.fill();
// Círculo blanco
context.beginPath();
context.arc(anchorX, 2 + 0.5 * anchorY, radius - 3, 0, 2 * Math.PI, false);
context.fillStyle = "white";
context.fill();
context.beginPath();
context.beginPath();
context.font = "normal normal normal " + fontsize + "px " + font;
//console.log('context font', context.font);
context.fillStyle = color1;
context.textBaseline = "top";
context.font = "normal normal normal " + fontsize + "px " + font;
//console.log('context font', context.font);
context.fillStyle = color1;
context.textBaseline = "top";
var textWidth = context.measureText(options.unicodelabel),
text_x = options.unicodelabel,
label_x = Math.floor(canvas.width / 2 - textWidth.width / 2),
label_y = 1 + Math.floor(canvas.height / 2 - fontsize / 2);
var textWidth = context.measureText(options.unicodelabel),
text_x = options.unicodelabel,
label_x = Math.floor(canvas.width / 2 - textWidth.width / 2),
label_y = 1 + Math.floor(canvas.height / 2 - fontsize / 2);
// centre the text.
context.fillText(text_x, label_x, label_y);
canvas.fillColor = color0;
return canvas;
};
// centre the text.
context.fillText(text_x, label_x, label_y);
canvas.fillColor = color0;
return canvas;
};
function createFatMarkerIcon(theoptions) {
var scale = theoptions.scale || 1,

@@ -696,12 +694,13 @@ markerCanvas = generateFatCanvas(theoptions),

if (window && window.google && window.google.maps) {
Object.assign(markerOpts, {
size: new google.maps.Size(54, 48),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(21 * scale, 36 * scale),
scaledSize: new google.maps.Size(42 * scale, 36 * scale),
scale: scale
});
}
var iconObj = new IconObject(markerCanvas, markerOpts);
Object.assign(markerOpts, {
origin: { x: 0, y: 0 },
anchor: { x: 21 * scale, y: 36 * scale },
size: { width: 54, height: 48 },
scaledSize: { width: 42 * scale, height: 36 * scale },
scale: scale
});
var url = markerCanvas.toDataURL(),
fillColor = markerCanvas.fillColor,
iconObj = new IconObject(url, fillColor, markerOpts);
return iconObj;

@@ -711,70 +710,115 @@ }

/** global: google */
function createTransparentMarkerIcon(theoptions) {
var generateTransparentCanvas = function(options) {
var text_x,
canvas = options.canvas || document.createElement("canvas"),
context = canvas.getContext("2d"),
font = options.font || "fontello",
fontsize = options.fontsize || 26;
var generateGroupedCanvas = function(options) {
var text_x,
canvas = options.canvas || document.createElement("canvas"),
context = canvas.getContext("2d"),
font = options.font || "fontello",
fontsize = options.fontsize || 26;
canvas.width = 54;
canvas.height = 48;
context.clearRect(0, 0, canvas.width, canvas.height);
canvas.width = 54;
canvas.height = 48;
context.clearRect(0, 0, canvas.width, canvas.height);
var colors = getColors(options),
color0 = colors[0],
color1 = colors[1];
context.beginPath();
var colors = getColors(options),
color0 = colors[0];
context.beginPath();
if (options.shadow) {
context.font = "normal normal normal " + fontsize + "px " + font;
context.font = "normal normal normal " + fontsize + "px " + font;
context.textBaseline = "top";
var textWidth = context.measureText(options.unicodelabel);
text_x = Math.floor(canvas.width / 2 - textWidth.width / 2);
context.textBaseline = "top";
var textWidth = context.measureText(options.unicodelabel);
text_x = Math.floor(canvas.width / 2 - textWidth.width / 2);
context.shadowOffsetX = -2;
context.shadowOffsetY = -2;
context.shadowBlur = 0;
context.shadowOffsetX = -2;
context.shadowOffsetY = -2;
context.shadowBlur = 0;
context.fillStyle = "#FFFFFF";
context.shadowColor = "#666666";
context.fillStyle = "#FFFFFF";
context.shadowColor = "#666666";
context.fillText(options.unicodelabel, text_x - 4, 2);
context.fillText(options.unicodelabel, text_x, 5);
context.fillStyle = color0;
context.fillText(options.unicodelabel, text_x + 4, 8);
context.fillText(options.unicodelabel, text_x - 4, 2);
context.fillText(options.unicodelabel, text_x, 5);
context.fillStyle = color0;
context.fillText(options.unicodelabel, text_x + 4, 8);
context.strokeStyle = "#FFFFFF";
context.strokeText(options.unicodelabel, text_x + 4, 8);
} else {
context.font =
"normal normal normal " + (fontsize - 3) + "px " + font;
context.strokeStyle = "#FFFFFF";
context.strokeText(options.unicodelabel, text_x + 4, 8);
context.textBaseline = "top";
var textmetric = context.measureText(options.unicodelabel);
text_x = Math.floor(canvas.width / 2 - textmetric.width / 2);
canvas.fillColor = color0;
//console.debug('textmetric', textmetric);
return canvas;
};
context.shadowOffsetX = 2;
context.shadowOffsetY = 2;
context.shadowBlur = 0;
context.shadowColor = "#FFFFFF";
context.fillStyle = color0;
context.fillText(options.unicodelabel, text_x + 1, 6);
function createGroupedIcon(theoptions) {
theoptions.scale = theoptions.scale || 1;
theoptions.fontsize = theoptions.fontsize || 26;
context.shadowOffsetX = 2;
context.shadowOffsetY = 2;
context.shadowBlur = 1;
context.shadowColor = "#FFFFFF";
context.strokeStyle = color1;
context.strokeText(options.unicodelabel, text_x + 1, 6);
}
var markerCanvas = generateGroupedCanvas(theoptions),
markerOpts = {};
canvas.fillColor = color0;
var scale = theoptions.scale;
return canvas;
};
theoptions.type = "transparent";
Object.assign(markerOpts, theoptions);
Object.assign(markerOpts, {
origin: { x: 0, y: 0 },
anchor: { x: 27 * scale, y: 24 * scale },
size: { width: 54, height: 48 },
scaledSize: { width: 54 * scale, height: 48 * scale }
});
var url = markerCanvas.toDataURL(),
fillColor = markerCanvas.fillColor,
iconObj = new IconObject(url, fillColor, markerOpts);
return iconObj;
}
/** global: google */
var generateTransparentCanvas = function(options) {
var text_x,
canvas = options.canvas || document.createElement("canvas"),
context = canvas.getContext("2d"),
font = options.font || "fontello",
fontsize = options.fontsize || 26;
canvas.width = 54;
canvas.height = 48;
context.clearRect(0, 0, canvas.width, canvas.height);
var colors = getColors(options),
color0 = colors[0],
color1 = colors[1];
context.beginPath();
context.font = "normal normal normal " + (fontsize - 3) + "px " + font;
context.textBaseline = "top";
var textmetric = context.measureText(options.unicodelabel);
text_x = Math.floor(canvas.width / 2 - textmetric.width / 2);
//console.debug('textmetric', textmetric);
context.shadowOffsetX = 2;
context.shadowOffsetY = 2;
context.shadowBlur = 0;
context.shadowColor = "#FFFFFF";
context.fillStyle = color0;
context.fillText(options.unicodelabel, text_x + 1, 6);
context.shadowOffsetX = 2;
context.shadowOffsetY = 2;
context.shadowBlur = 1;
context.shadowColor = "#FFFFFF";
context.strokeStyle = color1;
context.strokeText(options.unicodelabel, text_x + 1, 6);
canvas.fillColor = color0;
return canvas;
};
function createTransparentMarkerIcon(theoptions) {
theoptions.scale = theoptions.scale || 1;

@@ -792,12 +836,13 @@ theoptions.fontsize = theoptions.fontsize || 26;

if (window.google && window.google.maps) {
Object.assign(markerOpts, {
size: new google.maps.Size(54 * scale, 48 * scale),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(27 * scale, 24 * scale),
scaledSize: new google.maps.Size(54 * scale, 48 * scale)
});
}
var iconObj = new IconObject(markerCanvas, markerOpts);
Object.assign(markerOpts, {
origin: { x: 0, y: 0 },
anchor: { x: 27 * scale, y: 24 * scale },
size: { width: 54, height: 48 },
scaledSize: { width: 54 * scale, height: 48 * scale }
});
var url = markerCanvas.toDataURL(),
fillColor = markerCanvas.fillColor,
iconObj = new IconObject(url, fillColor, markerOpts);
return iconObj;

@@ -821,23 +866,35 @@ }

createClusterIcon: createClusterIcon,
serializeOptions: function(options) {
if (typeof options !== "object") {
createGroupedIcon: createGroupedIcon,
readCache: function(cacheKey, options) {
if (options.no_cache) {
return null;
}
var cleanOptions = omit(options, function(prop) {
return prop.indexOf("gm_") === 0;
}),
sortedOpts = Object.entries(cleanOptions)
.filter(function(item) {
return (
typeof item[1] !== "function" &&
typeof item[1] !== "object"
);
})
.sort();
return JSON.stringify(sortedOpts);
var cached = window.sessionStorage.getItem(cacheKey);
if (cached === null) {
return null;
}
var cachedObj = JSON.parse(cached);
var iconObj = new IconObject(
cachedObj.url,
cachedObj.fillColor,
omit(cachedObj, function(key) {
return ["url", "fillColor"].indexOf(key) !== -1;
})
);
iconObj.cached = true;
return iconObj;
},
setCache: function(cacheKey, iconObj) {
var cached = iconObj.toJSON();
cached.url = iconObj.url;
window.sessionStorage.setItem(cacheKey, JSON.stringify(cached));
return iconObj;
},
generateAutoicon: function(options) {
var generatorFN = MarkerFactory.createFatMarkerIcon,
iconObj;
options.type = "fatmarker";
var generatorFN;

@@ -847,24 +904,23 @@ if (!options.is_icon) {

generatorFN = MarkerFactory.createTextMarker;
} else if (options.shadow || options.type === "grouped") {
options.type = "grouped";
generatorFN = MarkerFactory.createGroupedIcon;
} else if (options.transparent_background) {
options.type = "transparent";
generatorFN = MarkerFactory.createTransparentMarkerIcon;
} else {
generatorFN = MarkerFactory.createFatMarkerIcon;
options.type = "fatmarker";
}
if (!options.no_cache) {
var cacheKey = MarkerFactory.serializeOptions(options);
iconObj = window.sessionStorage.getItem(cacheKey);
if (iconObj !== null && !options.no_cache) {
return JSON.parse(iconObj);
}
var cacheKey = serializeOptions(options);
var iconObj = MarkerFactory.readCache(cacheKey, options);
if (iconObj === null) {
iconObj = generatorFN(options);
iconObj.cached = false;
}
iconObj = generatorFN(options);
if (!options.no_cache) {
var cached = iconObj.toJSON();
cached.url = iconObj.url;
window.sessionStorage.setItem(cacheKey, JSON.stringify(cached));
iconObj.cacheKey = cacheKey;
if (options.no_cache) {
return iconObj;
}
return iconObj;
return MarkerFactory.setCache(cacheKey, iconObj);
},

@@ -890,3 +946,3 @@ /**

darkenfactor = darkenfactor || 1;
opacity = opacity || 1;
opacity = isNaN(parseFloat(opacity, 10)) ? 1 : parseFloat(opacity, 10);

@@ -925,3 +981,4 @@ if (somecolor.indexOf("hsl") !== -1) {

padHex(rgb.g.toString(16)),
padHex(rgb.b.toString(16))
padHex(rgb.b.toString(16)),
rgb.a === 0 ? "00" : ""
].join("");

@@ -928,0 +985,0 @@ return parsedcolor;

@@ -7,602 +7,606 @@ (function (global, factory) {

function hslaString(hslcolor) {
if (hslcolor.a) {
return (
"hsla(" +
hslcolor.h +
"," +
hslcolor.s +
"%," +
hslcolor.l +
"%," +
hslcolor.a +
")"
);
function hslaString(hslcolor) {
if (hslcolor.a !== undefined) {
return (
"hsla(" +
hslcolor.h +
"," +
hslcolor.s +
"%," +
hslcolor.l +
"%," +
parseFloat(hslcolor.a, 10) +
")"
);
}
return "hsl(" + hslcolor.h + "," + hslcolor.s + "%," + hslcolor.l + "%)";
}
return "hsl(" + hslcolor.h + "," + hslcolor.s + "%," + hslcolor.l + "%)";
}
function rgbaString(hexcolor) {
if (hexcolor.a) {
return (
"rgba(" +
hexcolor.r +
"," +
hexcolor.g +
"," +
hexcolor.b +
"," +
hexcolor.a +
")"
);
function rgbaString(hexcolor) {
if (hexcolor.a !== undefined) {
return (
"rgba(" +
hexcolor.r +
"," +
hexcolor.g +
"," +
hexcolor.b +
"," +
parseFloat(hexcolor.a, 10) +
")"
);
}
return "rgb(" + hexcolor.r + "," + hexcolor.g + "," + hexcolor.b + ")";
}
return "rgb(" + hexcolor.r + "," + hexcolor.g + "," + hexcolor.b + ")";
}
function parseHalf(foo) {
return parseInt(foo / 2, 10);
}
function parseHalf(foo) {
return parseInt(foo / 2, 10);
}
function compact(array) {
var index = -1,
length = array ? array.length : 0,
resIndex = 0,
result = [];
function compact(array) {
var index = -1,
length = array ? array.length : 0,
resIndex = 0,
result = [];
while (++index < length) {
var value = array[index];
if (value) {
result[resIndex++] = value;
while (++index < length) {
var value = array[index];
if (value) {
result[resIndex++] = value;
}
}
return result;
}
return result;
}
function omit(obj, fn) {
var target = {};
for (var i in obj) {
if (fn(i)) {
continue;
function omit(obj, fn) {
var target = {};
for (var i in obj) {
if (fn(i)) {
continue;
}
if (!Object.prototype.hasOwnProperty.call(obj, i)) {
continue;
}
target[i] = obj[i];
}
if (!Object.prototype.hasOwnProperty.call(obj, i)) {
continue;
return target;
}
function serializeOptions(options) {
if (typeof options !== "object") {
return null;
}
target[i] = obj[i];
var cleanOptions = omit(options, function(prop) {
return prop.indexOf("gm_") === 0;
}),
sortedOpts = Object.entries(cleanOptions)
.filter(function(item) {
return (
typeof item[1] !== "function" &&
typeof item[1] !== "object" &&
item[1] !== null &&
typeof item[1] !== "undefined"
);
})
.sort();
return JSON.stringify(sortedOpts);
}
return target;
}
function IconObject(canvas, markerOpts) {
this.url = canvas.toDataURL();
this.fillColor = canvas.fillColor;
this.markerOpts = markerOpts;
Object.assign(this, markerOpts);
return this;
}
function IconObject(url, fillColor, markerOpts) {
this.url = url;
this.fillColor = fillColor;
this.markerOpts = markerOpts;
Object.assign(this, markerOpts);
return this;
}
IconObject.prototype.toJSON = function() {
return omit(this.markerOpts, function(prop) {
return prop.indexOf("gm_") === 0 || prop === "url";
});
};
IconObject.prototype.toJSON = function() {
var serialized = omit(this.markerOpts, function(prop) {
return prop.indexOf("gm_") === 0 || prop === "url";
});
serialized.fillColor = this.fillColor;
return serialized;
};
/** global: google */
function createClusterIcon(theoptions) {
var generateClusterCanvas = function(options) {
var canvas = options.canvas || document.createElement("canvas"),
anchorX = 27,
anchorY = 53,
radius = anchorX - 9,
color1,
font = options.font || "fontello",
fontsize = options.fontsize || 14,
context = canvas.getContext("2d");
/** global: google */
canvas.width = anchorX * 2;
canvas.height = anchorY + 1;
var generateClusterCanvas = function(options) {
var canvas = options.canvas || document.createElement("canvas"),
anchorX = 27,
anchorY = 53,
radius = anchorX - 9,
color1,
font = options.font || "fontello",
fontsize = options.fontsize || 14,
context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
context.moveTo(anchorX, anchorY);
canvas.width = anchorX * 2;
canvas.height = anchorY + 1;
var labelvalue = parseInt(options.label, 10);
if (labelvalue < 10) {
color1 = "orange";
fontsize = 14;
} else if (labelvalue < 30) {
color1 = "red";
fontsize = 15;
} else {
color1 = "purple";
fontsize = 16;
}
if (labelvalue > 99) {
radius = radius + 3;
context.setLineDash([5, 5]);
context.beginPath();
context.arc(
anchorX,
2 + 0.5 * anchorY,
radius + 7,
0,
2 * Math.PI,
false
);
context.fillStyle = "transparent";
context.strokeStyle = color1;
context.lineWidth = 2;
context.fill();
context.stroke();
}
context.clearRect(0, 0, canvas.width, canvas.height);
context.moveTo(anchorX, anchorY);
context.setLineDash([5, 5]);
context.beginPath();
context.arc(
anchorX,
2 + 0.5 * anchorY,
radius + 2,
0,
2 * Math.PI,
false
);
context.fillStyle = "transparent";
context.strokeStyle = color1;
context.lineWidth = 2;
context.fill();
context.stroke();
var labelvalue = parseInt(options.label, 10);
if (labelvalue < 10) {
color1 = "orange";
fontsize = 14;
} else if (labelvalue < 30) {
color1 = "red";
fontsize = 15;
} else {
color1 = "purple";
fontsize = 16;
}
if (labelvalue > 99) {
radius = radius + 3;
context.setLineDash([5, 5]);
context.beginPath();
context.arc(
anchorX,
2 + 0.5 * anchorY,
radius + 7,
0,
2 * Math.PI,
false
);
context.fillStyle = "transparent";
context.strokeStyle = color1;
context.lineWidth = 2;
context.fill();
context.stroke();
}
// Círculo blanco
context.setLineDash([5, 0]);
context.beginPath();
context.arc(
anchorX,
2 + 0.5 * anchorY,
radius - 3,
0,
2 * Math.PI,
false
);
context.fillStyle = "white";
context.strokeStyle = color1;
context.lineWidth = 4;
context.fill();
context.stroke();
context.setLineDash([5, 5]);
context.beginPath();
context.arc(anchorX, 2 + 0.5 * anchorY, radius + 2, 0, 2 * Math.PI, false);
context.fillStyle = "transparent";
context.strokeStyle = color1;
context.lineWidth = 2;
context.fill();
context.stroke();
context.beginPath();
// Círculo blanco
context.setLineDash([5, 0]);
context.beginPath();
context.arc(anchorX, 2 + 0.5 * anchorY, radius - 3, 0, 2 * Math.PI, false);
context.fillStyle = "white";
context.strokeStyle = color1;
context.lineWidth = 4;
context.fill();
context.stroke();
context.font = "normal normal normal " + fontsize + "px " + font;
context.fillStyle = "#333";
context.textBaseline = "top";
context.beginPath();
var textWidth = context.measureText(options.label),
text_x = options.label,
label_x = Math.floor(canvas.width / 2 - textWidth.width / 2),
label_y = 1 + Math.floor(canvas.height / 2 - fontsize / 2);
context.font = "normal normal normal " + fontsize + "px " + font;
context.fillStyle = "#333";
context.textBaseline = "top";
// centre the text.
context.fillText(text_x, label_x, label_y);
var textWidth = context.measureText(options.label),
text_x = options.label,
label_x = Math.floor(canvas.width / 2 - textWidth.width / 2),
label_y = 1 + Math.floor(canvas.height / 2 - fontsize / 2);
return canvas;
};
theoptions.scale = theoptions.scale || 1;
var markerCanvas = generateClusterCanvas(theoptions),
markerOpts = {},
scale = theoptions.scale;
// centre the text.
context.fillText(text_x, label_x, label_y);
Object.assign(markerOpts, theoptions);
return canvas;
};
function createClusterIcon(theoptions) {
theoptions.scale = theoptions.scale || 1;
var markerCanvas = generateClusterCanvas(theoptions),
markerOpts = {},
scale = theoptions.scale;
if (window && window.google && window.google.maps) {
Object.assign(markerOpts, {
size: new google.maps.Size(54, 48),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(27 * scale, 24 * scale),
scaledSize: new google.maps.Size(54 * scale, 48 * scale)
});
}
Object.assign(markerOpts, theoptions);
var iconObj = new IconObject(markerCanvas, markerOpts);
Object.assign(markerOpts, {
origin: { x: 0, y: 0 },
anchor: { x: 27 * scale, y: 24 * scale },
size: { width: 54, height: 48 },
scaledSize: { width: 54 * scale, height: 48 * scale }
});
return iconObj;
}
var url = markerCanvas.toDataURL(),
fillColor = markerCanvas.fillColor,
iconObj = new IconObject(url, fillColor, markerOpts);
/** global: google, r, g, b */
return iconObj;
}
function parseHex(hexstring, opacity, darkenfactor) {
var hexcolor = {
hex: hexstring
};
darkenfactor = darkenfactor || 1;
/** global: google, r, g, b */
hexstring = hexstring.replace("#", "");
if (hexstring.length === 3) {
hexstring =
hexstring[0] +
hexstring[0] +
hexstring[1] +
hexstring[1] +
hexstring[2] +
hexstring[2];
}
if (isNaN(parseFloat(opacity, 10))) {
opacity = 1;
}
function parseHex(hexstring, opacity, darkenfactor) {
var hexcolor = {
hex: hexstring
};
darkenfactor = darkenfactor || 1;
hexcolor.r = parseInt(
darkenfactor * parseInt(hexstring.substring(0, 2), 16),
10
);
hexcolor.g = parseInt(
darkenfactor * parseInt(hexstring.substring(2, 4), 16),
10
);
hexcolor.b = parseInt(
darkenfactor * parseInt(hexstring.substring(4, 6), 16),
10
);
hexcolor.a = opacity;
hexcolor.fillColor = rgbaString(hexcolor);
hexcolor.strokeColor = [
"rgba(" + parseHalf(hexcolor.r),
parseHalf(hexcolor.g),
parseHalf(hexcolor.b),
hexcolor.a + ")"
].join(",");
hexcolor.rgb = hexcolor.fillColor;
return hexcolor;
}
hexstring = hexstring.replace("#", "");
if (hexstring.length === 3) {
hexstring =
hexstring[0] +
hexstring[0] +
hexstring[1] +
hexstring[1] +
hexstring[2] +
hexstring[2];
}
if (isNaN(parseFloat(opacity, 10))) {
opacity = 1;
}
function parseHSL(hslstring, opacity) {
var hslcolor = {},
hslcolor_stroke = {},
hslparts = compact(hslstring.split(/hsla?\(|,|\)|%/));
hexcolor.r = parseInt(
darkenfactor * parseInt(hexstring.substring(0, 2), 16),
10
);
hexcolor.g = parseInt(
darkenfactor * parseInt(hexstring.substring(2, 4), 16),
10
);
hexcolor.b = parseInt(
darkenfactor * parseInt(hexstring.substring(4, 6), 16),
10
);
hexcolor.a = opacity;
hexcolor.fillColor = rgbaString(hexcolor);
hexcolor.strokeColor = [
"rgba(" + parseHalf(hexcolor.r),
parseHalf(hexcolor.g),
parseHalf(hexcolor.b),
hexcolor.a + ")"
].join(",");
hexcolor.rgb = hexcolor.fillColor;
return hexcolor;
}
if (hslparts[3] === undefined) {
hslparts[3] = 1;
}
if (isNaN(parseFloat(opacity, 10))) {
opacity = 1;
}
function parseHSL(hslstring, opacity) {
var hslcolor = {},
hslcolor_stroke = {},
hslparts = compact(hslstring.split(/hsla?\(|,|\)|%/));
hslcolor.h = hslcolor_stroke.h = parseFloat(hslparts[0], 10);
hslcolor.s = hslcolor_stroke.s = parseFloat(hslparts[1], 10);
hslcolor.l = parseFloat(hslparts[2], 10);
hslcolor.a = hslcolor_stroke.a = parseFloat(opacity * hslparts[3], 10);
hslcolor_stroke.l = parseInt(hslcolor.l / 2, 10);
if (hslparts[3] === undefined) {
hslparts[3] = 1;
}
if (isNaN(parseFloat(opacity, 10))) {
opacity = 1;
}
hslcolor.fillColor = hslaString(hslcolor);
hslcolor.strokeColor = hslaString(hslcolor_stroke);
hslcolor.hsl = hslcolor.fillColor;
return hslcolor;
}
hslcolor.h = hslcolor_stroke.h = parseFloat(hslparts[0], 10);
hslcolor.s = hslcolor_stroke.s = parseFloat(hslparts[1], 10);
hslcolor.l = parseFloat(hslparts[2], 10);
hslcolor.a = hslcolor_stroke.a = parseFloat(opacity * hslparts[3], 10);
hslcolor_stroke.l = parseInt(hslcolor.l / 2, 10);
function parseRGB(rgbstring, opacity, darkenfactor) {
var rgbcolor = {},
rgbparts = compact(rgbstring.split(/rgba?\(|,|\)/));
hslcolor.fillColor = hslaString(hslcolor);
hslcolor.strokeColor = hslaString(hslcolor_stroke);
hslcolor.hsl = hslcolor.fillColor;
return hslcolor;
}
darkenfactor = darkenfactor || 1;
function parseRGB(rgbstring, opacity, darkenfactor) {
var rgbcolor = {},
rgbparts = compact(rgbstring.split(/rgba?\(|,|\)/));
if (rgbparts[3] === undefined) {
rgbparts[3] = 1;
}
darkenfactor = darkenfactor || 1;
if (isNaN(parseFloat(opacity, 10))) {
opacity = 1;
}
if (rgbparts[3] === undefined) {
rgbparts[3] = 1;
}
rgbcolor.r = parseInt(darkenfactor * (parseInt(rgbparts[0], 10) % 256), 10);
rgbcolor.g = parseInt(darkenfactor * (parseInt(rgbparts[1], 10) % 256), 10);
rgbcolor.b = parseInt(darkenfactor * (parseInt(rgbparts[2], 10) % 256), 10);
rgbcolor.a = parseFloat(opacity * rgbparts[3], 10);
rgbcolor.fillColor = rgbaString(rgbcolor);
rgbcolor.strokeColor =
"rgba(" +
rgbcolor.r / 2 +
"," +
rgbcolor.g / 2 +
"," +
rgbcolor.b / 2 +
"," +
rgbcolor.a +
")";
rgbcolor.rgb = rgbcolor.fillColor;
return rgbcolor;
}
if (isNaN(parseFloat(opacity, 10))) {
opacity = 1;
}
function hue2rgb(p, q, t) {
if (t < 0) {
t += 1;
}
if (t > 1) {
t -= 1;
}
if (t < 1 / 6) {
return p + (q - p) * 6 * t;
}
if (t < 1 / 2) {
return q;
}
if (t < 2 / 3) {
return p + (q - p) * (2 / 3 - t) * 6;
}
return p;
}
rgbcolor.r = parseInt(darkenfactor * (parseInt(rgbparts[0], 10) % 256), 10);
rgbcolor.g = parseInt(darkenfactor * (parseInt(rgbparts[1], 10) % 256), 10);
rgbcolor.b = parseInt(darkenfactor * (parseInt(rgbparts[2], 10) % 256), 10);
rgbcolor.a = parseFloat(opacity * rgbparts[3], 10);
rgbcolor.fillColor = rgbaString(rgbcolor);
rgbcolor.strokeColor =
"rgba(" +
rgbcolor.r / 2 +
"," +
rgbcolor.g / 2 +
"," +
rgbcolor.b / 2 +
"," +
rgbcolor.a +
")";
rgbcolor.rgb = rgbcolor.fillColor;
return rgbcolor;
}
function hslToRGB(h, s, l, a, darkenfactor) {
var r, g, b;
function hue2rgb(p, q, t) {
if (t < 0) {
t += 1;
}
if (t > 1) {
t -= 1;
}
if (t < 1 / 6) {
return p + (q - p) * 6 * t;
}
if (t < 1 / 2) {
return q;
}
if (t < 2 / 3) {
return p + (q - p) * (2 / 3 - t) * 6;
}
return p;
}
darkenfactor = darkenfactor || 1;
h = parseFloat(h, 10) / 360;
s = parseFloat(s, 10) / 100;
l = parseFloat(l, 10) / 100;
if (a === undefined) {
a = 1;
}
if (s === 0) {
r = g = b = l; // achromatic
} else {
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
var p = 2 * l - q;
r = hue2rgb(p, q, h + 1 / 3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - 1 / 3);
}
function hslToRGB(h, s, l, a, darkenfactor) {
var r, g, b;
if (a === undefined) {
a = 1;
}
darkenfactor = darkenfactor || 1;
h = parseFloat(h, 10) / 360;
s = parseFloat(s, 10) / 100;
l = parseFloat(l, 10) / 100;
if (a === undefined) {
a = 1;
}
if (s === 0) {
r = g = b = l; // achromatic
} else {
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
var p = 2 * l - q;
r = hue2rgb(p, q, h + 1 / 3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - 1 / 3);
}
var rgb = {
r: Math.round(r * 255 * darkenfactor),
g: Math.round(g * 255 * darkenfactor),
b: Math.round(b * 255 * darkenfactor),
a: parseFloat(a, 10)
};
if (a === undefined) {
a = 1;
}
rgb.fillColor = rgbaString(rgb);
var rgb = {
r: Math.round(r * 255 * darkenfactor),
g: Math.round(g * 255 * darkenfactor),
b: Math.round(b * 255 * darkenfactor),
a: parseFloat(a, 10)
};
return rgb;
}
rgb.fillColor = rgbaString(rgb);
function rgbToHSL(in_r, in_g, in_b, in_a) {
var h,
r = (in_r % 256) / 255,
g = (in_g % 256) / 255,
b = (in_b % 256) / 255,
a = in_a === undefined ? 1 : in_a,
max = Math.max(r, g, b),
min = Math.min(r, g, b),
sum = max + min,
diff = max - min,
s = sum > 1 ? diff / (2 - sum) : diff / sum;
return rgb;
}
switch (max) {
case r:
h = (g - b) / diff + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / diff + 2;
break;
case b:
h = (r - g) / diff + 4;
break;
default:
h = 0;
break;
}
function rgbToHSL(in_r, in_g, in_b, in_a) {
var h,
r = (in_r % 256) / 255,
g = (in_g % 256) / 255,
b = (in_b % 256) / 255,
a = in_a === undefined ? 1 : in_a,
max = Math.max(r, g, b),
min = Math.min(r, g, b),
sum = max + min,
diff = max - min,
s = sum > 1 ? diff / (2 - sum) : diff / sum;
h /= 6;
switch (max) {
case r:
h = (g - b) / diff + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / diff + 2;
break;
case b:
h = (r - g) / diff + 4;
break;
default:
h = 0;
break;
}
if (diff === 0) {
h = s = 0; // achromatic
}
h /= 6;
var hsl = {
h: Math.round(360 * h),
s: Math.round(100 * s),
l: Math.round(50 * sum),
a: Math.round(100 * a) / 100
};
if (diff === 0) {
h = s = 0; // achromatic
}
hsl.fillColor = hslaString(hsl);
var hsl = {
h: Math.round(360 * h),
s: Math.round(100 * s),
l: Math.round(50 * sum),
a: Math.round(100 * a) / 100
};
return hsl;
}
hsl.fillColor = hslaString(hsl);
function toDecColor(stringcolor) {
var parsedcolor = {};
if (!stringcolor) {
parsedcolor.fillColor = "rgba(100,250,50,0.99)";
} else if (stringcolor.indexOf("rgb") !== -1) {
parsedcolor = parseRGB(stringcolor);
} else if (stringcolor.indexOf("hsl") !== -1) {
parsedcolor = parseHSL(stringcolor);
} else {
parsedcolor = parseHex(stringcolor);
}
return hsl;
}
return parsedcolor;
}
function toDecColor(stringcolor) {
var parsedcolor = {};
if (!stringcolor) {
parsedcolor.fillColor = "rgba(100,250,50,0.99)";
} else if (stringcolor.indexOf("rgb") !== -1) {
parsedcolor = parseRGB(stringcolor);
} else if (stringcolor.indexOf("hsl") !== -1) {
parsedcolor = parseHSL(stringcolor);
} else {
parsedcolor = parseHex(stringcolor);
}
function getColor(val, range) {
var defaults = {
h: Math.floor((360 / range) * val),
s: 78, // constant saturation
l: 63, // constant luminance
a: 1
};
return parsedcolor;
}
return hslaString(defaults);
}
function getColor(val, range) {
var defaults = {
h: Math.floor((360 / range) * val),
s: 78, // constant saturation
l: 63, // constant luminance
a: 1
};
function getColor1() {
var defaults1 = {
h: 1,
s: 78, // constant saturation
l: 33, // constant luminance
a: 1
};
return hslaString(defaults1);
}
return hslaString(defaults);
}
function darken(stringcolor, factor) {
var darkercolor = {};
if (!factor) {
factor = 1;
}
if (stringcolor.fillColor.indexOf("rgb") !== -1) {
darkercolor.r = factor * parseHalf(stringcolor.r);
darkercolor.g = factor * parseHalf(stringcolor.g);
darkercolor.b = factor * parseHalf(stringcolor.b);
darkercolor.a = 0.99;
darkercolor.fillColor = rgbaString(darkercolor);
} else if (stringcolor.fillColor.indexOf("hsl") !== -1) {
darkercolor.h = stringcolor.h;
darkercolor.s = stringcolor.s;
darkercolor.l = factor * stringcolor.l - 30;
darkercolor.fillColor = hslaString(darkercolor);
}
function getColor1() {
var defaults1 = {
h: 1,
s: 78, // constant saturation
l: 33, // constant luminance
a: 1
};
return hslaString(defaults1);
}
return darkercolor;
}
function darken(stringcolor, factor) {
var darkercolor = {};
if (!factor) {
factor = 1;
}
if (stringcolor.fillColor.indexOf("rgb") !== -1) {
darkercolor.r = factor * parseHalf(stringcolor.r);
darkercolor.g = factor * parseHalf(stringcolor.g);
darkercolor.b = factor * parseHalf(stringcolor.b);
darkercolor.a = 0.99;
darkercolor.fillColor = rgbaString(darkercolor);
} else if (stringcolor.fillColor.indexOf("hsl") !== -1) {
darkercolor.h = stringcolor.h;
darkercolor.s = stringcolor.s;
darkercolor.l = factor * stringcolor.l - 30;
darkercolor.fillColor = hslaString(darkercolor);
}
function getColors(options) {
var color0, color1;
if (options.index !== undefined && options.count > 0) {
color0 = getColor(options.index, options.count);
color1 = getColor1();
} else {
var deccolor = toDecColor(options.color);
color0 = deccolor.fillColor;
color1 = darken(deccolor).fillColor;
}
return [color0, color1];
}
return darkercolor;
}
/** global: google */
function createTextMarker(theoptions) {
var generateCanvas = function(options) {
var canvas = document.createElement("canvas");
var ancho = 30,
alto = 40;
canvas.width = ancho + 18;
canvas.height = alto;
var x = canvas.width / 2,
y = canvas.height - 2,
radius = ancho / 2,
angulo = 0.6;
function getColors(options) {
var color0, color1;
if (options.index !== undefined && options.count > 0) {
color0 = getColor(options.index, options.count);
color1 = getColor1();
} else {
var deccolor = toDecColor(options.color);
color0 = deccolor.fillColor;
color1 = darken(deccolor).fillColor;
}
return [color0, color1];
}
var font = "'" + options.font + "'" || "Arial";
var fontsize = options.fontsize || 11;
/** global: google */
var generateCanvas = function(options) {
var canvas = document.createElement("canvas");
var ancho = 30,
alto = 40;
canvas.width = ancho + 18;
canvas.height = alto;
var x = canvas.width / 2,
y = canvas.height - 2,
radius = ancho / 2,
angulo = 0.6;
var context = canvas.getContext("2d");
var font = "'" + options.font + "'" || "Arial";
var fontsize = options.fontsize || 11;
context.clearRect(0, 0, canvas.width, canvas.height);
var context = canvas.getContext("2d");
var radius0 = 2 * radius,
cx = x + 0.95 * radius0,
cy = y + 0.45 * radius0;
context.clearRect(0, 0, canvas.width, canvas.height);
var grad = context.createLinearGradient(0, 0, 0, canvas.height),
colors = getColors(options),
color0 = colors[0],
color1 = colors[1];
var radius0 = 2 * radius,
cx = x + 0.95 * radius0,
cy = y + 0.45 * radius0;
grad.addColorStop(0, color0);
grad.addColorStop(1, color1);
var grad = context.createLinearGradient(0, 0, 0, canvas.height),
colors = getColors(options),
color0 = colors[0],
color1 = colors[1];
context.fillStyle = grad;
context.strokeStyle = "rgba(200,200,200,0.7)";
grad.addColorStop(0, color0);
grad.addColorStop(1, color1);
context.beginPath();
context.fillStyle = grad;
context.strokeStyle = "rgba(200,200,200,0.7)";
//arco izquierdo
context.arc(
cx - 1,
cy,
radius0,
(9 * Math.PI) / 8,
(-6 * Math.PI) / 8,
false
);
context.beginPath();
// arco superior
context.arc(x, (y - 7) / 2, radius, angulo, Math.PI - angulo, true);
//arco izquierdo
context.arc(
cx - 1,
cy,
radius0,
(9 * Math.PI) / 8,
(-6 * Math.PI) / 8,
false
);
//arco derecho
context.arc(
2 * x - cx + 1,
cy,
radius0,
(-0.95 * Math.PI) / 3,
-Math.PI / 8,
false
);
context.fill();
context.stroke();
// arco superior
context.arc(x, (y - 7) / 2, radius, angulo, Math.PI - angulo, true);
context.beginPath();
context.arc(x, 0.4 * y, (2 * radius) / 3, 0, 2 * Math.PI, false);
context.fillStyle = "white";
context.fill();
//arco derecho
context.arc(
2 * x - cx + 1,
cy,
radius0,
(-0.95 * Math.PI) / 3,
-Math.PI / 8,
false
);
context.fill();
context.stroke();
context.beginPath();
context.beginPath();
context.arc(x, 0.4 * y, (2 * radius) / 3, 0, 2 * Math.PI, false);
context.fillStyle = "white";
context.fill();
// Render Label
//context.font = "11pt Arial";
context.font = fontsize + "pt " + font;
context.textBaseline = "top";
context.beginPath();
var textWidth = context.measureText(options.label);
// Render Label
//context.font = "11pt Arial";
context.font = fontsize + "pt " + font;
context.textBaseline = "top";
if (textWidth.width > ancho || String(options.label).length > 3) {
context.rect(
x - 2 - textWidth.width / 2,
y - 30,
x - 2 + textWidth.width / 2,
y - 23
);
context.fillStyle = "#F7F0F0";
context.fill();
context.stroke();
}
var textWidth = context.measureText(options.label);
context.fillStyle = "black";
context.strokeStyle = "black";
// centre the text.
context.fillText(
options.label,
1 + Math.floor(canvas.width / 2 - textWidth.width / 2),
8
);
if (textWidth.width > ancho || String(options.label).length > 3) {
context.rect(
x - 2 - textWidth.width / 2,
y - 30,
x - 2 + textWidth.width / 2,
y - 23
);
context.fillStyle = "#F7F0F0";
context.fill();
context.stroke();
}
return canvas;
};
theoptions.scale = theoptions.scale || 0.75;
var markerCanvas = generateCanvas(theoptions),
markerOpts = {};
context.fillStyle = "black";
context.strokeStyle = "black";
// centre the text.
context.fillText(
options.label,
1 + Math.floor(canvas.width / 2 - textWidth.width / 2),
8
);
canvas.fillColor = color0;
theoptions.type = "textmarker";
return canvas;
};
function createTextMarker(theoptions) {
var scale = theoptions.scale || 0.75,
markerCanvas = generateCanvas(theoptions),
markerOpts = {};
Object.assign(markerOpts, theoptions);
theoptions.type = "textmarker";
if (window && window.google && window.google.maps) {
Object.assign(markerOpts, {
size: new google.maps.Size(48, 40),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(
24 * theoptions.scale,
40 * theoptions.scale
),
scaledSize: new google.maps.Size(
48 * theoptions.scale,
40 * theoptions.scale
)
});
}
var iconObj = new IconObject(markerCanvas, markerOpts);
Object.assign(markerOpts, theoptions);
return iconObj;
}
Object.assign(markerOpts, {
origin: { x: 0, y: 0 },
anchor: { x: 24 * scale, y: 40 * scale },
size: { width: 48, height: 40 },
scaledSize: { width: 48 * scale, height: 40 * scale }
});
/** global: google */
function createFatMarkerIcon(theoptions) {
var url = markerCanvas.toDataURL(),
fillColor = markerCanvas.fillColor,
iconObj = new IconObject(url, fillColor, markerOpts);
return iconObj;
}
/** global: google */
var generateFatCanvas = function(options) {

@@ -655,10 +659,3 @@ var canvas = options.canvas || document.createElement("canvas"),

context.beginPath();
context.arc(
anchorX,
2 + 0.5 * anchorY,
radius - 3,
0,
2 * Math.PI,
false
);
context.arc(anchorX, 2 + 0.5 * anchorY, radius - 3, 0, 2 * Math.PI, false);
context.fillStyle = "white";

@@ -685,286 +682,346 @@ context.fill();

var scale = theoptions.scale || 1,
markerCanvas = generateFatCanvas(theoptions),
markerOpts = {};
function createFatMarkerIcon(theoptions) {
var scale = theoptions.scale || 1,
markerCanvas = generateFatCanvas(theoptions),
markerOpts = {};
theoptions.type = "fatmarker";
theoptions.type = "fatmarker";
Object.assign(markerOpts, theoptions);
Object.assign(markerOpts, theoptions);
if (window && window.google && window.google.maps) {
Object.assign(markerOpts, {
size: new google.maps.Size(54, 48),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(21 * scale, 36 * scale),
scaledSize: new google.maps.Size(42 * scale, 36 * scale),
origin: { x: 0, y: 0 },
anchor: { x: 21 * scale, y: 36 * scale },
size: { width: 54, height: 48 },
scaledSize: { width: 42 * scale, height: 36 * scale },
scale: scale
});
var url = markerCanvas.toDataURL(),
fillColor = markerCanvas.fillColor,
iconObj = new IconObject(url, fillColor, markerOpts);
return iconObj;
}
var iconObj = new IconObject(markerCanvas, markerOpts);
return iconObj;
}
/** global: google */
function createTransparentMarkerIcon(theoptions) {
var generateTransparentCanvas = function(options) {
var text_x,
canvas = options.canvas || document.createElement("canvas"),
context = canvas.getContext("2d"),
font = options.font || "fontello",
fontsize = options.fontsize || 26;
/** global: google */
var generateGroupedCanvas = function(options) {
var text_x,
canvas = options.canvas || document.createElement("canvas"),
context = canvas.getContext("2d"),
font = options.font || "fontello",
fontsize = options.fontsize || 26;
canvas.width = 54;
canvas.height = 48;
context.clearRect(0, 0, canvas.width, canvas.height);
canvas.width = 54;
canvas.height = 48;
context.clearRect(0, 0, canvas.width, canvas.height);
var colors = getColors(options),
color0 = colors[0],
color1 = colors[1];
context.beginPath();
var colors = getColors(options),
color0 = colors[0];
context.beginPath();
if (options.shadow) {
context.font = "normal normal normal " + fontsize + "px " + font;
context.font = "normal normal normal " + fontsize + "px " + font;
context.textBaseline = "top";
var textWidth = context.measureText(options.unicodelabel);
text_x = Math.floor(canvas.width / 2 - textWidth.width / 2);
context.textBaseline = "top";
var textWidth = context.measureText(options.unicodelabel);
text_x = Math.floor(canvas.width / 2 - textWidth.width / 2);
context.shadowOffsetX = -2;
context.shadowOffsetY = -2;
context.shadowBlur = 0;
context.shadowOffsetX = -2;
context.shadowOffsetY = -2;
context.shadowBlur = 0;
context.fillStyle = "#FFFFFF";
context.shadowColor = "#666666";
context.fillStyle = "#FFFFFF";
context.shadowColor = "#666666";
context.fillText(options.unicodelabel, text_x - 4, 2);
context.fillText(options.unicodelabel, text_x, 5);
context.fillStyle = color0;
context.fillText(options.unicodelabel, text_x + 4, 8);
context.fillText(options.unicodelabel, text_x - 4, 2);
context.fillText(options.unicodelabel, text_x, 5);
context.fillStyle = color0;
context.fillText(options.unicodelabel, text_x + 4, 8);
context.strokeStyle = "#FFFFFF";
context.strokeText(options.unicodelabel, text_x + 4, 8);
} else {
context.font =
"normal normal normal " + (fontsize - 3) + "px " + font;
context.strokeStyle = "#FFFFFF";
context.strokeText(options.unicodelabel, text_x + 4, 8);
context.textBaseline = "top";
var textmetric = context.measureText(options.unicodelabel);
text_x = Math.floor(canvas.width / 2 - textmetric.width / 2);
canvas.fillColor = color0;
//console.debug('textmetric', textmetric);
return canvas;
};
context.shadowOffsetX = 2;
context.shadowOffsetY = 2;
context.shadowBlur = 0;
context.shadowColor = "#FFFFFF";
context.fillStyle = color0;
context.fillText(options.unicodelabel, text_x + 1, 6);
function createGroupedIcon(theoptions) {
theoptions.scale = theoptions.scale || 1;
theoptions.fontsize = theoptions.fontsize || 26;
context.shadowOffsetX = 2;
context.shadowOffsetY = 2;
context.shadowBlur = 1;
context.shadowColor = "#FFFFFF";
context.strokeStyle = color1;
context.strokeText(options.unicodelabel, text_x + 1, 6);
}
var markerCanvas = generateGroupedCanvas(theoptions),
markerOpts = {};
canvas.fillColor = color0;
var scale = theoptions.scale;
return canvas;
};
theoptions.type = "transparent";
theoptions.scale = theoptions.scale || 1;
theoptions.fontsize = theoptions.fontsize || 26;
Object.assign(markerOpts, theoptions);
var markerCanvas = generateTransparentCanvas(theoptions),
markerOpts = {};
Object.assign(markerOpts, {
origin: { x: 0, y: 0 },
anchor: { x: 27 * scale, y: 24 * scale },
size: { width: 54, height: 48 },
scaledSize: { width: 54 * scale, height: 48 * scale }
});
var scale = theoptions.scale;
var url = markerCanvas.toDataURL(),
fillColor = markerCanvas.fillColor,
iconObj = new IconObject(url, fillColor, markerOpts);
theoptions.type = "transparent";
return iconObj;
}
Object.assign(markerOpts, theoptions);
/** global: google */
var generateTransparentCanvas = function(options) {
var text_x,
canvas = options.canvas || document.createElement("canvas"),
context = canvas.getContext("2d"),
font = options.font || "fontello",
fontsize = options.fontsize || 26;
if (window.google && window.google.maps) {
Object.assign(markerOpts, {
size: new google.maps.Size(54 * scale, 48 * scale),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(27 * scale, 24 * scale),
scaledSize: new google.maps.Size(54 * scale, 48 * scale)
});
}
var iconObj = new IconObject(markerCanvas, markerOpts);
canvas.width = 54;
canvas.height = 48;
context.clearRect(0, 0, canvas.width, canvas.height);
return iconObj;
}
var colors = getColors(options),
color0 = colors[0],
color1 = colors[1];
context.beginPath();
/** global: google, r, g, b */
context.font = "normal normal normal " + (fontsize - 3) + "px " + font;
function padHex(str_in) {
if (("" + str_in).length === 1) {
return "0" + String(str_in);
} else {
return String(str_in);
}
}
context.textBaseline = "top";
var textmetric = context.measureText(options.unicodelabel);
text_x = Math.floor(canvas.width / 2 - textmetric.width / 2);
var MarkerFactory = {
createTransparentMarkerIcon: createTransparentMarkerIcon,
createFatMarkerIcon: createFatMarkerIcon,
createTextMarker: createTextMarker,
createClusterIcon: createClusterIcon,
serializeOptions: function(options) {
if (typeof options !== "object") {
return null;
}
var cleanOptions = omit(options, function(prop) {
return prop.indexOf("gm_") === 0;
}),
sortedOpts = Object.entries(cleanOptions)
.filter(function(item) {
return (
typeof item[1] !== "function" &&
typeof item[1] !== "object"
);
})
.sort();
return JSON.stringify(sortedOpts);
},
generateAutoicon: function(options) {
var generatorFN = MarkerFactory.createFatMarkerIcon,
iconObj;
options.type = "fatmarker";
//console.debug('textmetric', textmetric);
if (!options.is_icon) {
options.type = "textmarker";
generatorFN = MarkerFactory.createTextMarker;
} else if (options.transparent_background) {
options.type = "transparent";
generatorFN = MarkerFactory.createTransparentMarkerIcon;
}
context.shadowOffsetX = 2;
context.shadowOffsetY = 2;
context.shadowBlur = 0;
context.shadowColor = "#FFFFFF";
context.fillStyle = color0;
context.fillText(options.unicodelabel, text_x + 1, 6);
if (!options.no_cache) {
var cacheKey = MarkerFactory.serializeOptions(options);
context.shadowOffsetX = 2;
context.shadowOffsetY = 2;
context.shadowBlur = 1;
context.shadowColor = "#FFFFFF";
context.strokeStyle = color1;
context.strokeText(options.unicodelabel, text_x + 1, 6);
iconObj = window.sessionStorage.getItem(cacheKey);
if (iconObj !== null && !options.no_cache) {
return JSON.parse(iconObj);
}
}
canvas.fillColor = color0;
iconObj = generatorFN(options);
return canvas;
};
if (!options.no_cache) {
var cached = iconObj.toJSON();
cached.url = iconObj.url;
window.sessionStorage.setItem(cacheKey, JSON.stringify(cached));
}
return iconObj;
},
/**
* Receives a color string rgb(a), hsl(a) or hex, returns its components
* in rgba and hsla, with optional transparency
* plus a darkened version (default is half of each RGB component) and a
*
* @param {string} somecolor - A color string in rgb(a), hsl(a) or hex format
* @param {Number} opacity - Opacity to apply to the color. Optional, default 1
* @param {Number} darkenfactor - How much darker should the resulting color be. Optional, default 1
*
* @return {Object} input color parsed and modified as requested
*/
parseColorString: function(somecolor, opacity, darkenfactor) {
var parsedcolor = {
original: somecolor
},
hsl,
rgb;
function createTransparentMarkerIcon(theoptions) {
theoptions.scale = theoptions.scale || 1;
theoptions.fontsize = theoptions.fontsize || 26;
darkenfactor = darkenfactor || 1;
opacity = opacity || 1;
var markerCanvas = generateTransparentCanvas(theoptions),
markerOpts = {};
if (somecolor.indexOf("hsl") !== -1) {
hsl = parseHSL(somecolor, opacity);
rgb = hslToRGB(hsl.h, hsl.s, hsl.l, hsl.a, darkenfactor);
} else if (somecolor.indexOf("rgb") !== -1) {
rgb = parseRGB(somecolor, opacity, darkenfactor);
} else {
rgb = parseHex(somecolor, opacity, darkenfactor);
}
var scale = theoptions.scale;
hsl = rgbToHSL(rgb.r, rgb.g, rgb.b, rgb.a);
theoptions.type = "transparent";
parsedcolor.hsl = {
h: hsl.h,
s: hsl.s,
l: hsl.l,
a: hsl.a
};
parsedcolor.rgb = {
r: rgb.r,
g: rgb.g,
b: rgb.b,
a: rgb.a
};
Object.assign(markerOpts, theoptions);
parsedcolor.fillColor = rgb.fillColor;
parsedcolor.rgba = rgb.fillColor;
parsedcolor.hsla = hsl.fillColor;
parsedcolor.strokeColor = rgb.strokeColor;
parsedcolor.hex = [
"#",
padHex(rgb.r.toString(16)),
padHex(rgb.g.toString(16)),
padHex(rgb.b.toString(16))
].join("");
return parsedcolor;
},
Object.assign(markerOpts, {
origin: { x: 0, y: 0 },
anchor: { x: 27 * scale, y: 24 * scale },
size: { width: 54, height: 48 },
scaledSize: { width: 54 * scale, height: 48 * scale }
});
/**
* Generates an google maps marker (or an image as dataurl from the given options)
*
* @param {Object} options The options
* @return {Object} { description_of_the_return_value }
*/
autoIcon: function(options) {
if (typeof options !== "object") {
console.warn("autoIcon expects an object as its only parameter");
return null;
}
// unless explicitly set to false, the icon doesn't have a marker-like wrapper
options.transparent_background =
options.transparent_background !== false;
var url = markerCanvas.toDataURL(),
fillColor = markerCanvas.fillColor,
iconObj = new IconObject(url, fillColor, markerOpts);
options.label = String(options.label || "A");
options.color = options.color || "#FF0000";
return iconObj;
}
if (
options.label.length === 4 ||
options.label.substring(0, 2) === "0x"
) {
options.font = options.font || "fontello";
options.label = (options.label || "e836").slice(-4);
options.unicodelabel = String.fromCharCode("0x" + options.label);
options.scale = options.scale || 1;
options.is_icon = true;
/** global: google, r, g, b */
return MarkerFactory.generateAutoicon(options);
} else if (options.shadow) {
function padHex(str_in) {
if (("" + str_in).length === 1) {
return "0" + String(str_in);
} else {
return String(str_in);
}
}
return MarkerFactory.createClusterIcon(options);
} else {
options.scale = options.scale || 0.75;
options.label = String(options.label || "A");
options.fontsize = options.fontsize || 11;
options.font = options.font || "Arial";
// This is text I should print literally
var MarkerFactory = {
createTransparentMarkerIcon: createTransparentMarkerIcon,
createFatMarkerIcon: createFatMarkerIcon,
createTextMarker: createTextMarker,
createClusterIcon: createClusterIcon,
createGroupedIcon: createGroupedIcon,
return MarkerFactory.generateAutoicon(options);
}
}
};
readCache: function(cacheKey, options) {
if (options.no_cache) {
return null;
}
exports.MarkerFactory = MarkerFactory;
var cached = window.sessionStorage.getItem(cacheKey);
if (cached === null) {
return null;
}
Object.defineProperty(exports, '__esModule', { value: true });
var cachedObj = JSON.parse(cached);
var iconObj = new IconObject(
cachedObj.url,
cachedObj.fillColor,
omit(cachedObj, function(key) {
return ["url", "fillColor"].indexOf(key) !== -1;
})
);
iconObj.cached = true;
return iconObj;
},
setCache: function(cacheKey, iconObj) {
var cached = iconObj.toJSON();
cached.url = iconObj.url;
window.sessionStorage.setItem(cacheKey, JSON.stringify(cached));
return iconObj;
},
generateAutoicon: function(options) {
var generatorFN;
if (!options.is_icon) {
options.type = "textmarker";
generatorFN = MarkerFactory.createTextMarker;
} else if (options.shadow || options.type === "grouped") {
options.type = "grouped";
generatorFN = MarkerFactory.createGroupedIcon;
} else if (options.transparent_background) {
options.type = "transparent";
generatorFN = MarkerFactory.createTransparentMarkerIcon;
} else {
generatorFN = MarkerFactory.createFatMarkerIcon;
options.type = "fatmarker";
}
var cacheKey = serializeOptions(options);
var iconObj = MarkerFactory.readCache(cacheKey, options);
if (iconObj === null) {
iconObj = generatorFN(options);
iconObj.cached = false;
}
iconObj.cacheKey = cacheKey;
if (options.no_cache) {
return iconObj;
}
return MarkerFactory.setCache(cacheKey, iconObj);
},
/**
* Receives a color string rgb(a), hsl(a) or hex, returns its components
* in rgba and hsla, with optional transparency
* plus a darkened version (default is half of each RGB component) and a
*
* @param {string} somecolor - A color string in rgb(a), hsl(a) or hex format
* @param {Number} opacity - Opacity to apply to the color. Optional, default 1
* @param {Number} darkenfactor - How much darker should the resulting color be. Optional, default 1
*
* @return {Object} input color parsed and modified as requested
*/
parseColorString: function(somecolor, opacity, darkenfactor) {
var parsedcolor = {
original: somecolor
},
hsl,
rgb;
darkenfactor = darkenfactor || 1;
opacity = isNaN(parseFloat(opacity, 10)) ? 1 : parseFloat(opacity, 10);
if (somecolor.indexOf("hsl") !== -1) {
hsl = parseHSL(somecolor, opacity);
rgb = hslToRGB(hsl.h, hsl.s, hsl.l, hsl.a, darkenfactor);
} else if (somecolor.indexOf("rgb") !== -1) {
rgb = parseRGB(somecolor, opacity, darkenfactor);
} else {
rgb = parseHex(somecolor, opacity, darkenfactor);
}
hsl = rgbToHSL(rgb.r, rgb.g, rgb.b, rgb.a);
parsedcolor.hsl = {
h: hsl.h,
s: hsl.s,
l: hsl.l,
a: hsl.a
};
parsedcolor.rgb = {
r: rgb.r,
g: rgb.g,
b: rgb.b,
a: rgb.a
};
parsedcolor.fillColor = rgb.fillColor;
parsedcolor.rgba = rgb.fillColor;
parsedcolor.hsla = hsl.fillColor;
parsedcolor.strokeColor = rgb.strokeColor;
parsedcolor.hex = [
"#",
padHex(rgb.r.toString(16)),
padHex(rgb.g.toString(16)),
padHex(rgb.b.toString(16)),
rgb.a === 0 ? "00" : ""
].join("");
return parsedcolor;
},
/**
* Generates an google maps marker (or an image as dataurl from the given options)
*
* @param {Object} options The options
* @return {Object} { description_of_the_return_value }
*/
autoIcon: function(options) {
if (typeof options !== "object") {
console.warn("autoIcon expects an object as its only parameter");
return null;
}
// unless explicitly set to false, the icon doesn't have a marker-like wrapper
options.transparent_background =
options.transparent_background !== false;
options.label = String(options.label || "A");
options.color = options.color || "#FF0000";
if (
options.label.length === 4 ||
options.label.substring(0, 2) === "0x"
) {
options.font = options.font || "fontello";
options.label = (options.label || "e836").slice(-4);
options.unicodelabel = String.fromCharCode("0x" + options.label);
options.scale = options.scale || 1;
options.is_icon = true;
return MarkerFactory.generateAutoicon(options);
} else if (options.shadow) {
return MarkerFactory.createClusterIcon(options);
} else {
options.scale = options.scale || 0.75;
options.label = String(options.label || "A");
options.fontsize = options.fontsize || 11;
options.font = options.font || "Arial";
// This is text I should print literally
return MarkerFactory.generateAutoicon(options);
}
}
};
exports.MarkerFactory = MarkerFactory;
Object.defineProperty(exports, '__esModule', { value: true });
})));

@@ -1,2 +0,2 @@

!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory(global=global||{})}(this,function(exports){"use strict";function hslaString(hslcolor){return hslcolor.a?"hsla("+hslcolor.h+","+hslcolor.s+"%,"+hslcolor.l+"%,"+hslcolor.a+")":"hsl("+hslcolor.h+","+hslcolor.s+"%,"+hslcolor.l+"%)"}function rgbaString(hexcolor){return hexcolor.a?"rgba("+hexcolor.r+","+hexcolor.g+","+hexcolor.b+","+hexcolor.a+")":"rgb("+hexcolor.r+","+hexcolor.g+","+hexcolor.b+")"}function parseHalf(foo){return parseInt(foo/2,10)}function compact(array){for(var index=-1,length=array?array.length:0,resIndex=0,result=[];++index<length;){var value=array[index];value&&(result[resIndex++]=value)}return result}function omit(obj,fn){var target={};for(var i in obj)fn(i)||Object.prototype.hasOwnProperty.call(obj,i)&&(target[i]=obj[i]);return target}function IconObject(canvas,markerOpts){return this.url=canvas.toDataURL(),this.fillColor=canvas.fillColor,this.markerOpts=markerOpts,Object.assign(this,markerOpts),this}function parseHex(hexstring,opacity,darkenfactor){var hexcolor={hex:hexstring};return darkenfactor=darkenfactor||1,3===(hexstring=hexstring.replace("#","")).length&&(hexstring=hexstring[0]+hexstring[0]+hexstring[1]+hexstring[1]+hexstring[2]+hexstring[2]),isNaN(parseFloat(opacity,10))&&(opacity=1),hexcolor.r=parseInt(darkenfactor*parseInt(hexstring.substring(0,2),16),10),hexcolor.g=parseInt(darkenfactor*parseInt(hexstring.substring(2,4),16),10),hexcolor.b=parseInt(darkenfactor*parseInt(hexstring.substring(4,6),16),10),hexcolor.a=opacity,hexcolor.fillColor=rgbaString(hexcolor),hexcolor.strokeColor=["rgba("+parseHalf(hexcolor.r),parseHalf(hexcolor.g),parseHalf(hexcolor.b),hexcolor.a+")"].join(","),hexcolor.rgb=hexcolor.fillColor,hexcolor}function parseHSL(hslstring,opacity){var hslcolor={},hslcolor_stroke={},hslparts=compact(hslstring.split(/hsla?\(|,|\)|%/));return void 0===hslparts[3]&&(hslparts[3]=1),isNaN(parseFloat(opacity,10))&&(opacity=1),hslcolor.h=hslcolor_stroke.h=parseFloat(hslparts[0],10),hslcolor.s=hslcolor_stroke.s=parseFloat(hslparts[1],10),hslcolor.l=parseFloat(hslparts[2],10),hslcolor.a=hslcolor_stroke.a=parseFloat(opacity*hslparts[3],10),hslcolor_stroke.l=parseInt(hslcolor.l/2,10),hslcolor.fillColor=hslaString(hslcolor),hslcolor.strokeColor=hslaString(hslcolor_stroke),hslcolor.hsl=hslcolor.fillColor,hslcolor}function parseRGB(rgbstring,opacity,darkenfactor){var rgbcolor={},rgbparts=compact(rgbstring.split(/rgba?\(|,|\)/));return darkenfactor=darkenfactor||1,void 0===rgbparts[3]&&(rgbparts[3]=1),isNaN(parseFloat(opacity,10))&&(opacity=1),rgbcolor.r=parseInt(darkenfactor*(parseInt(rgbparts[0],10)%256),10),rgbcolor.g=parseInt(darkenfactor*(parseInt(rgbparts[1],10)%256),10),rgbcolor.b=parseInt(darkenfactor*(parseInt(rgbparts[2],10)%256),10),rgbcolor.a=parseFloat(opacity*rgbparts[3],10),rgbcolor.fillColor=rgbaString(rgbcolor),rgbcolor.strokeColor="rgba("+rgbcolor.r/2+","+rgbcolor.g/2+","+rgbcolor.b/2+","+rgbcolor.a+")",rgbcolor.rgb=rgbcolor.fillColor,rgbcolor}function hue2rgb(p,q,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?p+6*(q-p)*t:t<.5?q:t<2/3?p+(q-p)*(2/3-t)*6:p}function getColors(options){var color0,color1;if(void 0!==options.index&&options.count>0)color0=function(val,range){return hslaString({h:Math.floor(360/range*val),s:78,l:63,a:1})}(options.index,options.count),color1=hslaString({h:1,s:78,l:33,a:1});else{var deccolor=function(stringcolor){var parsedcolor={};return stringcolor?parsedcolor=-1!==stringcolor.indexOf("rgb")?parseRGB(stringcolor):-1!==stringcolor.indexOf("hsl")?parseHSL(stringcolor):parseHex(stringcolor):parsedcolor.fillColor="rgba(100,250,50,0.99)",parsedcolor}(options.color);color0=deccolor.fillColor,color1=function(stringcolor,factor){var darkercolor={};return factor||(factor=1),-1!==stringcolor.fillColor.indexOf("rgb")?(darkercolor.r=factor*parseHalf(stringcolor.r),darkercolor.g=factor*parseHalf(stringcolor.g),darkercolor.b=factor*parseHalf(stringcolor.b),darkercolor.a=.99,darkercolor.fillColor=rgbaString(darkercolor)):-1!==stringcolor.fillColor.indexOf("hsl")&&(darkercolor.h=stringcolor.h,darkercolor.s=stringcolor.s,darkercolor.l=factor*stringcolor.l-30,darkercolor.fillColor=hslaString(darkercolor)),darkercolor}(deccolor).fillColor}return[color0,color1]}function padHex(str_in){return 1===(""+str_in).length?"0"+String(str_in):String(str_in)}IconObject.prototype.toJSON=function(){return omit(this.markerOpts,function(prop){return 0===prop.indexOf("gm_")||"url"===prop})};var MarkerFactory={createTransparentMarkerIcon:function(theoptions){theoptions.scale=theoptions.scale||1,theoptions.fontsize=theoptions.fontsize||26;var markerCanvas=function(options){var text_x,canvas=options.canvas||document.createElement("canvas"),context=canvas.getContext("2d"),font=options.font||"fontello",fontsize=options.fontsize||26;canvas.width=54,canvas.height=48,context.clearRect(0,0,canvas.width,canvas.height);var colors=getColors(options),color0=colors[0],color1=colors[1];if(context.beginPath(),options.shadow){context.font="normal normal normal "+fontsize+"px "+font,context.textBaseline="top";var textWidth=context.measureText(options.unicodelabel);text_x=Math.floor(canvas.width/2-textWidth.width/2),context.shadowOffsetX=-2,context.shadowOffsetY=-2,context.shadowBlur=0,context.fillStyle="#FFFFFF",context.shadowColor="#666666",context.fillText(options.unicodelabel,text_x-4,2),context.fillText(options.unicodelabel,text_x,5),context.fillStyle=color0,context.fillText(options.unicodelabel,text_x+4,8),context.strokeStyle="#FFFFFF",context.strokeText(options.unicodelabel,text_x+4,8)}else{context.font="normal normal normal "+(fontsize-3)+"px "+font,context.textBaseline="top";var textmetric=context.measureText(options.unicodelabel);text_x=Math.floor(canvas.width/2-textmetric.width/2),context.shadowOffsetX=2,context.shadowOffsetY=2,context.shadowBlur=0,context.shadowColor="#FFFFFF",context.fillStyle=color0,context.fillText(options.unicodelabel,text_x+1,6),context.shadowOffsetX=2,context.shadowOffsetY=2,context.shadowBlur=1,context.shadowColor="#FFFFFF",context.strokeStyle=color1,context.strokeText(options.unicodelabel,text_x+1,6)}return canvas.fillColor=color0,canvas}(theoptions),markerOpts={},scale=theoptions.scale;return theoptions.type="transparent",Object.assign(markerOpts,theoptions),window.google&&window.google.maps&&Object.assign(markerOpts,{size:new google.maps.Size(54*scale,48*scale),origin:new google.maps.Point(0,0),anchor:new google.maps.Point(27*scale,24*scale),scaledSize:new google.maps.Size(54*scale,48*scale)}),new IconObject(markerCanvas,markerOpts)},createFatMarkerIcon:function(theoptions){var scale=theoptions.scale||1,markerCanvas=function(options){var canvas=options.canvas||document.createElement("canvas"),font=options.font||"fontello",fontsize=options.fontsize||14,context=canvas.getContext("2d"),grad=context.createLinearGradient(0,0,0,53);canvas.width=54,canvas.height=54;var colors=getColors(options),color0=colors[0],color1=colors[1];context.clearRect(0,0,canvas.width,canvas.height),grad.addColorStop(0,color0),grad.addColorStop(1,color1),context.fillStyle=grad,context.strokeStyle=color1,context.beginPath(),context.moveTo(27,53),context.arc(27,28.5,18,1.1,Math.PI-1.1,!0),context.lineTo(27,53),context.fill(),context.stroke(),context.beginPath(),context.arc(27,28.5,15,0,2*Math.PI,!1),context.fillStyle="white",context.fill(),context.beginPath(),context.font="normal normal normal "+fontsize+"px "+font,context.fillStyle=color1,context.textBaseline="top";var textWidth=context.measureText(options.unicodelabel),text_x=options.unicodelabel,label_x=Math.floor(canvas.width/2-textWidth.width/2),label_y=1+Math.floor(canvas.height/2-fontsize/2);return context.fillText(text_x,label_x,label_y),canvas.fillColor=color0,canvas}(theoptions),markerOpts={};return theoptions.type="fatmarker",Object.assign(markerOpts,theoptions),window&&window.google&&window.google.maps&&Object.assign(markerOpts,{size:new google.maps.Size(54,48),origin:new google.maps.Point(0,0),anchor:new google.maps.Point(21*scale,36*scale),scaledSize:new google.maps.Size(42*scale,36*scale),scale:scale}),new IconObject(markerCanvas,markerOpts)},createTextMarker:function(theoptions){theoptions.scale=theoptions.scale||.75;var markerCanvas=function(options){var canvas=document.createElement("canvas");canvas.width=48,canvas.height=40;var x=canvas.width/2,y=canvas.height-2,font="'"+options.font+"'"||"Arial",fontsize=options.fontsize||11,context=canvas.getContext("2d");context.clearRect(0,0,canvas.width,canvas.height);var cx=x+28.5,cy=y+13.5,grad=context.createLinearGradient(0,0,0,canvas.height),colors=getColors(options),color0=colors[0],color1=colors[1];grad.addColorStop(0,color0),grad.addColorStop(1,color1),context.fillStyle=grad,context.strokeStyle="rgba(200,200,200,0.7)",context.beginPath(),context.arc(cx-1,cy,30,9*Math.PI/8,-6*Math.PI/8,!1),context.arc(x,(y-7)/2,15,.6,Math.PI-.6,!0),context.arc(2*x-cx+1,cy,30,-.95*Math.PI/3,-Math.PI/8,!1),context.fill(),context.stroke(),context.beginPath(),context.arc(x,.4*y,10,0,2*Math.PI,!1),context.fillStyle="white",context.fill(),context.beginPath(),context.font=fontsize+"pt "+font,context.textBaseline="top";var textWidth=context.measureText(options.label);return(textWidth.width>30||String(options.label).length>3)&&(context.rect(x-2-textWidth.width/2,y-30,x-2+textWidth.width/2,y-23),context.fillStyle="#F7F0F0",context.fill(),context.stroke()),context.fillStyle="black",context.strokeStyle="black",context.fillText(options.label,1+Math.floor(canvas.width/2-textWidth.width/2),8),canvas}(theoptions),markerOpts={};return theoptions.type="textmarker",Object.assign(markerOpts,theoptions),window&&window.google&&window.google.maps&&Object.assign(markerOpts,{size:new google.maps.Size(48,40),origin:new google.maps.Point(0,0),anchor:new google.maps.Point(24*theoptions.scale,40*theoptions.scale),scaledSize:new google.maps.Size(48*theoptions.scale,40*theoptions.scale)}),new IconObject(markerCanvas,markerOpts)},createClusterIcon:function(theoptions){theoptions.scale=theoptions.scale||1;var markerCanvas=function(options){var color1,canvas=options.canvas||document.createElement("canvas"),radius=18,font=options.font||"fontello",fontsize=options.fontsize||14,context=canvas.getContext("2d");canvas.width=54,canvas.height=54,context.clearRect(0,0,canvas.width,canvas.height),context.moveTo(27,53);var labelvalue=parseInt(options.label,10);labelvalue<10?(color1="orange",fontsize=14):labelvalue<30?(color1="red",fontsize=15):(color1="purple",fontsize=16),labelvalue>99&&(radius+=3,context.setLineDash([5,5]),context.beginPath(),context.arc(27,28.5,radius+7,0,2*Math.PI,!1),context.fillStyle="transparent",context.strokeStyle=color1,context.lineWidth=2,context.fill(),context.stroke()),context.setLineDash([5,5]),context.beginPath(),context.arc(27,28.5,radius+2,0,2*Math.PI,!1),context.fillStyle="transparent",context.strokeStyle=color1,context.lineWidth=2,context.fill(),context.stroke(),context.setLineDash([5,0]),context.beginPath(),context.arc(27,28.5,radius-3,0,2*Math.PI,!1),context.fillStyle="white",context.strokeStyle=color1,context.lineWidth=4,context.fill(),context.stroke(),context.beginPath(),context.font="normal normal normal "+fontsize+"px "+font,context.fillStyle="#333",context.textBaseline="top";var textWidth=context.measureText(options.label),text_x=options.label,label_x=Math.floor(canvas.width/2-textWidth.width/2),label_y=1+Math.floor(canvas.height/2-fontsize/2);return context.fillText(text_x,label_x,label_y),canvas}(theoptions),markerOpts={},scale=theoptions.scale;return Object.assign(markerOpts,theoptions),window&&window.google&&window.google.maps&&Object.assign(markerOpts,{size:new google.maps.Size(54,48),origin:new google.maps.Point(0,0),anchor:new google.maps.Point(27*scale,24*scale),scaledSize:new google.maps.Size(54*scale,48*scale)}),new IconObject(markerCanvas,markerOpts)},serializeOptions:function(options){if("object"!=typeof options)return null;var cleanOptions=omit(options,function(prop){return 0===prop.indexOf("gm_")}),sortedOpts=Object.entries(cleanOptions).filter(function(item){return"function"!=typeof item[1]&&"object"!=typeof item[1]}).sort();return JSON.stringify(sortedOpts)},generateAutoicon:function(options){var iconObj,generatorFN=MarkerFactory.createFatMarkerIcon;if(options.type="fatmarker",options.is_icon?options.transparent_background&&(options.type="transparent",generatorFN=MarkerFactory.createTransparentMarkerIcon):(options.type="textmarker",generatorFN=MarkerFactory.createTextMarker),!options.no_cache){var cacheKey=MarkerFactory.serializeOptions(options);if(null!==(iconObj=window.sessionStorage.getItem(cacheKey))&&!options.no_cache)return JSON.parse(iconObj)}if(iconObj=generatorFN(options),!options.no_cache){var cached=iconObj.toJSON();cached.url=iconObj.url,window.sessionStorage.setItem(cacheKey,JSON.stringify(cached))}return iconObj},parseColorString:function(somecolor,opacity,darkenfactor){var hsl,rgb,parsedcolor={original:somecolor};return darkenfactor=darkenfactor||1,opacity=opacity||1,rgb=-1!==somecolor.indexOf("hsl")?function(h,s,l,a,darkenfactor){var r,g,b;if(darkenfactor=darkenfactor||1,h=parseFloat(h,10)/360,s=parseFloat(s,10)/100,l=parseFloat(l,10)/100,void 0===a&&(a=1),0===s)r=g=b=l;else{var q=l<.5?l*(1+s):l+s-l*s,p=2*l-q;r=hue2rgb(p,q,h+1/3),g=hue2rgb(p,q,h),b=hue2rgb(p,q,h-1/3)}void 0===a&&(a=1);var rgb={r:Math.round(255*r*darkenfactor),g:Math.round(255*g*darkenfactor),b:Math.round(255*b*darkenfactor),a:parseFloat(a,10)};return rgb.fillColor=rgbaString(rgb),rgb}((hsl=parseHSL(somecolor,opacity)).h,hsl.s,hsl.l,hsl.a,darkenfactor):-1!==somecolor.indexOf("rgb")?parseRGB(somecolor,opacity,darkenfactor):parseHex(somecolor,opacity,darkenfactor),hsl=function(in_r,in_g,in_b,in_a){var h,r=in_r%256/255,g=in_g%256/255,b=in_b%256/255,a=void 0===in_a?1:in_a,max=Math.max(r,g,b),min=Math.min(r,g,b),sum=max+min,diff=max-min,s=sum>1?diff/(2-sum):diff/sum;switch(max){case r:h=(g-b)/diff+(g<b?6:0);break;case g:h=(b-r)/diff+2;break;case b:h=(r-g)/diff+4;break;default:h=0}h/=6,0===diff&&(h=s=0);var hsl={h:Math.round(360*h),s:Math.round(100*s),l:Math.round(50*sum),a:Math.round(100*a)/100};return hsl.fillColor=hslaString(hsl),hsl}(rgb.r,rgb.g,rgb.b,rgb.a),parsedcolor.hsl={h:hsl.h,s:hsl.s,l:hsl.l,a:hsl.a},parsedcolor.rgb={r:rgb.r,g:rgb.g,b:rgb.b,a:rgb.a},parsedcolor.fillColor=rgb.fillColor,parsedcolor.rgba=rgb.fillColor,parsedcolor.hsla=hsl.fillColor,parsedcolor.strokeColor=rgb.strokeColor,parsedcolor.hex=["#",padHex(rgb.r.toString(16)),padHex(rgb.g.toString(16)),padHex(rgb.b.toString(16))].join(""),parsedcolor},autoIcon:function(options){return"object"!=typeof options?(console.warn("autoIcon expects an object as its only parameter"),null):(options.transparent_background=!1!==options.transparent_background,options.label=String(options.label||"A"),options.color=options.color||"#FF0000",4===options.label.length||"0x"===options.label.substring(0,2)?(options.font=options.font||"fontello",options.label=(options.label||"e836").slice(-4),options.unicodelabel=String.fromCharCode("0x"+options.label),options.scale=options.scale||1,options.is_icon=!0,MarkerFactory.generateAutoicon(options)):options.shadow?MarkerFactory.createClusterIcon(options):(options.scale=options.scale||.75,options.label=String(options.label||"A"),options.fontsize=options.fontsize||11,options.font=options.font||"Arial",MarkerFactory.generateAutoicon(options)))}};exports.MarkerFactory=MarkerFactory,Object.defineProperty(exports,"__esModule",{value:!0})});
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory(global=global||{})}(this,function(exports){"use strict";function hslaString(hslcolor){return void 0!==hslcolor.a?"hsla("+hslcolor.h+","+hslcolor.s+"%,"+hslcolor.l+"%,"+parseFloat(hslcolor.a,10)+")":"hsl("+hslcolor.h+","+hslcolor.s+"%,"+hslcolor.l+"%)"}function rgbaString(hexcolor){return void 0!==hexcolor.a?"rgba("+hexcolor.r+","+hexcolor.g+","+hexcolor.b+","+parseFloat(hexcolor.a,10)+")":"rgb("+hexcolor.r+","+hexcolor.g+","+hexcolor.b+")"}function parseHalf(foo){return parseInt(foo/2,10)}function compact(array){for(var index=-1,length=array?array.length:0,resIndex=0,result=[];++index<length;){var value=array[index];value&&(result[resIndex++]=value)}return result}function omit(obj,fn){var target={};for(var i in obj)fn(i)||Object.prototype.hasOwnProperty.call(obj,i)&&(target[i]=obj[i]);return target}function IconObject(url,fillColor,markerOpts){return this.url=url,this.fillColor=fillColor,this.markerOpts=markerOpts,Object.assign(this,markerOpts),this}function parseHex(hexstring,opacity,darkenfactor){var hexcolor={hex:hexstring};return darkenfactor=darkenfactor||1,3===(hexstring=hexstring.replace("#","")).length&&(hexstring=hexstring[0]+hexstring[0]+hexstring[1]+hexstring[1]+hexstring[2]+hexstring[2]),isNaN(parseFloat(opacity,10))&&(opacity=1),hexcolor.r=parseInt(darkenfactor*parseInt(hexstring.substring(0,2),16),10),hexcolor.g=parseInt(darkenfactor*parseInt(hexstring.substring(2,4),16),10),hexcolor.b=parseInt(darkenfactor*parseInt(hexstring.substring(4,6),16),10),hexcolor.a=opacity,hexcolor.fillColor=rgbaString(hexcolor),hexcolor.strokeColor=["rgba("+parseHalf(hexcolor.r),parseHalf(hexcolor.g),parseHalf(hexcolor.b),hexcolor.a+")"].join(","),hexcolor.rgb=hexcolor.fillColor,hexcolor}function parseHSL(hslstring,opacity){var hslcolor={},hslcolor_stroke={},hslparts=compact(hslstring.split(/hsla?\(|,|\)|%/));return void 0===hslparts[3]&&(hslparts[3]=1),isNaN(parseFloat(opacity,10))&&(opacity=1),hslcolor.h=hslcolor_stroke.h=parseFloat(hslparts[0],10),hslcolor.s=hslcolor_stroke.s=parseFloat(hslparts[1],10),hslcolor.l=parseFloat(hslparts[2],10),hslcolor.a=hslcolor_stroke.a=parseFloat(opacity*hslparts[3],10),hslcolor_stroke.l=parseInt(hslcolor.l/2,10),hslcolor.fillColor=hslaString(hslcolor),hslcolor.strokeColor=hslaString(hslcolor_stroke),hslcolor.hsl=hslcolor.fillColor,hslcolor}function parseRGB(rgbstring,opacity,darkenfactor){var rgbcolor={},rgbparts=compact(rgbstring.split(/rgba?\(|,|\)/));return darkenfactor=darkenfactor||1,void 0===rgbparts[3]&&(rgbparts[3]=1),isNaN(parseFloat(opacity,10))&&(opacity=1),rgbcolor.r=parseInt(darkenfactor*(parseInt(rgbparts[0],10)%256),10),rgbcolor.g=parseInt(darkenfactor*(parseInt(rgbparts[1],10)%256),10),rgbcolor.b=parseInt(darkenfactor*(parseInt(rgbparts[2],10)%256),10),rgbcolor.a=parseFloat(opacity*rgbparts[3],10),rgbcolor.fillColor=rgbaString(rgbcolor),rgbcolor.strokeColor="rgba("+rgbcolor.r/2+","+rgbcolor.g/2+","+rgbcolor.b/2+","+rgbcolor.a+")",rgbcolor.rgb=rgbcolor.fillColor,rgbcolor}function hue2rgb(p,q,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?p+6*(q-p)*t:t<.5?q:t<2/3?p+(q-p)*(2/3-t)*6:p}function getColors(options){var color0,color1;if(void 0!==options.index&&options.count>0)color0=function(val,range){return hslaString({h:Math.floor(360/range*val),s:78,l:63,a:1})}(options.index,options.count),color1=hslaString({h:1,s:78,l:33,a:1});else{var deccolor=function(stringcolor){var parsedcolor={};return stringcolor?parsedcolor=-1!==stringcolor.indexOf("rgb")?parseRGB(stringcolor):-1!==stringcolor.indexOf("hsl")?parseHSL(stringcolor):parseHex(stringcolor):parsedcolor.fillColor="rgba(100,250,50,0.99)",parsedcolor}(options.color);color0=deccolor.fillColor,color1=function(stringcolor,factor){var darkercolor={};return factor||(factor=1),-1!==stringcolor.fillColor.indexOf("rgb")?(darkercolor.r=factor*parseHalf(stringcolor.r),darkercolor.g=factor*parseHalf(stringcolor.g),darkercolor.b=factor*parseHalf(stringcolor.b),darkercolor.a=.99,darkercolor.fillColor=rgbaString(darkercolor)):-1!==stringcolor.fillColor.indexOf("hsl")&&(darkercolor.h=stringcolor.h,darkercolor.s=stringcolor.s,darkercolor.l=factor*stringcolor.l-30,darkercolor.fillColor=hslaString(darkercolor)),darkercolor}(deccolor).fillColor}return[color0,color1]}function padHex(str_in){return 1===(""+str_in).length?"0"+String(str_in):String(str_in)}IconObject.prototype.toJSON=function(){var serialized=omit(this.markerOpts,function(prop){return 0===prop.indexOf("gm_")||"url"===prop});return serialized.fillColor=this.fillColor,serialized};var generateClusterCanvas=function(options){var color1,canvas=options.canvas||document.createElement("canvas"),radius=18,font=options.font||"fontello",fontsize=options.fontsize||14,context=canvas.getContext("2d");canvas.width=54,canvas.height=54,context.clearRect(0,0,canvas.width,canvas.height),context.moveTo(27,53);var labelvalue=parseInt(options.label,10);labelvalue<10?(color1="orange",fontsize=14):labelvalue<30?(color1="red",fontsize=15):(color1="purple",fontsize=16),labelvalue>99&&(radius+=3,context.setLineDash([5,5]),context.beginPath(),context.arc(27,28.5,radius+7,0,2*Math.PI,!1),context.fillStyle="transparent",context.strokeStyle=color1,context.lineWidth=2,context.fill(),context.stroke()),context.setLineDash([5,5]),context.beginPath(),context.arc(27,28.5,radius+2,0,2*Math.PI,!1),context.fillStyle="transparent",context.strokeStyle=color1,context.lineWidth=2,context.fill(),context.stroke(),context.setLineDash([5,0]),context.beginPath(),context.arc(27,28.5,radius-3,0,2*Math.PI,!1),context.fillStyle="white",context.strokeStyle=color1,context.lineWidth=4,context.fill(),context.stroke(),context.beginPath(),context.font="normal normal normal "+fontsize+"px "+font,context.fillStyle="#333",context.textBaseline="top";var textWidth=context.measureText(options.label),text_x=options.label,label_x=Math.floor(canvas.width/2-textWidth.width/2),label_y=1+Math.floor(canvas.height/2-fontsize/2);return context.fillText(text_x,label_x,label_y),canvas},generateCanvas=function(options){var canvas=document.createElement("canvas");canvas.width=48,canvas.height=40;var x=canvas.width/2,y=canvas.height-2,font="'"+options.font+"'"||"Arial",fontsize=options.fontsize||11,context=canvas.getContext("2d");context.clearRect(0,0,canvas.width,canvas.height);var cx=x+28.5,cy=y+13.5,grad=context.createLinearGradient(0,0,0,canvas.height),colors=getColors(options),color0=colors[0],color1=colors[1];grad.addColorStop(0,color0),grad.addColorStop(1,color1),context.fillStyle=grad,context.strokeStyle="rgba(200,200,200,0.7)",context.beginPath(),context.arc(cx-1,cy,30,9*Math.PI/8,-6*Math.PI/8,!1),context.arc(x,(y-7)/2,15,.6,Math.PI-.6,!0),context.arc(2*x-cx+1,cy,30,-.95*Math.PI/3,-Math.PI/8,!1),context.fill(),context.stroke(),context.beginPath(),context.arc(x,.4*y,10,0,2*Math.PI,!1),context.fillStyle="white",context.fill(),context.beginPath(),context.font=fontsize+"pt "+font,context.textBaseline="top";var textWidth=context.measureText(options.label);return(textWidth.width>30||String(options.label).length>3)&&(context.rect(x-2-textWidth.width/2,y-30,x-2+textWidth.width/2,y-23),context.fillStyle="#F7F0F0",context.fill(),context.stroke()),context.fillStyle="black",context.strokeStyle="black",context.fillText(options.label,1+Math.floor(canvas.width/2-textWidth.width/2),8),canvas.fillColor=color0,canvas},generateFatCanvas=function(options){var canvas=options.canvas||document.createElement("canvas"),font=options.font||"fontello",fontsize=options.fontsize||14,context=canvas.getContext("2d"),grad=context.createLinearGradient(0,0,0,53);canvas.width=54,canvas.height=54;var colors=getColors(options),color0=colors[0],color1=colors[1];context.clearRect(0,0,canvas.width,canvas.height),grad.addColorStop(0,color0),grad.addColorStop(1,color1),context.fillStyle=grad,context.strokeStyle=color1,context.beginPath(),context.moveTo(27,53),context.arc(27,28.5,18,1.1,Math.PI-1.1,!0),context.lineTo(27,53),context.fill(),context.stroke(),context.beginPath(),context.arc(27,28.5,15,0,2*Math.PI,!1),context.fillStyle="white",context.fill(),context.beginPath(),context.font="normal normal normal "+fontsize+"px "+font,context.fillStyle=color1,context.textBaseline="top";var textWidth=context.measureText(options.unicodelabel),text_x=options.unicodelabel,label_x=Math.floor(canvas.width/2-textWidth.width/2),label_y=1+Math.floor(canvas.height/2-fontsize/2);return context.fillText(text_x,label_x,label_y),canvas.fillColor=color0,canvas},generateGroupedCanvas=function(options){var text_x,canvas=options.canvas||document.createElement("canvas"),context=canvas.getContext("2d"),font=options.font||"fontello",fontsize=options.fontsize||26;canvas.width=54,canvas.height=48,context.clearRect(0,0,canvas.width,canvas.height);var color0=getColors(options)[0];context.beginPath(),context.font="normal normal normal "+fontsize+"px "+font,context.textBaseline="top";var textWidth=context.measureText(options.unicodelabel);return text_x=Math.floor(canvas.width/2-textWidth.width/2),context.shadowOffsetX=-2,context.shadowOffsetY=-2,context.shadowBlur=0,context.fillStyle="#FFFFFF",context.shadowColor="#666666",context.fillText(options.unicodelabel,text_x-4,2),context.fillText(options.unicodelabel,text_x,5),context.fillStyle=color0,context.fillText(options.unicodelabel,text_x+4,8),context.strokeStyle="#FFFFFF",context.strokeText(options.unicodelabel,text_x+4,8),canvas.fillColor=color0,canvas},generateTransparentCanvas=function(options){var text_x,canvas=options.canvas||document.createElement("canvas"),context=canvas.getContext("2d"),font=options.font||"fontello",fontsize=options.fontsize||26;canvas.width=54,canvas.height=48,context.clearRect(0,0,canvas.width,canvas.height);var colors=getColors(options),color0=colors[0],color1=colors[1];context.beginPath(),context.font="normal normal normal "+(fontsize-3)+"px "+font,context.textBaseline="top";var textmetric=context.measureText(options.unicodelabel);return text_x=Math.floor(canvas.width/2-textmetric.width/2),context.shadowOffsetX=2,context.shadowOffsetY=2,context.shadowBlur=0,context.shadowColor="#FFFFFF",context.fillStyle=color0,context.fillText(options.unicodelabel,text_x+1,6),context.shadowOffsetX=2,context.shadowOffsetY=2,context.shadowBlur=1,context.shadowColor="#FFFFFF",context.strokeStyle=color1,context.strokeText(options.unicodelabel,text_x+1,6),canvas.fillColor=color0,canvas},MarkerFactory={createTransparentMarkerIcon:function(theoptions){theoptions.scale=theoptions.scale||1,theoptions.fontsize=theoptions.fontsize||26;var markerCanvas=generateTransparentCanvas(theoptions),markerOpts={},scale=theoptions.scale;return theoptions.type="transparent",Object.assign(markerOpts,theoptions),Object.assign(markerOpts,{origin:{x:0,y:0},anchor:{x:27*scale,y:24*scale},size:{width:54,height:48},scaledSize:{width:54*scale,height:48*scale}}),new IconObject(markerCanvas.toDataURL(),markerCanvas.fillColor,markerOpts)},createFatMarkerIcon:function(theoptions){var scale=theoptions.scale||1,markerCanvas=generateFatCanvas(theoptions),markerOpts={};return theoptions.type="fatmarker",Object.assign(markerOpts,theoptions),Object.assign(markerOpts,{origin:{x:0,y:0},anchor:{x:21*scale,y:36*scale},size:{width:54,height:48},scaledSize:{width:42*scale,height:36*scale},scale:scale}),new IconObject(markerCanvas.toDataURL(),markerCanvas.fillColor,markerOpts)},createTextMarker:function(theoptions){var scale=theoptions.scale||.75,markerCanvas=generateCanvas(theoptions),markerOpts={};return theoptions.type="textmarker",Object.assign(markerOpts,theoptions),Object.assign(markerOpts,{origin:{x:0,y:0},anchor:{x:24*scale,y:40*scale},size:{width:48,height:40},scaledSize:{width:48*scale,height:40*scale}}),new IconObject(markerCanvas.toDataURL(),markerCanvas.fillColor,markerOpts)},createClusterIcon:function(theoptions){theoptions.scale=theoptions.scale||1;var markerCanvas=generateClusterCanvas(theoptions),markerOpts={},scale=theoptions.scale;return Object.assign(markerOpts,theoptions),Object.assign(markerOpts,{origin:{x:0,y:0},anchor:{x:27*scale,y:24*scale},size:{width:54,height:48},scaledSize:{width:54*scale,height:48*scale}}),new IconObject(markerCanvas.toDataURL(),markerCanvas.fillColor,markerOpts)},createGroupedIcon:function(theoptions){theoptions.scale=theoptions.scale||1,theoptions.fontsize=theoptions.fontsize||26;var markerCanvas=generateGroupedCanvas(theoptions),markerOpts={},scale=theoptions.scale;return theoptions.type="transparent",Object.assign(markerOpts,theoptions),Object.assign(markerOpts,{origin:{x:0,y:0},anchor:{x:27*scale,y:24*scale},size:{width:54,height:48},scaledSize:{width:54*scale,height:48*scale}}),new IconObject(markerCanvas.toDataURL(),markerCanvas.fillColor,markerOpts)},readCache:function(cacheKey,options){if(options.no_cache)return null;var cached=window.sessionStorage.getItem(cacheKey);if(null===cached)return null;var cachedObj=JSON.parse(cached),iconObj=new IconObject(cachedObj.url,cachedObj.fillColor,omit(cachedObj,function(key){return-1!==["url","fillColor"].indexOf(key)}));return iconObj.cached=!0,iconObj},setCache:function(cacheKey,iconObj){var cached=iconObj.toJSON();return cached.url=iconObj.url,window.sessionStorage.setItem(cacheKey,JSON.stringify(cached)),iconObj},generateAutoicon:function(options){var generatorFN;options.is_icon?options.shadow||"grouped"===options.type?(options.type="grouped",generatorFN=MarkerFactory.createGroupedIcon):options.transparent_background?(options.type="transparent",generatorFN=MarkerFactory.createTransparentMarkerIcon):(generatorFN=MarkerFactory.createFatMarkerIcon,options.type="fatmarker"):(options.type="textmarker",generatorFN=MarkerFactory.createTextMarker);var cacheKey=function(options){if("object"!=typeof options)return null;var cleanOptions=omit(options,function(prop){return 0===prop.indexOf("gm_")}),sortedOpts=Object.entries(cleanOptions).filter(function(item){return"function"!=typeof item[1]&&"object"!=typeof item[1]&&null!==item[1]&&void 0!==item[1]}).sort();return JSON.stringify(sortedOpts)}(options),iconObj=MarkerFactory.readCache(cacheKey,options);return null===iconObj&&((iconObj=generatorFN(options)).cached=!1),iconObj.cacheKey=cacheKey,options.no_cache?iconObj:MarkerFactory.setCache(cacheKey,iconObj)},parseColorString:function(somecolor,opacity,darkenfactor){var hsl,rgb,parsedcolor={original:somecolor};return darkenfactor=darkenfactor||1,opacity=isNaN(parseFloat(opacity,10))?1:parseFloat(opacity,10),rgb=-1!==somecolor.indexOf("hsl")?function(h,s,l,a,darkenfactor){var r,g,b;if(darkenfactor=darkenfactor||1,h=parseFloat(h,10)/360,s=parseFloat(s,10)/100,l=parseFloat(l,10)/100,void 0===a&&(a=1),0===s)r=g=b=l;else{var q=l<.5?l*(1+s):l+s-l*s,p=2*l-q;r=hue2rgb(p,q,h+1/3),g=hue2rgb(p,q,h),b=hue2rgb(p,q,h-1/3)}void 0===a&&(a=1);var rgb={r:Math.round(255*r*darkenfactor),g:Math.round(255*g*darkenfactor),b:Math.round(255*b*darkenfactor),a:parseFloat(a,10)};return rgb.fillColor=rgbaString(rgb),rgb}((hsl=parseHSL(somecolor,opacity)).h,hsl.s,hsl.l,hsl.a,darkenfactor):-1!==somecolor.indexOf("rgb")?parseRGB(somecolor,opacity,darkenfactor):parseHex(somecolor,opacity,darkenfactor),hsl=function(in_r,in_g,in_b,in_a){var h,r=in_r%256/255,g=in_g%256/255,b=in_b%256/255,a=void 0===in_a?1:in_a,max=Math.max(r,g,b),min=Math.min(r,g,b),sum=max+min,diff=max-min,s=sum>1?diff/(2-sum):diff/sum;switch(max){case r:h=(g-b)/diff+(g<b?6:0);break;case g:h=(b-r)/diff+2;break;case b:h=(r-g)/diff+4;break;default:h=0}h/=6,0===diff&&(h=s=0);var hsl={h:Math.round(360*h),s:Math.round(100*s),l:Math.round(50*sum),a:Math.round(100*a)/100};return hsl.fillColor=hslaString(hsl),hsl}(rgb.r,rgb.g,rgb.b,rgb.a),parsedcolor.hsl={h:hsl.h,s:hsl.s,l:hsl.l,a:hsl.a},parsedcolor.rgb={r:rgb.r,g:rgb.g,b:rgb.b,a:rgb.a},parsedcolor.fillColor=rgb.fillColor,parsedcolor.rgba=rgb.fillColor,parsedcolor.hsla=hsl.fillColor,parsedcolor.strokeColor=rgb.strokeColor,parsedcolor.hex=["#",padHex(rgb.r.toString(16)),padHex(rgb.g.toString(16)),padHex(rgb.b.toString(16)),0===rgb.a?"00":""].join(""),parsedcolor},autoIcon:function(options){return"object"!=typeof options?(console.warn("autoIcon expects an object as its only parameter"),null):(options.transparent_background=!1!==options.transparent_background,options.label=String(options.label||"A"),options.color=options.color||"#FF0000",4===options.label.length||"0x"===options.label.substring(0,2)?(options.font=options.font||"fontello",options.label=(options.label||"e836").slice(-4),options.unicodelabel=String.fromCharCode("0x"+options.label),options.scale=options.scale||1,options.is_icon=!0,MarkerFactory.generateAutoicon(options)):options.shadow?MarkerFactory.createClusterIcon(options):(options.scale=options.scale||.75,options.label=String(options.label||"A"),options.fontsize=options.fontsize||11,options.font=options.font||"Arial",MarkerFactory.generateAutoicon(options)))}};exports.MarkerFactory=MarkerFactory,Object.defineProperty(exports,"__esModule",{value:!0})});
//# sourceMappingURL=markerfactory.min.js.map
{
"name": "ig_markerfactory",
"version": "2.12.4",
"version": "2.12.5",
"description": "Uses canvas to generate google.maps.Marker Icons from graphic fonts (i.e. font-awesome) on the fly",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc