{"version":3,"file":"esri-leaflet-renderers.js","sources":["../src/Symbols/Symbol.js","../node_modules/leaflet-shape-markers/src/ShapeMarker.js","../node_modules/leaflet-shape-markers/src/CrossMarker.js","../node_modules/leaflet-shape-markers/src/XMarker.js","../node_modules/leaflet-shape-markers/src/SquareMarker.js","../node_modules/leaflet-shape-markers/src/DiamondMarker.js","../src/Symbols/PointSymbol.js","../src/Symbols/LineSymbol.js","../src/Symbols/PolygonSymbol.js","../src/Renderers/Renderer.js","../src/Renderers/SimpleRenderer.js","../src/Renderers/ClassBreaksRenderer.js","../src/Renderers/UniqueValueRenderer.js","../src/FeatureLayerHook.js"],"sourcesContent":["import { Class } from 'leaflet';\r\n\r\nexport var Symbol = Class.extend({\r\n initialize: function (symbolJson, options) {\r\n this._symbolJson = symbolJson;\r\n this.val = null;\r\n this._styles = {};\r\n this._isDefault = false;\r\n this._layerTransparency = 1;\r\n if (options && options.layerTransparency) {\r\n this._layerTransparency = 1 - (options.layerTransparency / 100.0);\r\n }\r\n },\r\n\r\n // the geojson values returned are in points\r\n pixelValue: function (pointValue) {\r\n return pointValue * 1.333;\r\n },\r\n\r\n // color is an array [r,g,b,a]\r\n colorValue: function (color) {\r\n return 'rgb(' + color[0] + ',' + color[1] + ',' + color[2] + ')';\r\n },\r\n\r\n alphaValue: function (color) {\r\n var alpha = color[3] / 255.0;\r\n return alpha * this._layerTransparency;\r\n },\r\n\r\n getSize: function (feature, sizeInfo) {\r\n var attr = feature.properties;\r\n var field = sizeInfo.field;\r\n var size = 0;\r\n var featureValue = null;\r\n\r\n if (field) {\r\n featureValue = attr[field];\r\n var minSize = sizeInfo.minSize;\r\n var maxSize = sizeInfo.maxSize;\r\n var minDataValue = sizeInfo.minDataValue;\r\n var maxDataValue = sizeInfo.maxDataValue;\r\n var featureRatio;\r\n var normField = sizeInfo.normalizationField;\r\n var normValue = attr ? parseFloat(attr[normField]) : undefined;\r\n\r\n if (featureValue === null || (normField && ((isNaN(normValue) || normValue === 0)))) {\r\n return null;\r\n }\r\n\r\n if (!isNaN(normValue)) {\r\n featureValue /= normValue;\r\n }\r\n\r\n if (minSize !== null && maxSize !== null && minDataValue !== null && maxDataValue !== null) {\r\n if (featureValue <= minDataValue) {\r\n size = minSize;\r\n } else if (featureValue >= maxDataValue) {\r\n size = maxSize;\r\n } else {\r\n featureRatio = (featureValue - minDataValue) / (maxDataValue - minDataValue);\r\n size = minSize + (featureRatio * (maxSize - minSize));\r\n }\r\n }\r\n size = isNaN(size) ? 0 : size;\r\n }\r\n return size;\r\n },\r\n\r\n getColor: function (feature, colorInfo) {\r\n // required information to get color\r\n if (!(feature.properties && colorInfo && colorInfo.field && colorInfo.stops)) {\r\n return null;\r\n }\r\n\r\n var attr = feature.properties;\r\n var featureValue = attr[colorInfo.field];\r\n var lowerBoundColor, upperBoundColor, lowerBound, upperBound;\r\n var normField = colorInfo.normalizationField;\r\n var normValue = attr ? parseFloat(attr[normField]) : undefined;\r\n if (featureValue === null || (normField && ((isNaN(normValue) || normValue === 0)))) {\r\n return null;\r\n }\r\n\r\n if (!isNaN(normValue)) {\r\n featureValue /= normValue;\r\n }\r\n\r\n if (featureValue <= colorInfo.stops[0].value) {\r\n return colorInfo.stops[0].color;\r\n }\r\n var lastStop = colorInfo.stops[colorInfo.stops.length - 1];\r\n if (featureValue >= lastStop.value) {\r\n return lastStop.color;\r\n }\r\n\r\n // go through the stops to find min and max\r\n for (var i = 0; i < colorInfo.stops.length; i++) {\r\n var stopInfo = colorInfo.stops[i];\r\n\r\n if (stopInfo.value <= featureValue) {\r\n lowerBoundColor = stopInfo.color;\r\n lowerBound = stopInfo.value;\r\n } else if (stopInfo.value > featureValue) {\r\n upperBoundColor = stopInfo.color;\r\n upperBound = stopInfo.value;\r\n break;\r\n }\r\n }\r\n\r\n // feature falls between two stops, interplate the colors\r\n if (!isNaN(lowerBound) && !isNaN(upperBound)) {\r\n var range = upperBound - lowerBound;\r\n if (range > 0) {\r\n // more weight the further it is from the lower bound\r\n var upperBoundColorWeight = (featureValue - lowerBound) / range;\r\n if (upperBoundColorWeight) {\r\n // more weight the further it is from the upper bound\r\n var lowerBoundColorWeight = (upperBound - featureValue) / range;\r\n if (lowerBoundColorWeight) {\r\n // interpolate the lower and upper bound color by applying the\r\n // weights to each of the rgba colors and adding them together\r\n var interpolatedColor = [];\r\n for (var j = 0; j < 4; j++) {\r\n interpolatedColor[j] = Math.round((lowerBoundColor[j] * lowerBoundColorWeight) + (upperBoundColor[j] * upperBoundColorWeight));\r\n }\r\n return interpolatedColor;\r\n } else {\r\n // no difference between featureValue and upperBound, 100% of upperBoundColor\r\n return upperBoundColor;\r\n }\r\n } else {\r\n // no difference between featureValue and lowerBound, 100% of lowerBoundColor\r\n return lowerBoundColor;\r\n }\r\n }\r\n }\r\n // if we get to here, none of the cases apply so return null\r\n return null;\r\n }\r\n});\r\n\r\n// export function symbol (symbolJson) {\r\n// return new Symbol(symbolJson);\r\n// }\r\n\r\nexport default Symbol;\r\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 toGeoJSON: function () {\n return L.GeoJSON.getFeature(this, {\n type: 'Point',\n coordinates: L.GeoJSON.latLngToCoords(this.getLatLng())\n });\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 {\r\n marker,\r\n icon as leafletIcon,\r\n extend,\r\n circleMarker\r\n} from 'leaflet';\r\nimport Symbol from './Symbol';\r\nimport { squareMarker, xMarker, crossMarker, diamondMarker } from 'leaflet-shape-markers';\r\n\r\nexport var PointSymbol = Symbol.extend({\r\n\r\n statics: {\r\n MARKERTYPES: ['esriSMSCircle', 'esriSMSCross', 'esriSMSDiamond', 'esriSMSSquare', 'esriSMSX', 'esriPMS']\r\n },\r\n\r\n initialize: function (symbolJson, options) {\r\n var url;\r\n Symbol.prototype.initialize.call(this, symbolJson, options);\r\n if (options) {\r\n this.serviceUrl = options.url;\r\n }\r\n if (symbolJson) {\r\n if (symbolJson.type === 'esriPMS') {\r\n var imageUrl = this._symbolJson.url;\r\n if ((imageUrl && imageUrl.substr(0, 7) === 'http://') || (imageUrl.substr(0, 8) === 'https://')) {\r\n // web image\r\n url = this.sanitize(imageUrl);\r\n this._iconUrl = url;\r\n } else {\r\n url = this.serviceUrl + 'images/' + imageUrl;\r\n this._iconUrl = options && options.token ? url + '?token=' + options.token : url;\r\n }\r\n if (symbolJson.imageData) {\r\n this._iconUrl = 'data:' + symbolJson.contentType + ';base64,' + symbolJson.imageData;\r\n }\r\n // leaflet does not allow resizing icons so keep a hash of different\r\n // icon sizes to try and keep down on the number of icons created\r\n this._icons = {};\r\n // create base icon\r\n this.icon = this._createIcon(this._symbolJson);\r\n } else {\r\n this._fillStyles();\r\n }\r\n }\r\n },\r\n\r\n // prevent html injection in strings\r\n sanitize: function (str) {\r\n if (!str) {\r\n return '';\r\n }\r\n var text;\r\n try {\r\n // removes html but leaves url link text\r\n text = str.replace(/
/gi, '\\n');\r\n text = text.replace(/