From 4298007f11dc747a689f00e1cd8f891c59f71305 Mon Sep 17 00:00:00 2001 From: jgravois Date: Thu, 10 Sep 2015 13:07:09 -0700 Subject: [PATCH] build 2.0.0 --- dist/esri-leaflet-renderers.js | 5 +++++ dist/esri-leaflet-renderers.js.map | 1 + 2 files changed, 6 insertions(+) create mode 100644 dist/esri-leaflet-renderers.js create mode 100644 dist/esri-leaflet-renderers.js.map diff --git a/dist/esri-leaflet-renderers.js b/dist/esri-leaflet-renderers.js new file mode 100644 index 0000000..2e61469 --- /dev/null +++ b/dist/esri-leaflet-renderers.js @@ -0,0 +1,5 @@ +/* esri-leaflet-renderers - v2.0.0 - Thu Sep 10 2015 13:07:08 GMT-0700 (PDT) + * Copyright (c) 2015 Environmental Systems Research Institute, Inc. + * Apache-2.0 */ +(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("leaflet")):typeof define==="function"&&define.amd?define(["exports","leaflet"],factory):factory(global.L.esri.Renderers={},L)})(this,function(exports,L){"use strict";exports.Symbol=L.Class.extend({initialize:function(symbolJson,options){this._symbolJson=symbolJson;this.val=null;this._styles={};this._isDefault=false;this._layerTransparency=1;if(options&&options.layerTransparency){this._layerTransparency=1-options.layerTransparency/100}},pixelValue:function(pointValue){return pointValue*1.333},colorValue:function(color){return"rgb("+color[0]+","+color[1]+","+color[2]+")"},alphaValue:function(color){var alpha=color[3]/255;return alpha*this._layerTransparency},getSize:function(feature,sizeInfo){var attr=feature.properties;var field=sizeInfo.field;var size=0;var featureValue=null;if(field){featureValue=attr[field];var minSize=sizeInfo.minSize;var maxSize=sizeInfo.maxSize;var minDataValue=sizeInfo.minDataValue;var maxDataValue=sizeInfo.maxDataValue;var featureRatio;var normField=sizeInfo.normalizationField;var normValue=attr?parseFloat(attr[normField]):undefined;if(featureValue===null||normField&&(isNaN(normValue)||normValue===0)){return null}if(!isNaN(normValue)){featureValue/=normValue}if(minSize!==null&&maxSize!==null&&minDataValue!==null&&maxDataValue!==null){if(featureValue<=minDataValue){size=minSize}else if(featureValue>=maxDataValue){size=maxSize}else{featureRatio=(featureValue-minDataValue)/(maxDataValue-minDataValue);size=minSize+featureRatio*(maxSize-minSize)}}size=isNaN(size)?0:size}return size},getColor:function(feature,colorInfo){if(!(feature.properties&&colorInfo&&colorInfo.field&&colorInfo.stops)){return null}var attr=feature.properties;var featureValue=attr[colorInfo.field];var lowerBoundColor,upperBoundColor,lowerBound,upperBound;var normField=colorInfo.normalizationField;var normValue=attr?parseFloat(attr[normField]):undefined;if(featureValue===null||normField&&(isNaN(normValue)||normValue===0)){return null}if(!isNaN(normValue)){featureValue/=normValue}if(featureValue<=colorInfo.stops[0].value){return colorInfo.stops[0].color}var lastStop=colorInfo.stops[colorInfo.stops.length-1];if(featureValue>=lastStop.value){return lastStop.color}for(var i=0;ifeatureValue){upperBoundColor=stopInfo.color;upperBound=stopInfo.value;break}}if(!isNaN(lowerBound)&&!isNaN(upperBound)){var range=upperBound-lowerBound;if(range>0){var upperBoundColorWeight=(featureValue-lowerBound)/range;if(upperBoundColorWeight){var lowerBoundColorWeight=(upperBound-featureValue)/range;if(lowerBoundColorWeight){var interpolatedColor=[];for(var j=0;j<4;j++){interpolatedColor[j]=Math.round(lowerBoundColor[j]*lowerBoundColorWeight+upperBoundColor[j]*upperBoundColorWeight)}return interpolatedColor}else{return upperBoundColor}}else{return lowerBoundColor}}}return null}});var _Symbol=exports.Symbol;exports.LineSymbol=_Symbol.extend({statics:{LINETYPES:["esriSLSDash","esriSLSDot","esriSLSDashDotDot","esriSLSDashDot","esriSLSSolid"]},initialize:function(symbolJson,options){_Symbol.prototype.initialize.call(this,symbolJson,options);this._fillStyles()},_fillStyles:function(){this._styles.lineCap="butt";this._styles.lineJoin="miter";this._styles.fill=false;if(!this._symbolJson){return}if(this._symbolJson.color){this._styles.color=this.colorValue(this._symbolJson.color);this._styles.opacity=this.alphaValue(this._symbolJson.color)}if(this._symbolJson.width){this._styles.weight=this.pixelValue(this._symbolJson.width);var dashValues=[];switch(this._symbolJson.style){case"esriSLSDash":dashValues=[4,3];break;case"esriSLSDot":dashValues=[1,3];break;case"esriSLSDashDot":dashValues=[8,3,1,3];break;case"esriSLSDashDotDot":dashValues=[8,3,1,3,1,3];break}if(dashValues.length>0){for(var i=0;i=0)){this._styles.fill=true;this._styles.fillColor=this.colorValue(this._symbolJson.color);this._styles.fillOpacity=this.alphaValue(this._symbolJson.color)}else{this._styles.fill=false;this._styles.fillOpacity=0}}},style:function(feature,visualVariables){if(!this._isDefault&&visualVariables&&visualVariables.colorInfo){var color=this.getColor(feature,visualVariables.colorInfo);if(color){this._styles.fillColor=this.colorValue(color);this._styles.fillOpacity=this.alphaValue(color)}}return this._styles}});function polygonSymbol(symbolJson,options){return new exports.PolygonSymbol(symbolJson,options)}var ShapeMarker=L.Path.extend({initialize:function(latlng,size,options){L.setOptions(this,options);this._size=size;this._latlng=L.latLng(latlng);this._svgCanvasIncludes()},_svgCanvasIncludes:function(){},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng)},_update:function(){if(this._map){this._updatePath()}},_updatePath:function(){},setLatLng:function(latlng){this._latlng=L.latLng(latlng);this.redraw();return this.fire("move",{latlng:this._latlng})},getLatLng:function(){return this._latlng},setSize:function(size){this._size=size;return this.redraw()},getSize:function(){return this._size}});var CrossMarker=ShapeMarker.extend({initialize:function(latlng,size,options){ShapeMarker.prototype.initialize.call(this,latlng,size,options)},_updatePath:function(){this._renderer._updateCrossMarker(this)},_svgCanvasIncludes:function(){L.Canvas.include({_updateCrossMarker:function(layer){var latlng=layer._point;var offset=layer._size/2;var ctx=this._ctx;ctx.beginPath();ctx.moveTo(latlng.x,latlng.y+offset);ctx.lineTo(latlng.x,latlng.y-offset);this._fillStroke(ctx,layer);ctx.moveTo(latlng.x-offset,latlng.y);ctx.lineTo(latlng.x+offset,latlng.y);this._fillStroke(ctx,layer)}});L.SVG.include({_updateCrossMarker:function(layer){var latlng=layer._point;var offset=layer._size/2;if(L.Browser.vml){latlng._round();offset=Math.round(offset)}var str="M"+latlng.x+","+(latlng.y+offset)+"L"+latlng.x+","+(latlng.y-offset)+"M"+(latlng.x-offset)+","+latlng.y+"L"+(latlng.x+offset)+","+latlng.y;this._setPath(layer,str)}})}});var crossMarker=function(latlng,size,options){return new CrossMarker(latlng,size,options)};var XMarker=ShapeMarker.extend({initialize:function(latlng,size,options){ShapeMarker.prototype.initialize.call(this,latlng,size,options)},_updatePath:function(){this._renderer._updateXMarker(this)},_svgCanvasIncludes:function(){L.Canvas.include({_updateXMarker:function(layer){var latlng=layer._point;var offset=layer._size/2;var ctx=this._ctx;ctx.beginPath();ctx.moveTo(latlng.x+offset,latlng.y+offset);ctx.lineTo(latlng.x-offset,latlng.y-offset);this._fillStroke(ctx,layer)}});L.SVG.include({_updateXMarker:function(layer){var latlng=layer._point;var offset=layer._size/2;if(L.Browser.vml){latlng._round();offset=Math.round(offset)}var str="M"+(latlng.x+offset)+","+(latlng.y+offset)+"L"+(latlng.x-offset)+","+(latlng.y-offset)+"M"+(latlng.x-offset)+","+(latlng.y+offset)+"L"+(latlng.x+offset)+","+(latlng.y-offset);this._setPath(layer,str)}})}});var xMarker=function(latlng,size,options){return new XMarker(latlng,size,options)};var SquareMarker=ShapeMarker.extend({options:{fill:true},initialize:function(latlng,size,options){ShapeMarker.prototype.initialize.call(this,latlng,size,options)},_updatePath:function(){this._renderer._updateSquareMarker(this)},_svgCanvasIncludes:function(){L.Canvas.include({_updateSquareMarker:function(layer){var latlng=layer._point;var offset=layer._size/2;var ctx=this._ctx;ctx.beginPath();ctx.moveTo(latlng.x+offset,latlng.y+offset);ctx.lineTo(latlng.x-offset,latlng.y+offset);ctx.lineTo(latlng.x-offset,latlng.y-offset);ctx.lineTo(latlng.x+offset,latlng.y-offset);ctx.closePath();this._fillStroke(ctx,layer)}});L.SVG.include({_updateSquareMarker:function(layer){var latlng=layer._point;var offset=layer._size/2;if(L.Browser.vml){latlng._round();offset=Math.round(offset)}var str="M"+(latlng.x+offset)+","+(latlng.y+offset)+"L"+(latlng.x-offset)+","+(latlng.y+offset)+"L"+(latlng.x-offset)+","+(latlng.y-offset)+"L"+(latlng.x+offset)+","+(latlng.y-offset);str=str+(L.Browser.svg?"z":"x");this._setPath(layer,str)}})}});var squareMarker=function(latlng,size,options){return new SquareMarker(latlng,size,options)};var DiamondMarker=ShapeMarker.extend({options:{fill:true},initialize:function(latlng,size,options){ShapeMarker.prototype.initialize.call(this,latlng,size,options)},_updatePath:function(){this._renderer._updateDiamondMarker(this)},_svgCanvasIncludes:function(){L.Canvas.include({_updateDiamondMarker:function(layer){var latlng=layer._point;var offset=layer._size/2;var ctx=this._ctx;ctx.beginPath();ctx.moveTo(latlng.x,latlng.y+offset);ctx.lineTo(latlng.x-offset,latlng.y);ctx.lineTo(latlng.x,latlng.y-offset);ctx.lineTo(latlng.x+offset,latlng.y);ctx.closePath();this._fillStroke(ctx,layer)}});L.SVG.include({_updateDiamondMarker:function(layer){var latlng=layer._point;var offset=layer._size/2;if(L.Browser.vml){latlng._round();offset=Math.round(offset)}var str="M"+latlng.x+","+(latlng.y+offset)+"L"+(latlng.x-offset)+","+latlng.y+"L"+latlng.x+","+(latlng.y-offset)+"L"+(latlng.x+offset)+","+latlng.y;str=str+(L.Browser.svg?"z":"x");this._setPath(layer,str)}})}});var diamondMarker=function(latlng,size,options){return new DiamondMarker(latlng,size,options)};exports.PointSymbol=_Symbol.extend({statics:{MARKERTYPES:["esriSMSCircle","esriSMSCross","esriSMSDiamond","esriSMSSquare","esriSMSX","esriPMS"]},initialize:function(symbolJson,options){_Symbol.prototype.initialize.call(this,symbolJson,options);if(options){this.serviceUrl=options.url}if(symbolJson){if(symbolJson.type==="esriPMS"){var url=this.serviceUrl+"images/"+this._symbolJson.url;this._iconUrl=options&&options.token?url+"?token="+options.token:url;this._icons={};this.icon=this._createIcon(this._symbolJson)}else{this._fillStyles()}}},_fillStyles:function(){if(this._symbolJson.outline&&this._symbolJson.size>0){this._styles.stroke=true;this._styles.weight=this.pixelValue(this._symbolJson.outline.width);this._styles.color=this.colorValue(this._symbolJson.outline.color);this._styles.opacity=this.alphaValue(this._symbolJson.outline.color)}else{this._styles.stroke=false}if(this._symbolJson.color){this._styles.fillColor=this.colorValue(this._symbolJson.color);this._styles.fillOpacity=this.alphaValue(this._symbolJson.color)}else{this._styles.fillOpacity=0}if(this._symbolJson.style==="esriSMSCircle"){this._styles.radius=this.pixelValue(this._symbolJson.size)/2}},_createIcon:function(options){var width=this.pixelValue(options.width);var height=width;if(options.height){height=this.pixelValue(options.height)}var xOffset=width/2;var yOffset=height/2;if(options.xoffset){xOffset+=this.pixelValue(options.xoffset)}if(options.yoffset){yOffset+=this.pixelValue(options.yoffset)}var icon=L.icon({iconUrl:this._iconUrl,iconSize:[width,height],iconAnchor:[xOffset,yOffset]});this._icons[options.width.toString()]=icon;return icon},_getIcon:function(size){var icon=this._icons[size.toString()];if(!icon){icon=this._createIcon({width:size})}return icon},pointToLayer:function(geojson,latlng,visualVariables){var size=this._symbolJson.size||this._symbolJson.width;if(!this._isDefault){if(visualVariables.sizeInfo){var calculatedSize=this.getSize(geojson,visualVariables.sizeInfo);if(calculatedSize){size=calculatedSize}}if(visualVariables.colorInfo){var color=this.getColor(geojson,visualVariables.colorInfo);if(color){this._styles.fillColor=this.colorValue(color);this._styles.fillOpacity=this.alphaValue(color)}}}if(this._symbolJson.type==="esriPMS"){return L.marker(latlng,{icon:this._getIcon(size)})}size=this.pixelValue(size);switch(this._symbolJson.style){case"esriSMSSquare":return squareMarker(latlng,size,this._styles);case"esriSMSDiamond":return diamondMarker(latlng,size,this._styles);case"esriSMSCross":return crossMarker(latlng,size,this._styles);case"esriSMSX":return xMarker(latlng,size,this._styles)}this._styles.radius=size/2;return L.circleMarker(latlng,this._styles)}});function pointSymbol(symbolJson,options){return new exports.PointSymbol(symbolJson,options)}exports.Renderer=L.Class.extend({options:{proportionalPolygon:false,clickable:true},initialize:function(rendererJson,options){this._rendererJson=rendererJson;this._pointSymbols=false;this._symbols=[];this._visualVariables=this._parseVisualVariables(rendererJson.visualVariables);L.Util.setOptions(this,options)},_parseVisualVariables:function(visualVariables){var visVars={};if(visualVariables){for(var i=0;i=0;i--){if(this.options.proportionalPolygon&&this._rendererJson.backgroundFillSymbol){symbol=this._newSymbol(this._rendererJson.backgroundFillSymbol)}else{symbol=this._newSymbol(classbreaks[i].symbol)}symbol.val=classbreaks[i].classMaxValue;this._symbols.push(symbol)}this._symbols.sort(function(a,b){return a.val>b.val?1:-1});this._createDefaultSymbol();this._maxValue=this._symbols[this._symbols.length-1].val},_getSymbol:function(feature){var val=feature.properties[this._field];if(this._normalizationField){var normValue=feature.properties[this._normalizationField];if(!isNaN(normValue)&&normValue!==0){val=val/normValue}else{return this._defaultSymbol}}if(val>this._maxValue){return this._defaultSymbol}var symbol=this._symbols[0];for(var i=this._symbols.length-1;i>=0;i--){if(val>this._symbols[i].val){break}symbol=this._symbols[i]}return symbol}});function classBreaksRenderer(rendererJson,options){return new exports.ClassBreaksRenderer(rendererJson,options)}exports.UniqueValueRenderer=exports.Renderer.extend({initialize:function(rendererJson,options){exports.Renderer.prototype.initialize.call(this,rendererJson,options);this._field=this._rendererJson.field1;this._createSymbols()},_createSymbols:function(){var symbol;var uniques=this._rendererJson.uniqueValueInfos;for(var i=uniques.length-1;i>=0;i--){symbol=this._newSymbol(uniques[i].symbol);symbol.val=uniques[i].value;this._symbols.push(symbol)}this._createDefaultSymbol()},_getSymbol:function(feature){var val=feature.properties[this._field];if(this._rendererJson.fieldDelimiter&&this._rendererJson.field2){var val2=feature.properties[this._rendererJson.field2];if(val2){val+=this._rendererJson.fieldDelimiter+val2;var val3=feature.properties[this._rendererJson.field3];if(val3){val+=this._rendererJson.fieldDelimiter+val3}}}var symbol=this._defaultSymbol;for(var i=this._symbols.length-1;i>=0;i--){if(this._symbols[i].val==val){symbol=this._symbols[i]}}return symbol}});function uniqueValueRenderer(rendererJson,options){return new exports.UniqueValueRenderer(rendererJson,options)}var SimpleRenderer=exports.Renderer.extend({initialize:function(rendererJson,options){exports.Renderer.prototype.initialize.call(this,rendererJson,options);this._createSymbol()},_createSymbol:function(){if(this._rendererJson.symbol){this._symbols.push(this._newSymbol(this._rendererJson.symbol))}},_getSymbol:function(){return this._symbols[0]}});function simpleRenderer(rendererJson,options){return new SimpleRenderer(rendererJson,options)}L.esri.FeatureLayer.addInitHook(function(){var oldOnAdd=L.Util.bind(this.onAdd,this);var oldUnbindPopup=L.Util.bind(this.unbindPopup,this);var oldOnRemove=L.Util.bind(this.onRemove,this);L.Util.bind(this.createNewLayer,this);this.metadata(function(error,response){if(error){return}if(response&&response.drawingInfo&&!this.options.style){this._setRenderers(response)}this._metadataLoaded=true;if(this._loadedMap){oldOnAdd(this._loadedMap);this._addPointLayer(this._loadedMap)}},this);this.onAdd=function(map){this._loadedMap=map;if(this._metadataLoaded){oldOnAdd(this._loadedMap);this._addPointLayer(this._loadedMap)}};this.onRemove=function(map){oldOnRemove(map);if(this._pointLayer){var pointLayers=this._pointLayer.getLayers();for(var i in pointLayers){map.removeLayer(pointLayers[i])}}};this.unbindPopup=function(){oldUnbindPopup();if(this._pointLayer){var pointLayers=this._pointLayer.getLayers();for(var i in pointLayers){pointLayers[i].unbindPopup()}}};this._addPointLayer=function(map){if(this._pointLayer){this._pointLayer.addTo(map);this._pointLayer.bringToFront()}};this._createPointLayer=function(){if(!this._pointLayer){this._pointLayer=L.geoJson();this._pointLayerIds={};if(this._popup){var popupFunction=function(feature,layer){layer.bindPopup(this._popup(feature,layer),this._popupOptions)};this._pointLayer.options.onEachFeature=L.Util.bind(popupFunction,this)}}};this.createNewLayer=function(geojson){var fLayer=L.GeoJSON.geometryToLayer(geojson,this.options);if(this._hasProportionalSymbols){var centroid=this.getPolygonCentroid(geojson.geometry.coordinates);if(!(isNaN(centroid[0])||isNaN(centroid[0]))){this._createPointLayer();var featureId=geojson.id.toString();if(!this._pointLayerIds[featureId]){var pointjson=this.getPointJson(geojson,centroid);this._pointLayer.addData(pointjson);this._pointLayerIds[featureId]=true}this._pointLayer.bringToFront()}}return fLayer};this.getPolygonCentroid=function(coordinates){var pts=coordinates[0][0];if(pts.length===2){pts=coordinates[0]}var twicearea=0;var x=0;var y=0;var nPts=pts.length;var p1;var p2;var f;for(var i=0,j=nPts-1;i= maxDataValue) {\n size = maxSize;\n } else {\n featureRatio = (featureValue - minDataValue) / (maxDataValue - minDataValue);\n size = minSize + (featureRatio * (maxSize - minSize));\n }\n }\n size = isNaN(size) ? 0 : size;\n }\n return size;\n },\n\n getColor: function (feature, colorInfo) {\n // required information to get color\n if (!(feature.properties && colorInfo && colorInfo.field && colorInfo.stops)) {\n return null;\n }\n\n var attr = feature.properties;\n var featureValue = attr[colorInfo.field];\n var lowerBoundColor, upperBoundColor, lowerBound, upperBound;\n var normField = colorInfo.normalizationField;\n var normValue = attr ? parseFloat(attr[normField]) : undefined;\n if (featureValue === null || (normField && ((isNaN(normValue) || normValue === 0)))) {\n return null;\n }\n\n if (!isNaN(normValue)) {\n featureValue /= normValue;\n }\n\n if (featureValue <= colorInfo.stops[0].value) {\n return colorInfo.stops[0].color;\n }\n var lastStop = colorInfo.stops[colorInfo.stops.length - 1];\n if (featureValue >= lastStop.value) {\n return lastStop.color;\n }\n\n // go through the stops to find min and max\n for (var i = 0; i < colorInfo.stops.length; i++) {\n var stopInfo = colorInfo.stops[i];\n\n if (stopInfo.value <= featureValue) {\n lowerBoundColor = stopInfo.color;\n lowerBound = stopInfo.value;\n } else if (stopInfo.value > featureValue) {\n upperBoundColor = stopInfo.color;\n upperBound = stopInfo.value;\n break;\n }\n }\n\n // feature falls between two stops, interplate the colors\n if (!isNaN(lowerBound) && !isNaN(upperBound)) {\n var range = upperBound - lowerBound;\n if (range > 0) {\n // more weight the further it is from the lower bound\n var upperBoundColorWeight = (featureValue - lowerBound) / range;\n if (upperBoundColorWeight) {\n // more weight the further it is from the upper bound\n var lowerBoundColorWeight = (upperBound - featureValue) / range;\n if (lowerBoundColorWeight) {\n // interpolate the lower and upper bound color by applying the\n // weights to each of the rgba colors and adding them together\n var interpolatedColor = [];\n for (var j = 0; j < 4; j++) {\n interpolatedColor[j] = Math.round(lowerBoundColor[j] * lowerBoundColorWeight + upperBoundColor[j] * upperBoundColorWeight);\n }\n return interpolatedColor;\n } else {\n // no difference between featureValue and upperBound, 100% of upperBoundColor\n return upperBoundColor;\n }\n } else {\n // no difference between featureValue and lowerBound, 100% of lowerBoundColor\n return lowerBoundColor;\n }\n }\n }\n // if we get to here, none of the cases apply so return null\n return null;\n }\n});\n\n// export function symbol (symbolJson) {\n// return new Symbol(symbolJson);\n// }\n\nexport default Symbol;\n","import Symbol from './Symbol';\n\nexport var LineSymbol = Symbol.extend({\n statics: {\n // Not implemented 'esriSLSNull'\n LINETYPES: ['esriSLSDash', 'esriSLSDot', 'esriSLSDashDotDot', 'esriSLSDashDot', 'esriSLSSolid']\n },\n initialize: function (symbolJson, options) {\n Symbol.prototype.initialize.call(this, symbolJson, options);\n this._fillStyles();\n },\n\n _fillStyles: function () {\n // set the defaults that show up on arcgis online\n this._styles.lineCap = 'butt';\n this._styles.lineJoin = 'miter';\n this._styles.fill = false;\n\n if (!this._symbolJson) {\n return;\n }\n\n if (this._symbolJson.color) {\n this._styles.color = this.colorValue(this._symbolJson.color);\n this._styles.opacity = this.alphaValue(this._symbolJson.color);\n }\n\n if (this._symbolJson.width) {\n this._styles.weight = this.pixelValue(this._symbolJson.width);\n\n var dashValues = [];\n\n switch (this._symbolJson.style) {\n case 'esriSLSDash':\n dashValues = [4, 3];\n break;\n case 'esriSLSDot':\n dashValues = [1, 3];\n break;\n case 'esriSLSDashDot':\n dashValues = [8, 3, 1, 3];\n break;\n case 'esriSLSDashDotDot':\n dashValues = [8, 3, 1, 3, 1, 3];\n break;\n }\n\n // use the dash values and the line weight to set dash array\n if (dashValues.length > 0) {\n for (var i = 0; i < dashValues.length; i++) {\n dashValues[i] *= this._styles.weight;\n }\n\n this._styles.dashArray = dashValues.join(',');\n }\n }\n },\n\n style: function (feature, visualVariables) {\n if (!this._isDefault && visualVariables) {\n if (visualVariables.sizeInfo) {\n var calculatedSize = this.pixelValue(this.getSize(feature, visualVariables.sizeInfo));\n if (calculatedSize) {\n this._styles.weight = calculatedSize;\n }\n }\n if (visualVariables.colorInfo) {\n var color = this.getColor(feature, visualVariables.colorInfo);\n if (color) {\n this._styles.color = this.colorValue(color);\n this._styles.opacity = this.alphaValue(color);\n }\n }\n }\n return this._styles;\n }\n});\n\nexport function lineSymbol (symbolJson, options) {\n return new LineSymbol(symbolJson, options);\n}\n\nexport default lineSymbol;\n","import Symbol from './Symbol';\nimport lineSymbol from './LineSymbol';\n\nexport var PolygonSymbol = Symbol.extend({\n statics: {\n // not implemented: 'esriSFSBackwardDiagonal','esriSFSCross','esriSFSDiagonalCross','esriSFSForwardDiagonal','esriSFSHorizontal','esriSFSNull','esriSFSVertical'\n POLYGONTYPES: ['esriSFSSolid']\n },\n initialize: function (symbolJson, options) {\n Symbol.prototype.initialize.call(this, symbolJson, options);\n if (symbolJson) {\n this._lineStyles = lineSymbol(symbolJson.outline, options).style();\n this._fillStyles();\n }\n },\n\n _fillStyles: function () {\n if (this._lineStyles) {\n if (this._lineStyles.weight === 0) {\n // when weight is 0, setting the stroke to false can still look bad\n // (gaps between the polygons)\n this._styles.stroke = false;\n } else {\n // copy the line symbol styles into this symbol's styles\n for (var styleAttr in this._lineStyles) {\n this._styles[styleAttr] = this._lineStyles[styleAttr];\n }\n }\n }\n\n // set the fill for the polygon\n if (this._symbolJson) {\n if (this._symbolJson.color &&\n // don't fill polygon if type is not supported\n PolygonSymbol.POLYGONTYPES.indexOf(this._symbolJson.style >= 0)) {\n this._styles.fill = true;\n this._styles.fillColor = this.colorValue(this._symbolJson.color);\n this._styles.fillOpacity = this.alphaValue(this._symbolJson.color);\n } else {\n this._styles.fill = false;\n this._styles.fillOpacity = 0;\n }\n }\n },\n\n style: function (feature, visualVariables) {\n if (!this._isDefault && visualVariables && visualVariables.colorInfo) {\n var color = this.getColor(feature, visualVariables.colorInfo);\n if (color) {\n this._styles.fillColor = this.colorValue(color);\n this._styles.fillOpacity = this.alphaValue(color);\n }\n }\n return this._styles;\n }\n});\n\nexport function polygonSymbol (symbolJson, options) {\n return new PolygonSymbol(symbolJson, options);\n}\n\nexport default polygonSymbol;\n","import L from 'leaflet';\n\nexport var ShapeMarker = L.Path.extend({\n\n initialize: function (latlng, size, options) {\n L.setOptions(this, options);\n this._size = size;\n this._latlng = L.latLng(latlng);\n this._svgCanvasIncludes();\n },\n\n _svgCanvasIncludes: function () {\n // implement in sub class\n },\n\n _project: function () {\n this._point = this._map.latLngToLayerPoint(this._latlng);\n },\n\n _update: function () {\n if (this._map) {\n this._updatePath();\n }\n },\n\n _updatePath: function () {\n // implement in sub class\n },\n\n setLatLng: function (latlng) {\n this._latlng = L.latLng(latlng);\n this.redraw();\n return this.fire('move', {latlng: this._latlng});\n },\n\n getLatLng: function () {\n return this._latlng;\n },\n\n setSize: function (size) {\n this._size = size;\n return this.redraw();\n },\n\n getSize: function () {\n return this._size;\n }\n});\n","import L from 'leaflet';\nimport { ShapeMarker } from './shapeMarker';\n\nexport var CrossMarker = ShapeMarker.extend({\n\n initialize: function (latlng, size, options) {\n ShapeMarker.prototype.initialize.call(this, latlng, size, options);\n },\n\n _updatePath: function () {\n this._renderer._updateCrossMarker(this);\n },\n\n _svgCanvasIncludes: function () {\n L.Canvas.include({\n _updateCrossMarker: function (layer) {\n var latlng = layer._point;\n var offset = layer._size / 2.0;\n var ctx = this._ctx;\n\n ctx.beginPath();\n ctx.moveTo(latlng.x, latlng.y + offset);\n ctx.lineTo(latlng.x, latlng.y - offset);\n this._fillStroke(ctx, layer);\n\n ctx.moveTo(latlng.x - offset, latlng.y);\n ctx.lineTo(latlng.x + offset, latlng.y);\n this._fillStroke(ctx, layer);\n }\n });\n\n L.SVG.include({\n _updateCrossMarker: function (layer) {\n var latlng = layer._point;\n var offset = layer._size / 2.0;\n\n if (L.Browser.vml) {\n latlng._round();\n offset = Math.round(offset);\n }\n\n var str = 'M' + latlng.x + ',' + (latlng.y + offset) +\n 'L' + latlng.x + ',' + (latlng.y - offset) +\n 'M' + (latlng.x - offset) + ',' + latlng.y +\n 'L' + (latlng.x + offset) + ',' + latlng.y;\n\n this._setPath(layer, str);\n }\n });\n }\n});\n\nexport var crossMarker = function (latlng, size, options) {\n return new CrossMarker(latlng, size, options);\n};\n\nexport default crossMarker;\n","import L from 'leaflet';\nimport { ShapeMarker } from './shapeMarker';\n\nexport var XMarker = ShapeMarker.extend({\n\n initialize: function (latlng, size, options) {\n ShapeMarker.prototype.initialize.call(this, latlng, size, options);\n },\n\n _updatePath: function () {\n this._renderer._updateXMarker(this);\n },\n\n _svgCanvasIncludes: function () {\n L.Canvas.include({\n _updateXMarker: function (layer) {\n var latlng = layer._point;\n var offset = layer._size / 2.0;\n var ctx = this._ctx;\n\n ctx.beginPath();\n\n ctx.moveTo(latlng.x + offset, latlng.y + offset);\n ctx.lineTo(latlng.x - offset, latlng.y - offset);\n this._fillStroke(ctx, layer);\n }\n });\n\n L.SVG.include({\n _updateXMarker: function (layer) {\n var latlng = layer._point;\n var offset = layer._size / 2.0;\n\n if (L.Browser.vml) {\n latlng._round();\n offset = Math.round(offset);\n }\n\n var str = 'M' + (latlng.x + offset) + ',' + (latlng.y + offset) +\n 'L' + (latlng.x - offset) + ',' + (latlng.y - offset) +\n 'M' + (latlng.x - offset) + ',' + (latlng.y + offset) +\n 'L' + (latlng.x + offset) + ',' + (latlng.y - offset);\n\n this._setPath(layer, str);\n }\n });\n }\n});\n\nexport var xMarker = function (latlng, size, options) {\n return new XMarker(latlng, size, options);\n};\n\nexport default xMarker;\n","import L from 'leaflet';\nimport { ShapeMarker } from './shapeMarker';\n\nexport var SquareMarker = ShapeMarker.extend({\n options: {\n fill: true\n },\n\n initialize: function (latlng, size, options) {\n ShapeMarker.prototype.initialize.call(this, latlng, size, options);\n },\n\n _updatePath: function () {\n this._renderer._updateSquareMarker(this);\n },\n\n _svgCanvasIncludes: function () {\n L.Canvas.include({\n _updateSquareMarker: function (layer) {\n var latlng = layer._point;\n var offset = layer._size / 2.0;\n var ctx = this._ctx;\n\n ctx.beginPath();\n\n ctx.moveTo(latlng.x + offset, latlng.y + offset);\n ctx.lineTo(latlng.x - offset, latlng.y + offset);\n ctx.lineTo(latlng.x - offset, latlng.y - offset);\n ctx.lineTo(latlng.x + offset, latlng.y - offset);\n\n ctx.closePath();\n\n this._fillStroke(ctx, layer);\n }\n });\n\n L.SVG.include({\n _updateSquareMarker: function (layer) {\n var latlng = layer._point;\n var offset = layer._size / 2.0;\n\n if (L.Browser.vml) {\n latlng._round();\n offset = Math.round(offset);\n }\n\n var str = 'M' + (latlng.x + offset) + ',' + (latlng.y + offset) +\n 'L' + (latlng.x - offset) + ',' + (latlng.y + offset) +\n 'L' + (latlng.x - offset) + ',' + (latlng.y - offset) +\n 'L' + (latlng.x + offset) + ',' + (latlng.y - offset);\n\n str = str + (L.Browser.svg ? 'z' : 'x');\n\n this._setPath(layer, str);\n }\n });\n }\n});\n\nexport var squareMarker = function (latlng, size, options) {\n return new SquareMarker(latlng, size, options);\n};\n\nexport default squareMarker;\n","import L from 'leaflet';\nimport { ShapeMarker } from './shapeMarker';\n\nexport var DiamondMarker = ShapeMarker.extend({\n options: {\n fill: true\n },\n\n initialize: function (latlng, size, options) {\n ShapeMarker.prototype.initialize.call(this, latlng, size, options);\n },\n\n _updatePath: function () {\n this._renderer._updateDiamondMarker(this);\n },\n\n _svgCanvasIncludes: function () {\n L.Canvas.include({\n _updateDiamondMarker: function (layer) {\n var latlng = layer._point;\n var offset = layer._size / 2.0;\n var ctx = this._ctx;\n\n ctx.beginPath();\n\n ctx.moveTo(latlng.x, latlng.y + offset);\n ctx.lineTo(latlng.x - offset, latlng.y);\n ctx.lineTo(latlng.x, latlng.y - offset);\n ctx.lineTo(latlng.x + offset, latlng.y);\n\n ctx.closePath();\n\n this._fillStroke(ctx, layer);\n }\n });\n\n L.SVG.include({\n _updateDiamondMarker: function (layer) {\n var latlng = layer._point;\n var offset = layer._size / 2.0;\n\n if (L.Browser.vml) {\n latlng._round();\n offset = Math.round(offset);\n }\n\n var str = 'M' + latlng.x + ',' + (latlng.y + offset) +\n 'L' + (latlng.x - offset) + ',' + latlng.y +\n 'L' + latlng.x + ',' + (latlng.y - offset) +\n 'L' + (latlng.x + offset) + ',' + latlng.y;\n\n str = str + (L.Browser.svg ? 'z' : 'x');\n\n this._setPath(layer, str);\n }\n });\n }\n});\n\nexport var diamondMarker = function (latlng, size, options) {\n return new DiamondMarker(latlng, size, options);\n};\n\nexport default diamondMarker;\n","import L from 'leaflet';\nimport Symbol from './Symbol';\nimport {squareMarker, xMarker, crossMarker, diamondMarker} from 'leaflet-shape-markers';\n\nexport var PointSymbol = Symbol.extend({\n statics: {\n MARKERTYPES: ['esriSMSCircle', 'esriSMSCross', 'esriSMSDiamond', 'esriSMSSquare', 'esriSMSX', 'esriPMS']\n },\n initialize: function (symbolJson, options) {\n Symbol.prototype.initialize.call(this, symbolJson, options);\n if (options) {\n this.serviceUrl = options.url;\n }\n if (symbolJson) {\n if (symbolJson.type === 'esriPMS') {\n var url = this.serviceUrl + 'images/' + this._symbolJson.url;\n this._iconUrl = options && options.token ? url + '?token=' + options.token : url;\n // leaflet does not allow resizing icons so keep a hash of different\n // icon sizes to try and keep down on the number of icons created\n this._icons = {};\n // create base icon\n this.icon = this._createIcon(this._symbolJson);\n } else {\n this._fillStyles();\n }\n }\n },\n\n _fillStyles: function () {\n if (this._symbolJson.outline && this._symbolJson.size > 0) {\n this._styles.stroke = true;\n this._styles.weight = this.pixelValue(this._symbolJson.outline.width);\n this._styles.color = this.colorValue(this._symbolJson.outline.color);\n this._styles.opacity = this.alphaValue(this._symbolJson.outline.color);\n } else {\n this._styles.stroke = false;\n }\n if (this._symbolJson.color) {\n this._styles.fillColor = this.colorValue(this._symbolJson.color);\n this._styles.fillOpacity = this.alphaValue(this._symbolJson.color);\n } else {\n this._styles.fillOpacity = 0;\n }\n\n if (this._symbolJson.style === 'esriSMSCircle') {\n this._styles.radius = this.pixelValue(this._symbolJson.size) / 2.0;\n }\n },\n\n _createIcon: function (options) {\n var width = this.pixelValue(options.width);\n var height = width;\n if (options.height) {\n height = this.pixelValue(options.height);\n }\n var xOffset = width / 2.0;\n var yOffset = height / 2.0;\n\n if (options.xoffset) {\n xOffset += this.pixelValue(options.xoffset);\n }\n if (options.yoffset) {\n yOffset += this.pixelValue(options.yoffset);\n }\n\n var icon = L.icon({\n iconUrl: this._iconUrl,\n iconSize: [width, height],\n iconAnchor: [xOffset, yOffset]\n });\n this._icons[options.width.toString()] = icon;\n return icon;\n },\n\n _getIcon: function (size) {\n // check to see if it is already created by size\n var icon = this._icons[size.toString()];\n if (!icon) {\n icon = this._createIcon({width: size});\n }\n return icon;\n },\n\n pointToLayer: function (geojson, latlng, visualVariables) {\n var size = this._symbolJson.size || this._symbolJson.width;\n if (!this._isDefault) {\n if (visualVariables.sizeInfo) {\n var calculatedSize = this.getSize(geojson, visualVariables.sizeInfo);\n if (calculatedSize) {\n size = calculatedSize;\n }\n }\n if (visualVariables.colorInfo) {\n var color = this.getColor(geojson, visualVariables.colorInfo);\n if (color) {\n this._styles.fillColor = this.colorValue(color);\n this._styles.fillOpacity = this.alphaValue(color);\n }\n }\n }\n\n if (this._symbolJson.type === 'esriPMS') {\n return L.marker(latlng, {icon: this._getIcon(size)});\n }\n size = this.pixelValue(size);\n\n switch (this._symbolJson.style) {\n case 'esriSMSSquare':\n return squareMarker(latlng, size, this._styles);\n case 'esriSMSDiamond':\n return diamondMarker(latlng, size, this._styles);\n case 'esriSMSCross':\n return crossMarker(latlng, size, this._styles);\n case 'esriSMSX':\n return xMarker(latlng, size, this._styles);\n }\n this._styles.radius = size / 2.0;\n return L.circleMarker(latlng, this._styles);\n }\n});\n\nexport function pointSymbol (symbolJson, options) {\n return new PointSymbol(symbolJson, options);\n}\n\nexport default pointSymbol;\n","import L from 'leaflet';\n\nimport pointSymbol from '../Symbols/PointSymbol';\nimport lineSymbol from '../Symbols/LineSymbol';\nimport polygonSymbol from '../Symbols/PolygonSymbol';\n\nexport var Renderer = L.Class.extend({\n options: {\n proportionalPolygon: false,\n clickable: true\n },\n\n initialize: function (rendererJson, options) {\n this._rendererJson = rendererJson;\n this._pointSymbols = false;\n this._symbols = [];\n this._visualVariables = this._parseVisualVariables(rendererJson.visualVariables);\n L.Util.setOptions(this, options);\n },\n\n _parseVisualVariables: function (visualVariables) {\n var visVars = {};\n if (visualVariables) {\n for (var i = 0; i < visualVariables.length; i++) {\n visVars[visualVariables[i].type] = visualVariables[i];\n }\n }\n return visVars;\n },\n\n _createDefaultSymbol: function () {\n if (this._rendererJson.defaultSymbol) {\n this._defaultSymbol = this._newSymbol(this._rendererJson.defaultSymbol);\n this._defaultSymbol._isDefault = true;\n }\n },\n\n _newSymbol: function (symbolJson) {\n if (symbolJson.type === 'esriSMS' || symbolJson.type === 'esriPMS') {\n this._pointSymbols = true;\n return pointSymbol(symbolJson, this.options);\n }\n if (symbolJson.type === 'esriSLS') {\n return lineSymbol(symbolJson, this.options);\n }\n if (symbolJson.type === 'esriSFS') {\n return polygonSymbol(symbolJson, this.options);\n }\n },\n\n _getSymbol: function () {\n // override\n },\n\n attachStylesToLayer: function (layer) {\n if (this._pointSymbols) {\n layer.options.pointToLayer = L.Util.bind(this.pointToLayer, this);\n } else {\n layer.options.style = L.Util.bind(this.style, this);\n }\n },\n\n pointToLayer: function (geojson, latlng) {\n var sym = this._getSymbol(geojson);\n if (sym && sym.pointToLayer) {\n return sym.pointToLayer(geojson, latlng, this._visualVariables);\n }\n // invisible symbology\n return L.circleMarker(latlng, {radius: 0, opacity: 0});\n },\n\n style: function (feature) {\n // find the symbol to represent this feature\n var sym = this._getSymbol(feature);\n if (sym) {\n return sym.style(feature, this._visualVariables);\n } else {\n // invisible symbology\n return {opacity: 0, fillOpacity: 0};\n }\n }\n});\n\nexport function renderer (rendererJson, options) {\n return new Renderer(rendererJson, options);\n}\n\nexport default renderer;\n","import Renderer from './Renderer';\n\nexport var SimpleRenderer = Renderer.extend({\n initialize: function (rendererJson, options) {\n Renderer.prototype.initialize.call(this, rendererJson, options);\n this._createSymbol();\n },\n\n _createSymbol: function () {\n if (this._rendererJson.symbol) {\n this._symbols.push(this._newSymbol(this._rendererJson.symbol));\n }\n },\n\n _getSymbol: function () {\n return this._symbols[0];\n }\n});\n\nexport function simpleRenderer (rendererJson, options) {\n return new SimpleRenderer(rendererJson, options);\n}\n\nexport default simpleRenderer;\n","import Renderer from './Renderer';\n\nexport var ClassBreaksRenderer = Renderer.extend({\n initialize: function (rendererJson, options) {\n Renderer.prototype.initialize.call(this, rendererJson, options);\n this._field = this._rendererJson.field;\n if (this._rendererJson.normalizationType && this._rendererJson.normalizationType === 'esriNormalizeByField') {\n this._normalizationField = this._rendererJson.normalizationField;\n }\n this._createSymbols();\n },\n\n _createSymbols: function () {\n var symbol;\n var classbreaks = this._rendererJson.classBreakInfos;\n\n this._symbols = [];\n\n // create a symbol for each class break\n for (var i = classbreaks.length - 1; i >= 0; i--) {\n if (this.options.proportionalPolygon && this._rendererJson.backgroundFillSymbol) {\n symbol = this._newSymbol(this._rendererJson.backgroundFillSymbol);\n } else {\n symbol = this._newSymbol(classbreaks[i].symbol);\n }\n symbol.val = classbreaks[i].classMaxValue;\n this._symbols.push(symbol);\n }\n // sort the symbols in ascending value\n this._symbols.sort(function (a, b) {\n return a.val > b.val ? 1 : -1;\n });\n this._createDefaultSymbol();\n this._maxValue = this._symbols[this._symbols.length - 1].val;\n },\n\n _getSymbol: function (feature) {\n var val = feature.properties[this._field];\n if (this._normalizationField) {\n var normValue = feature.properties[this._normalizationField];\n if (!isNaN(normValue) && normValue !== 0) {\n val = val / normValue;\n } else {\n return this._defaultSymbol;\n }\n }\n\n if (val > this._maxValue) {\n return this._defaultSymbol;\n }\n var symbol = this._symbols[0];\n for (var i = this._symbols.length - 1; i >= 0; i--) {\n if (val > this._symbols[i].val) {\n break;\n }\n symbol = this._symbols[i];\n }\n return symbol;\n }\n});\n\nexport function classBreaksRenderer (rendererJson, options) {\n return new ClassBreaksRenderer(rendererJson, options);\n}\n\nexport default classBreaksRenderer;\n","import Renderer from './Renderer';\n\nexport var UniqueValueRenderer = Renderer.extend({\n initialize: function (rendererJson, options) {\n Renderer.prototype.initialize.call(this, rendererJson, options);\n this._field = this._rendererJson.field1;\n this._createSymbols();\n },\n\n _createSymbols: function () {\n var symbol;\n var uniques = this._rendererJson.uniqueValueInfos;\n\n // create a symbol for each unique value\n for (var i = uniques.length - 1; i >= 0; i--) {\n symbol = this._newSymbol(uniques[i].symbol);\n symbol.val = uniques[i].value;\n this._symbols.push(symbol);\n }\n this._createDefaultSymbol();\n },\n\n _getSymbol: function (feature) {\n var val = feature.properties[this._field];\n // accumulate values if there is more than one field defined\n if (this._rendererJson.fieldDelimiter && this._rendererJson.field2) {\n var val2 = feature.properties[this._rendererJson.field2];\n if (val2) {\n val += this._rendererJson.fieldDelimiter + val2;\n var val3 = feature.properties[this._rendererJson.field3];\n if (val3) {\n val += this._rendererJson.fieldDelimiter + val3;\n }\n }\n }\n\n var symbol = this._defaultSymbol;\n for (var i = this._symbols.length - 1; i >= 0; i--) {\n // using the === operator does not work if the field\n // of the unique renderer is not a string\n /*eslint-disable */\n if (this._symbols[i].val == val) {\n symbol = this._symbols[i];\n }\n /*eslint-enable */\n }\n return symbol;\n }\n});\n\nexport function uniqueValueRenderer (rendererJson, options) {\n return new UniqueValueRenderer(rendererJson, options);\n}\n\nexport default uniqueValueRenderer;\n","import Renderer from './Renderer';\n\nexport var SimpleRenderer = Renderer.extend({\n initialize: function (rendererJson, options) {\n Renderer.prototype.initialize.call(this, rendererJson, options);\n this._createSymbol();\n },\n\n _createSymbol: function () {\n if (this._rendererJson.symbol) {\n this._symbols.push(this._newSymbol(this._rendererJson.symbol));\n }\n },\n\n _getSymbol: function () {\n return this._symbols[0];\n }\n});\n\nexport function simpleRenderer (rendererJson, options) {\n return new SimpleRenderer(rendererJson, options);\n}\n\nexport default simpleRenderer;\n","// import L from 'leaflet';\n// import { FeatureLayer } from 'esri-leaflet';\n\nimport classBreaksRenderer from './Renderers/ClassBreaksRenderer';\nimport uniqueValueRenderer from './Renderers/UniqueValueRenderer';\nimport simpleRenderer from './Renderers/simpleRenderer';\n\nL.esri.FeatureLayer.addInitHook(function () {\n var oldOnAdd = L.Util.bind(this.onAdd, this);\n var oldUnbindPopup = L.Util.bind(this.unbindPopup, this);\n var oldOnRemove = L.Util.bind(this.onRemove, this);\n L.Util.bind(this.createNewLayer, this);\n\n this.metadata(function (error, response) {\n if (error) {\n return;\n }\n if (response && response.drawingInfo && !this.options.style) {\n this._setRenderers(response);\n }\n\n this._metadataLoaded = true;\n if (this._loadedMap) {\n oldOnAdd(this._loadedMap);\n this._addPointLayer(this._loadedMap);\n }\n }, this);\n\n this.onAdd = function (map) {\n this._loadedMap = map;\n if (this._metadataLoaded) {\n oldOnAdd(this._loadedMap);\n this._addPointLayer(this._loadedMap);\n }\n };\n\n this.onRemove = function (map) {\n oldOnRemove(map);\n if (this._pointLayer) {\n var pointLayers = this._pointLayer.getLayers();\n for (var i in pointLayers) {\n map.removeLayer(pointLayers[i]);\n }\n }\n };\n\n this.unbindPopup = function () {\n oldUnbindPopup();\n if (this._pointLayer) {\n var pointLayers = this._pointLayer.getLayers();\n for (var i in pointLayers) {\n pointLayers[i].unbindPopup();\n }\n }\n };\n\n this._addPointLayer = function (map) {\n if (this._pointLayer) {\n this._pointLayer.addTo(map);\n this._pointLayer.bringToFront();\n }\n };\n\n this._createPointLayer = function () {\n if (!this._pointLayer) {\n this._pointLayer = L.geoJson();\n // store the feature ids that have already been added to the map\n this._pointLayerIds = {};\n\n if (this._popup) {\n var popupFunction = function (feature, layer) {\n layer.bindPopup(this._popup(feature, layer), this._popupOptions);\n };\n this._pointLayer.options.onEachFeature = L.Util.bind(popupFunction, this);\n }\n }\n };\n\n this.createNewLayer = function (geojson) {\n var fLayer = L.GeoJSON.geometryToLayer(geojson, this.options);\n\n // add a point layer when the polygon is represented as proportional marker symbols\n if (this._hasProportionalSymbols) {\n var centroid = this.getPolygonCentroid(geojson.geometry.coordinates);\n if (!(isNaN(centroid[0]) || isNaN(centroid[0]))) {\n this._createPointLayer();\n\n var featureId = geojson.id.toString();\n // only add the feature if it does not already exist on the map\n if (!this._pointLayerIds[featureId]) {\n var pointjson = this.getPointJson(geojson, centroid);\n\n this._pointLayer.addData(pointjson);\n this._pointLayerIds[featureId] = true;\n }\n\n this._pointLayer.bringToFront();\n }\n }\n return fLayer;\n };\n\n this.getPolygonCentroid = function (coordinates) {\n var pts = coordinates[0][0];\n if (pts.length === 2) {\n pts = coordinates[0];\n }\n\n var twicearea = 0;\n var x = 0;\n var y = 0;\n var nPts = pts.length;\n var p1;\n var p2;\n var f;\n\n for (var i = 0, j = nPts - 1; i < nPts; j = i++) {\n p1 = pts[i]; p2 = pts[j];\n twicearea += p1[0] * p2[1];\n twicearea -= p1[1] * p2[0];\n f = p1[0] * p2[1] - p2[0] * p1[1];\n x += (p1[0] + p2[0]) * f;\n y += (p1[1] + p2[1]) * f;\n }\n f = twicearea * 3;\n return [x / f, y / f];\n };\n\n this.getPointJson = function (geojson, centroid) {\n return {\n type: 'Feature',\n properties: geojson.properties,\n id: geojson.id,\n geometry: {\n type: 'Point',\n coordinates: [centroid[0], centroid[1]]\n }\n };\n };\n\n this._checkForProportionalSymbols = function (geometryType, renderer) {\n this._hasProportionalSymbols = false;\n if (geometryType === 'esriGeometryPolygon') {\n if (renderer.backgroundFillSymbol) {\n this._hasProportionalSymbols = true;\n }\n // check to see if the first symbol in the classbreaks is a marker symbol\n if (renderer.classBreakInfos && renderer.classBreakInfos.length) {\n var sym = renderer.classBreakInfos[0].symbol;\n if (sym && (sym.type === 'esriSMS' || sym.type === 'esriPMS')) {\n this._hasProportionalSymbols = true;\n }\n }\n }\n };\n\n this._setRenderers = function (geojson) {\n var rend;\n var rendererInfo = geojson.drawingInfo.renderer;\n var options = {\n url: this.options.url\n };\n if (this.options.token) {\n options.token = this.options.token;\n }\n\n if (geojson.drawingInfo.transparency) {\n options.layerTransparency = geojson.drawingInfo.transparency;\n }\n\n switch (rendererInfo.type) {\n case 'classBreaks':\n this._checkForProportionalSymbols(geojson.geometryType, rendererInfo);\n if (this._hasProportionalSymbols) {\n this._createPointLayer();\n var pRend = classBreaksRenderer(rendererInfo, options);\n pRend.attachStylesToLayer(this._pointLayer);\n options.proportionalPolygon = true;\n }\n rend = classBreaksRenderer(rendererInfo, options);\n break;\n case 'uniqueValue':\n rend = uniqueValueRenderer(rendererInfo, options);\n break;\n default:\n rend = simpleRenderer(rendererInfo, options);\n }\n rend.attachStylesToLayer(this);\n };\n});\n","export var VERSION = '2.0.0-beta.1';\n\nexport { Renderer, renderer } from './Renderers/Renderer';\nexport { SimpleRenderer, simpleRenderer } from './Renderers/SimpleRenderer';\nexport { ClassBreaksRenderer, classBreaksRenderer } from './Renderers/ClassBreaksRenderer';\nexport { UniqueValueRenderer, uniqueValueRenderer } from './Renderers/UniqueValueRenderer';\n\nexport { Symbol } from './Symbols/Symbol';\nexport { PointSymbol, pointSymbol } from './Symbols/PointSymbol';\nexport { LineSymbol, lineSymbol } from './Symbols/LineSymbol';\nexport { PolygonSymbol, polygonSymbol } from './Symbols/PolygonSymbol';\n\nimport './FeatureLayerHook';\n"]} \ No newline at end of file