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.1 to 2.12.2

25

dist/markerfactory.es6.js

@@ -798,10 +798,25 @@ function IconObject(canvas, markerOpts) {

createClusterIcon: createClusterIcon,
serializeOptions: function(options) {
if (typeof options !== "object") {
return null;
}
var sortedOpts = Object.entries(options)
.filter(function(item) {
return (
typeof item[1] !== "function" && typeof item[1] !== "object"
);
})
.sort();
return JSON.stringify(sortedOpts);
},
generateAutoicon: function(options) {
var cacheKey = JSON.stringify(options);
if (!options.no_cache) {
var cacheKey = MarkerFactory.serializeOptions(options);
var iconObj = window.sessionStorage.getItem(cacheKey);
if (iconObj !== null && !options.no_cache) {
return JSON.parse(iconObj);
var iconObj = window.sessionStorage.getItem(cacheKey);
if (iconObj !== null && !options.no_cache) {
return JSON.parse(iconObj);
}
}
if (!options.is_icon) {

@@ -808,0 +823,0 @@ iconObj = MarkerFactory.createTextMarker(options);

@@ -804,10 +804,25 @@ (function (global, factory) {

createClusterIcon: createClusterIcon,
serializeOptions: function(options) {
if (typeof options !== "object") {
return null;
}
var sortedOpts = Object.entries(options)
.filter(function(item) {
return (
typeof item[1] !== "function" && typeof item[1] !== "object"
);
})
.sort();
return JSON.stringify(sortedOpts);
},
generateAutoicon: function(options) {
var cacheKey = JSON.stringify(options);
if (!options.no_cache) {
var cacheKey = MarkerFactory.serializeOptions(options);
var iconObj = window.sessionStorage.getItem(cacheKey);
if (iconObj !== null && !options.no_cache) {
return JSON.parse(iconObj);
var iconObj = window.sessionStorage.getItem(cacheKey);
if (iconObj !== null && !options.no_cache) {
return JSON.parse(iconObj);
}
}
if (!options.is_icon) {

@@ -814,0 +829,0 @@ iconObj = MarkerFactory.createTextMarker(options);

2

dist/markerfactory.min.js

@@ -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 IconObject(canvas,markerOpts){return this.url=canvas.toDataURL(),this.fillColor=canvas.fillColor,this.markerOpts=markerOpts,Object.assign(this,markerOpts),this}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 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{url:null,markerOpts:this.markerOpts}};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)},generateAutoicon:function(options){var cacheKey=JSON.stringify(options),iconObj=window.sessionStorage.getItem(cacheKey);if(null!==iconObj&&!options.no_cache)return JSON.parse(iconObj);if(iconObj=options.is_icon?options.transparent_background?MarkerFactory.createTransparentMarkerIcon(options):MarkerFactory.createFatMarkerIcon(options):MarkerFactory.createTextMarker(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 IconObject(canvas,markerOpts){return this.url=canvas.toDataURL(),this.fillColor=canvas.fillColor,this.markerOpts=markerOpts,Object.assign(this,markerOpts),this}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 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{url:null,markerOpts:this.markerOpts}};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 sortedOpts=Object.entries(options).filter(function(item){return"function"!=typeof item[1]&&"object"!=typeof item[1]}).sort();return JSON.stringify(sortedOpts)},generateAutoicon:function(options){if(!options.no_cache){var cacheKey=MarkerFactory.serializeOptions(options),iconObj=window.sessionStorage.getItem(cacheKey);if(null!==iconObj&&!options.no_cache)return JSON.parse(iconObj)}if(iconObj=options.is_icon?options.transparent_background?MarkerFactory.createTransparentMarkerIcon(options):MarkerFactory.createFatMarkerIcon(options):MarkerFactory.createTextMarker(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})});
//# sourceMappingURL=markerfactory.min.js.map
{
"name": "ig_markerfactory",
"version": "2.12.1",
"version": "2.12.2",
"description": "Uses canvas to generate google.maps.Marker Icons from graphic fonts (i.e. font-awesome) on the fly",

@@ -62,7 +62,6 @@ "keywords": [

"rollup-plugin-strip": "^1.1.1",
"rollup-plugin-uglify": "^2.0.1"
"rollup-plugin-uglify": "^2.0.1",
"serve": "^10.0.2"
},
"dependencies": {
"serve": "^10.0.2"
}
"dependencies": {}
}

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