diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d20205..5749f2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ -# Changelog +# esri-leaflet-renderers changelog -# Beta 1 +## 0.0.1-beta.2 - 2015-03-02 +* Fix to work with Browserify +* Update to work with esri-leaflet 1.0.0-rc.5 +* Still backwards compatible with esri-leaflet 1.0.0-rc.4 +## 0.0.1-beta.1 - 2015-01-29 * First Beta release -* Works with esri-leaflet 1.0.0-rc.4 and higher +* Works with esri-leaflet 1.0.0-rc.4 + diff --git a/dist/esri-leaflet-renderers-src.js b/dist/esri-leaflet-renderers-src.js new file mode 100644 index 0000000..e7a1854 --- /dev/null +++ b/dist/esri-leaflet-renderers-src.js @@ -0,0 +1,798 @@ +/*! esri-leaflet-renderers - v0.0.1-beta.2 - 2015-03-02 +* Copyright (c) 2015 Environmental Systems Research Institute, Inc. +* Apache 2.0 License */ + +var EsriLeafletRenderers = { + VERSION: '0.0.1-beta.2' +}; + +// attach to the L.esri global if we can +if(typeof window !== 'undefined' && window.L && window.L.esri) { + window.L.esri.Renderers = EsriLeafletRenderers; +} + +// We do not have an 'Esri' variable e.g loading this file directly from source define 'Esri' +if(!Esri){ + var Esri = window.L.esri; +} + + +EsriLeafletRenderers.Symbol = L.Class.extend({ + + initialize: function(symbolJson){ + this._symbolJson = symbolJson; + this.val = null; + this._styles = {}; + }, + + //the geojson values returned are in points + pixelValue: function(pointValue){ + return pointValue * 1.3333333333333; + }, + + //color is an array [r,g,b,a] + colorValue: function(color){ + return 'rgb(' + color[0] + ',' + color[1] + ',' + color[2] + ')'; + }, + + alphaValue: function(color){ + return color[3] / 255.0; + } +}); + + +EsriLeafletRenderers.PointSymbol = EsriLeafletRenderers.Symbol.extend({ + statics: { + MARKERTYPES: ['esriSMSCircle','esriSMSCross', 'esriSMSDiamond', 'esriSMSSquare', 'esriSMSX', 'esriPMS'] + }, + initialize: function(symbolJson, options){ + EsriLeafletRenderers.Symbol.prototype.initialize.call(this, symbolJson); + if(options) { + this.serviceUrl = options.url; + } + if(symbolJson){ + if(symbolJson.type === 'esriPMS'){ + this._createIcon(); + } 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); + } + + if(this._symbolJson.style === 'esriSMSCircle'){ + this._styles.radius = this.pixelValue(this._symbolJson.size) / 2.0; + } + }, + + _createIcon: function(){ + var height = this.pixelValue(this._symbolJson.height); + var width = this.pixelValue(this._symbolJson.width); + var xOffset = width / 2.0 + this.pixelValue(this._symbolJson.xoffset); + var yOffset = height / 2.0 + this.pixelValue(this._symbolJson.yoffset); + var url = this.serviceUrl + 'images/' + this._symbolJson.url; + + this.icon = L.icon({ + iconUrl: url, + iconSize: [width, height], + iconAnchor: [xOffset, yOffset] + }); + }, + pointToLayer: function(geojson, latlng){ + if (this._symbolJson.type === 'esriPMS'){ + return L.marker(latlng, {icon: this.icon}); + } + + var size = this.pixelValue(this._symbolJson.size); + + switch(this._symbolJson.style){ + case 'esriSMSSquare': + return EsriLeafletRenderers.squareMarker(latlng, size, this._styles); + case 'esriSMSDiamond': + return EsriLeafletRenderers.diamondMarker(latlng, size, this._styles); + case 'esriSMSCross': + return EsriLeafletRenderers.crossMarker(latlng, size, this._styles); + case 'esriSMSX': + return EsriLeafletRenderers.xMarker(latlng, size, this._styles); + } + return L.circleMarker(latlng, this._styles); + } +}); +EsriLeafletRenderers.pointSymbol = function(symbolJson, options){ + return new EsriLeafletRenderers.PointSymbol(symbolJson, options); +}; + + +EsriLeafletRenderers.LineSymbol = EsriLeafletRenderers.Symbol.extend({ + statics: { + //Not implemented 'esriSLSNull' + LINETYPES: ['esriSLSDash','esriSLSDot','esriSLSDashDotDot','esriSLSDashDot','esriSLSSolid'] + }, + initialize: function(symbolJson){ + EsriLeafletRenderers.Symbol.prototype.initialize.call(this, symbolJson); + this._fillStyles(); + }, + + _fillStyles: function(){ + //set the defaults that show up on arcgis online + this._styles.lineCap = 'butt'; + this._styles.lineJoin = 'miter'; + + + if (!this._symbolJson){ + return; + } + + if(this._symbolJson.width){ + this._styles.weight = this.pixelValue(this._symbolJson.width); + } + + if(this._symbolJson.color ){ + this._styles.color = this.colorValue(this._symbolJson.color); + this._styles.opacity = this.alphaValue(this._symbolJson.color); + } + + //usuing dash patterns pulled from arcgis online (converted to pixels) + switch(this._symbolJson.style){ + case 'esriSLSDash': + //4,3 + this._styles.dashArray = '5,4'; + break; + case 'esriSLSDot': + //1,3 + this._styles.dashArray = '1,4'; + break; + case 'esriSLSDashDot': + //8,3,1,3 + this._styles.dashArray = '11,4,1,4'; + break; + case 'esriSLSDashDotDot': + //8,3,1,3,1,3 + this._styles.dashArray = '11,4,1,4,1,4'; + break; + } + }, + + style: function(){ + return this._styles; + } +}); +EsriLeafletRenderers.lineSymbol = function(symbolJson){ + return new EsriLeafletRenderers.LineSymbol(symbolJson); +}; + + +EsriLeafletRenderers.PolygonSymbol = EsriLeafletRenderers.Symbol.extend({ + statics: { + //not implemented: 'esriSFSBackwardDiagonal','esriSFSCross','esriSFSDiagonalCross','esriSFSForwardDiagonal','esriSFSHorizontal','esriSFSNull','esriSFSVertical' + POLYGONTYPES: ['esriSFSSolid'] + }, + initialize: function(symbolJson){ + EsriLeafletRenderers.Symbol.prototype.initialize.call(this, symbolJson); + if (symbolJson){ + this._lineStyles = EsriLeafletRenderers.lineSymbol(symbolJson.outline).style(); + this._fillStyles(); + } + }, + + _fillStyles: function(){ + //set the fill for the polygon + if (this._symbolJson && this._symbolJson.color){ + this._styles.fillColor = this.colorValue(this._symbolJson.color); + this._styles.fillOpacity = this.alphaValue(this._symbolJson.color); + } + + if(this._lineStyles){ + if(this._lineStyles.weight === 0){ + //when weight is 0, setting the stroke to false can still look bad + //(gaps between the polygons) + this._styles.stroke = false; + } else { + //copy the line symbol styles into this symbol's styles + for (var styleAttr in this._lineStyles){ + this._styles[styleAttr] = this._lineStyles[styleAttr]; + } + } + } + }, + + style: function() { + return this._styles; + } +}); +EsriLeafletRenderers.polygonSymbol = function(symbolJson){ + return new EsriLeafletRenderers.PolygonSymbol(symbolJson); +}; + + +EsriLeafletRenderers.Renderer = L.Class.extend({ + + options: { + proportionalPolygon: false, + clickable: true + }, + + initialize: function(rendererJson, options){ + this._rendererJson = rendererJson; + this._pointSymbols = false; + this._symbols = []; + L.Util.setOptions(this, options); + }, + + + _createDefaultSymbol: function(){ + if(this._rendererJson.defaultSymbol){ + this._defaultSymbol = this._newSymbol(this._rendererJson.defaultSymbol); + } + }, + + _newSymbol: function(symbolJson){ + if(symbolJson.type === 'esriSMS' || symbolJson.type === 'esriPMS'){ + this._pointSymbols = true; + return EsriLeafletRenderers.pointSymbol(symbolJson, this.options); + } + if(symbolJson.type === 'esriSLS'){ + return EsriLeafletRenderers.lineSymbol(symbolJson); + } + if(symbolJson.type === 'esriSFS'){ + return EsriLeafletRenderers.polygonSymbol(symbolJson); + } + }, + + _getSymbol: function(){ + //override + }, + + attachStylesToLayer: function(layer){ + if(this._pointSymbols){ + layer.options.pointToLayer = L.Util.bind(this.pointToLayer, this); + } else { + layer.options.style = L.Util.bind(this.style, this); + } + }, + + pointToLayer: function(geojson, latlng){ + var sym = this._getSymbol(geojson); + if(sym){ + return sym.pointToLayer(geojson, latlng); + } + //invisible symbology + return L.circleMarker(latlng, {radius: 0}); + }, + + style: function(feature){ + //find the symbol to represent this feature + var sym = this._getSymbol(feature); + if(sym){ + return sym.style(feature); + }else{ + //invisible symbology + return {opacity: 0, fillOpacity: 0}; + } + } +}); + + +EsriLeafletRenderers.SimpleRenderer = EsriLeafletRenderers.Renderer.extend({ + + initialize: function(rendererJson, options){ + EsriLeafletRenderers.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]; + } +}); + +EsriLeafletRenderers.simpleRenderer = function(rendererJson, options){ + return new EsriLeafletRenderers.SimpleRenderer(rendererJson, options); +}; + + +EsriLeafletRenderers.ClassBreaksRenderer = EsriLeafletRenderers.Renderer.extend({ + + initialize: function(rendererJson, options){ + EsriLeafletRenderers.Renderer.prototype.initialize.call(this, rendererJson, options); + this._field = this._rendererJson.field; + this._createSymbols(); + }, + + _createSymbols: function(){ + var symbol, + classbreaks = this._rendererJson.classBreakInfos; + + this._symbols = []; + + //create a symbol for each class break + for (var i = classbreaks.length - 1; 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); + } + //sort the symbols in ascending value + 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(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; + } +}); + +EsriLeafletRenderers.classBreaksRenderer = function(rendererJson, options){ + return new EsriLeafletRenderers.ClassBreaksRenderer(rendererJson, options); +}; + + +EsriLeafletRenderers.UniqueValueRenderer = EsriLeafletRenderers.Renderer.extend({ + + initialize: function(rendererJson, options){ + EsriLeafletRenderers.Renderer.prototype.initialize.call(this, rendererJson, options); + + //what to do when there are other fields? + this._field = this._rendererJson.field1; + this._createSymbols(); + }, + + _createSymbols: function(){ + var symbol, uniques = this._rendererJson.uniqueValueInfos; + + //create a symbol for each unique value + 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(); + }, + + /* jshint ignore:start */ + _getSymbol: function(feature){ + var val = feature.properties[this._field]; + var symbol = this._defaultSymbol; + for (var i = this._symbols.length - 1; i >= 0; i--){ + //using the === operator does not work if the field + //of the unique renderer is not a string + if(this._symbols[i].val == val){ + symbol = this._symbols[i]; + } + } + return symbol; + } + /* jshint ignore:end */ +}); + +EsriLeafletRenderers.uniqueValueRenderer = function(rendererJson, options){ + return new EsriLeafletRenderers.UniqueValueRenderer(rendererJson, options); +}; + + +EsriLeafletRenderers.SquareMarker = L.Path.extend({ + options: { + fill: true + }, + + initialize: function(center, size, options){ + L.Path.prototype.initialize.call(this, options); + this._size = size; + this._center = center; + }, + + projectLatlngs: function(){ + this._point = this._map.latLngToLayerPoint(this._center); + }, + + getPathString: function(){ + if (!this._map){ + return ''; + } + + var center = this._point, + offset = this._size / 2.0; + + if(L.Path.VML){ + center._round(); + offset = Math.round(offset); + } + + var str = 'M' + (center.x + offset) + ',' + (center.y + offset) + + 'L' + (center.x - offset) + ',' + (center.y + offset) + + 'L' + (center.x - offset) + ',' + (center.y - offset) + + 'L' + (center.x + offset) + ',' + (center.y - offset); + + return str + (L.Browser.svg ? 'z' : 'x'); + }, + + setLatLng: function(latlng){ + this._center = latlng; + return this.redraw(); + }, + + getLatLng: function(){ + return L.latLng(this._center); + }, + + getSize: function(){ + return this._size; + }, + + setSize: function(size){ + this._size = size; + return this.redraw(); + } +}); + +EsriLeafletRenderers.squareMarker = function(center, size, options){ + return new EsriLeafletRenderers.SquareMarker(center, size, options); +}; + + +EsriLeafletRenderers.DiamondMarker = L.Path.extend({ + options: { + fill: true + }, + + initialize: function(center, size, options){ + L.Path.prototype.initialize.call(this, options); + this._size = size; + this._center = center; + }, + + projectLatlngs: function(){ + this._point = this._map.latLngToLayerPoint(this._center); + }, + + getPathString: function(){ + if (!this._map){ + return ''; + } + + var center = this._point, + offset = this._size / 2.0; + + if(L.Path.VML){ + center._round(); + offset = Math.round(offset); + } + + var str = 'M' + center.x + ',' + (center.y + offset) + + 'L' + (center.x - offset) + ',' + center.y + + 'L' + center.x + ',' + (center.y - offset) + + 'L' + (center.x + offset) + ',' + center.y; + + return str + (L.Browser.svg ? 'z' : 'x'); + }, + + setLatLng: function(latlng){ + this._center = latlng; + return this.redraw(); + }, + + getLatLng: function(){ + return L.latLng(this._center); + }, + + getSize: function(){ + return this._size; + }, + + setSize: function(size){ + this._size = size; + return this.redraw(); + } +}); + +EsriLeafletRenderers.diamondMarker = function(center, size, options){ + return new EsriLeafletRenderers.DiamondMarker(center, size, options); +}; + + +EsriLeafletRenderers.CrossMarker = L.Path.extend({ + initialize: function (center, size, options){ + L.Path.prototype.initialize.call(this, options); + this._size = size; + this._center = center; + }, + + projectLatlngs: function(){ + this._point = this._map.latLngToLayerPoint(this._center); + }, + + getPathString: function(){ + if (!this._map){ + return ''; + } + + var center = this._point, + offset = this._size / 2.0; + + if(L.Path.VML){ + center._round(); + offset = Math.round(offset); + } + + return 'M' + center.x + ',' + (center.y + offset) + + 'L' + center.x + ',' + (center.y - offset) + + 'M' + (center.x - offset) + ',' + center.y + + 'L' + (center.x + offset) + ',' + center.y; + }, + + setLatLng: function(latlng){ + this._center = latlng; + return this.redraw(); + }, + + getLatLng: function(){ + return L.latLng(this._center); + }, + + getSize: function(){ + return this._size; + }, + + setSize: function(size){ + this._size = size; + return this.redraw(); + } +}); + +EsriLeafletRenderers.crossMarker = function(center, size, options){ + return new EsriLeafletRenderers.CrossMarker(center, size, options); +}; + + +EsriLeafletRenderers.XMarker = L.Path.extend({ + initialize: function(center, size, options){ + L.Path.prototype.initialize.call(this, options); + this._size = size; + this._center = center; + }, + + projectLatlngs: function(){ + this._point = this._map.latLngToLayerPoint(this._center); + }, + + getPathString: function(){ + if (!this._map){ + return ''; + } + + var center = this._point, + offset = this._size / 2.0; + + if(L.Path.VML){ + center._round(); + offset = Math.round(offset); + } + + return 'M' + (center.x + offset) + ',' + (center.y + offset) + + 'L' + (center.x - offset) + ',' + (center.y - offset) + + 'M' + (center.x - offset) + ',' + (center.y + offset) + + 'L' + (center.x + offset) + ',' + (center.y - offset); + }, + + setLatLng: function(latlng){ + this._center = latlng; + return this.redraw(); + }, + + getLatLng: function(){ + return L.latLng(this._center); + }, + + getSize: function(){ + return this._size; + }, + + setSize: function(size){ + this._size = size; + return this.redraw(); + } +}); + +EsriLeafletRenderers.xMarker = function(center, size, options){ + return new EsriLeafletRenderers.XMarker(center, size, options); +}; + + +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(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(); + + 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.pointToLayer, L.GeoJSON.coordsToLatLng, this.options); + + //add a point layer when the polygon is represented as proportional marker symbols + if(this._hasProportionalSymbols){ + var centroid = this.getPolygonCentroid(geojson.geometry.coordinates); + if(!(isNaN(centroid[0]) || isNaN(centroid[0]))){ + this._createPointLayer(); + + var pointjson = this.getPointJson(geojson, centroid); + this._pointLayer.addData(pointjson); + this._pointLayer.bringToFront(); + } + } + return fLayer; + }; + + this.getPolygonCentroid = function(coordinates){ + var pts = coordinates[0][0]; + if(pts.length === 2){ + pts = coordinates[0]; + } + + + var twicearea=0, + x=0, y=0, + nPts = pts.length, + p1, p2, f; + + for (var i=0, j=nPts-1 ;i0?(this._styles.stroke=!0,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)):this._styles.stroke=!1,this._symbolJson.color&&(this._styles.fillColor=this.colorValue(this._symbolJson.color),this._styles.fillOpacity=this.alphaValue(this._symbolJson.color)),"esriSMSCircle"===this._symbolJson.style&&(this._styles.radius=this.pixelValue(this._symbolJson.size)/2)},_createIcon:function(){var a=this.pixelValue(this._symbolJson.height),b=this.pixelValue(this._symbolJson.width),c=b/2+this.pixelValue(this._symbolJson.xoffset),d=a/2+this.pixelValue(this._symbolJson.yoffset),e=this.serviceUrl+"images/"+this._symbolJson.url;this.icon=L.icon({iconUrl:e,iconSize:[b,a],iconAnchor:[c,d]})},pointToLayer:function(a,b){if("esriPMS"===this._symbolJson.type)return L.marker(b,{icon:this.icon});var c=this.pixelValue(this._symbolJson.size);switch(this._symbolJson.style){case"esriSMSSquare":return EsriLeafletRenderers.squareMarker(b,c,this._styles);case"esriSMSDiamond":return EsriLeafletRenderers.diamondMarker(b,c,this._styles);case"esriSMSCross":return EsriLeafletRenderers.crossMarker(b,c,this._styles);case"esriSMSX":return EsriLeafletRenderers.xMarker(b,c,this._styles)}return L.circleMarker(b,this._styles)}}),EsriLeafletRenderers.pointSymbol=function(a,b){return new EsriLeafletRenderers.PointSymbol(a,b)},EsriLeafletRenderers.LineSymbol=EsriLeafletRenderers.Symbol.extend({statics:{LINETYPES:["esriSLSDash","esriSLSDot","esriSLSDashDotDot","esriSLSDashDot","esriSLSSolid"]},initialize:function(a){EsriLeafletRenderers.Symbol.prototype.initialize.call(this,a),this._fillStyles()},_fillStyles:function(){if(this._styles.lineCap="butt",this._styles.lineJoin="miter",this._symbolJson)switch(this._symbolJson.width&&(this._styles.weight=this.pixelValue(this._symbolJson.width)),this._symbolJson.color&&(this._styles.color=this.colorValue(this._symbolJson.color),this._styles.opacity=this.alphaValue(this._symbolJson.color)),this._symbolJson.style){case"esriSLSDash":this._styles.dashArray="5,4";break;case"esriSLSDot":this._styles.dashArray="1,4";break;case"esriSLSDashDot":this._styles.dashArray="11,4,1,4";break;case"esriSLSDashDotDot":this._styles.dashArray="11,4,1,4,1,4"}},style:function(){return this._styles}}),EsriLeafletRenderers.lineSymbol=function(a){return new EsriLeafletRenderers.LineSymbol(a)},EsriLeafletRenderers.PolygonSymbol=EsriLeafletRenderers.Symbol.extend({statics:{POLYGONTYPES:["esriSFSSolid"]},initialize:function(a){EsriLeafletRenderers.Symbol.prototype.initialize.call(this,a),a&&(this._lineStyles=EsriLeafletRenderers.lineSymbol(a.outline).style(),this._fillStyles())},_fillStyles:function(){if(this._symbolJson&&this._symbolJson.color&&(this._styles.fillColor=this.colorValue(this._symbolJson.color),this._styles.fillOpacity=this.alphaValue(this._symbolJson.color)),this._lineStyles)if(0===this._lineStyles.weight)this._styles.stroke=!1;else for(var a in this._lineStyles)this._styles[a]=this._lineStyles[a]},style:function(){return this._styles}}),EsriLeafletRenderers.polygonSymbol=function(a){return new EsriLeafletRenderers.PolygonSymbol(a)},EsriLeafletRenderers.Renderer=L.Class.extend({options:{proportionalPolygon:!1,clickable:!0},initialize:function(a,b){this._rendererJson=a,this._pointSymbols=!1,this._symbols=[],L.Util.setOptions(this,b)},_createDefaultSymbol:function(){this._rendererJson.defaultSymbol&&(this._defaultSymbol=this._newSymbol(this._rendererJson.defaultSymbol))},_newSymbol:function(a){return"esriSMS"===a.type||"esriPMS"===a.type?(this._pointSymbols=!0,EsriLeafletRenderers.pointSymbol(a,this.options)):"esriSLS"===a.type?EsriLeafletRenderers.lineSymbol(a):"esriSFS"===a.type?EsriLeafletRenderers.polygonSymbol(a):void 0},_getSymbol:function(){},attachStylesToLayer:function(a){this._pointSymbols?a.options.pointToLayer=L.Util.bind(this.pointToLayer,this):a.options.style=L.Util.bind(this.style,this)},pointToLayer:function(a,b){var c=this._getSymbol(a);return c?c.pointToLayer(a,b):L.circleMarker(b,{radius:0})},style:function(a){var b=this._getSymbol(a);return b?b.style(a):{opacity:0,fillOpacity:0}}}),EsriLeafletRenderers.SimpleRenderer=EsriLeafletRenderers.Renderer.extend({initialize:function(a,b){EsriLeafletRenderers.Renderer.prototype.initialize.call(this,a,b),this._createSymbol()},_createSymbol:function(){this._rendererJson.symbol&&this._symbols.push(this._newSymbol(this._rendererJson.symbol))},_getSymbol:function(){return this._symbols[0]}}),EsriLeafletRenderers.simpleRenderer=function(a,b){return new EsriLeafletRenderers.SimpleRenderer(a,b)},EsriLeafletRenderers.ClassBreaksRenderer=EsriLeafletRenderers.Renderer.extend({initialize:function(a,b){EsriLeafletRenderers.Renderer.prototype.initialize.call(this,a,b),this._field=this._rendererJson.field,this._createSymbols()},_createSymbols:function(){var a,b=this._rendererJson.classBreakInfos;this._symbols=[];for(var c=b.length-1;c>=0;c--)a=this._newSymbol(this.options.proportionalPolygon&&this._rendererJson.backgroundFillSymbol?this._rendererJson.backgroundFillSymbol:b[c].symbol),a.val=b[c].classMaxValue,this._symbols.push(a);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(a){var b=a.properties[this._field];if(b>this._maxValue)return this._defaultSymbol;for(var c=this._symbols[0],d=this._symbols.length-1;d>=0&&!(b>this._symbols[d].val);d--)c=this._symbols[d];return c}}),EsriLeafletRenderers.classBreaksRenderer=function(a,b){return new EsriLeafletRenderers.ClassBreaksRenderer(a,b)},EsriLeafletRenderers.UniqueValueRenderer=EsriLeafletRenderers.Renderer.extend({initialize:function(a,b){EsriLeafletRenderers.Renderer.prototype.initialize.call(this,a,b),this._field=this._rendererJson.field1,this._createSymbols()},_createSymbols:function(){for(var a,b=this._rendererJson.uniqueValueInfos,c=b.length-1;c>=0;c--)a=this._newSymbol(b[c].symbol),a.val=b[c].value,this._symbols.push(a);this._createDefaultSymbol()},_getSymbol:function(a){for(var b=a.properties[this._field],c=this._defaultSymbol,d=this._symbols.length-1;d>=0;d--)this._symbols[d].val==b&&(c=this._symbols[d]);return c}}),EsriLeafletRenderers.uniqueValueRenderer=function(a,b){return new EsriLeafletRenderers.UniqueValueRenderer(a,b)},EsriLeafletRenderers.SquareMarker=L.Path.extend({options:{fill:!0},initialize:function(a,b,c){L.Path.prototype.initialize.call(this,c),this._size=b,this._center=a},projectLatlngs:function(){this._point=this._map.latLngToLayerPoint(this._center)},getPathString:function(){if(!this._map)return"";var a=this._point,b=this._size/2;L.Path.VML&&(a._round(),b=Math.round(b));var c="M"+(a.x+b)+","+(a.y+b)+"L"+(a.x-b)+","+(a.y+b)+"L"+(a.x-b)+","+(a.y-b)+"L"+(a.x+b)+","+(a.y-b);return c+(L.Browser.svg?"z":"x")},setLatLng:function(a){return this._center=a,this.redraw()},getLatLng:function(){return L.latLng(this._center)},getSize:function(){return this._size},setSize:function(a){return this._size=a,this.redraw()}}),EsriLeafletRenderers.squareMarker=function(a,b,c){return new EsriLeafletRenderers.SquareMarker(a,b,c)},EsriLeafletRenderers.DiamondMarker=L.Path.extend({options:{fill:!0},initialize:function(a,b,c){L.Path.prototype.initialize.call(this,c),this._size=b,this._center=a},projectLatlngs:function(){this._point=this._map.latLngToLayerPoint(this._center)},getPathString:function(){if(!this._map)return"";var a=this._point,b=this._size/2;L.Path.VML&&(a._round(),b=Math.round(b));var c="M"+a.x+","+(a.y+b)+"L"+(a.x-b)+","+a.y+"L"+a.x+","+(a.y-b)+"L"+(a.x+b)+","+a.y;return c+(L.Browser.svg?"z":"x")},setLatLng:function(a){return this._center=a,this.redraw()},getLatLng:function(){return L.latLng(this._center)},getSize:function(){return this._size},setSize:function(a){return this._size=a,this.redraw()}}),EsriLeafletRenderers.diamondMarker=function(a,b,c){return new EsriLeafletRenderers.DiamondMarker(a,b,c)},EsriLeafletRenderers.CrossMarker=L.Path.extend({initialize:function(a,b,c){L.Path.prototype.initialize.call(this,c),this._size=b,this._center=a},projectLatlngs:function(){this._point=this._map.latLngToLayerPoint(this._center)},getPathString:function(){if(!this._map)return"";var a=this._point,b=this._size/2;return L.Path.VML&&(a._round(),b=Math.round(b)),"M"+a.x+","+(a.y+b)+"L"+a.x+","+(a.y-b)+"M"+(a.x-b)+","+a.y+"L"+(a.x+b)+","+a.y},setLatLng:function(a){return this._center=a,this.redraw()},getLatLng:function(){return L.latLng(this._center)},getSize:function(){return this._size},setSize:function(a){return this._size=a,this.redraw()}}),EsriLeafletRenderers.crossMarker=function(a,b,c){return new EsriLeafletRenderers.CrossMarker(a,b,c)},EsriLeafletRenderers.XMarker=L.Path.extend({initialize:function(a,b,c){L.Path.prototype.initialize.call(this,c),this._size=b,this._center=a},projectLatlngs:function(){this._point=this._map.latLngToLayerPoint(this._center)},getPathString:function(){if(!this._map)return"";var a=this._point,b=this._size/2;return L.Path.VML&&(a._round(),b=Math.round(b)),"M"+(a.x+b)+","+(a.y+b)+"L"+(a.x-b)+","+(a.y-b)+"M"+(a.x-b)+","+(a.y+b)+"L"+(a.x+b)+","+(a.y-b)},setLatLng:function(a){return this._center=a,this.redraw()},getLatLng:function(){return L.latLng(this._center)},getSize:function(){return this._size},setSize:function(a){return this._size=a,this.redraw()}}),EsriLeafletRenderers.xMarker=function(a,b,c){return new EsriLeafletRenderers.XMarker(a,b,c)},Esri.FeatureLayer.addInitHook(function(){var a=L.Util.bind(this.onAdd,this),b=L.Util.bind(this.unbindPopup,this),c=L.Util.bind(this.onRemove,this);L.Util.bind(this.createNewLayer,this),this.metadata(function(b,c){c&&c.drawingInfo&&!this.options.style&&this._setRenderers(c),this._metadataLoaded=!0,this._loadedMap&&(a(this._loadedMap),this._addPointLayer(this._loadedMap))},this),this.onAdd=function(b){this._loadedMap=b,this._metadataLoaded&&(a(this._loadedMap),this._addPointLayer(this._loadedMap))},this.onRemove=function(a){if(c(a),this._pointLayer){var b=this._pointLayer.getLayers();for(var d in b)a.removeLayer(b[d])}},this.unbindPopup=function(){if(b(),this._pointLayer){var a=this._pointLayer.getLayers();for(var c in a)a[c].unbindPopup()}},this._addPointLayer=function(a){this._pointLayer&&(this._pointLayer.addTo(a),this._pointLayer.bringToFront())},this._createPointLayer=function(){if(!this._pointLayer&&(this._pointLayer=L.geoJson(),this._popup)){var a=function(a,b){b.bindPopup(this._popup(a,b),this._popupOptions)};this._pointLayer.options.onEachFeature=L.Util.bind(a,this)}},this.createNewLayer=function(a){var b=L.GeoJSON.geometryToLayer(a,this.options.pointToLayer,L.GeoJSON.coordsToLatLng,this.options);if(this._hasProportionalSymbols){var c=this.getPolygonCentroid(a.geometry.coordinates);if(!isNaN(c[0])&&!isNaN(c[0])){this._createPointLayer();var d=this.getPointJson(a,c);this._pointLayer.addData(d),this._pointLayer.bringToFront()}}return b},this.getPolygonCentroid=function(a){var b=a[0][0];2===b.length&&(b=a[0]);for(var c,d,e,f=0,g=0,h=0,i=b.length,j=0,k=i-1;i>j;k=j++)c=b[j],d=b[k],f+=c[0]*d[1],f-=c[1]*d[0],e=c[0]*d[1]-d[0]*c[1],g+=(c[0]+d[0])*e,h+=(c[1]+d[1])*e;return e=3*f,[g/e,h/e]},this.getPointJson=function(a,b){return{type:"Feature",properties:a.properties,id:a.id,geometry:{type:"Point",coordinates:[b[0],b[1]]}}},this._checkForProportionalSymbols=function(a,b){if(this._hasProportionalSymbols=!1,"esriGeometryPolygon"===a&&(b.backgroundFillSymbol&&(this._hasProportionalSymbols=!0),b.classBreakInfos&&b.classBreakInfos.length)){var c=b.classBreakInfos[0].symbol;!c||"esriSMS"!==c.type&&"esriPMS"!==c.type||(this._hasProportionalSymbols=!0)}},this._setRenderers=function(a){var b,c=a.drawingInfo.renderer,d={url:this.url?this.url:this._service.options.url};switch(c.type){case"classBreaks":if(this._checkForProportionalSymbols(a.geometryType,c),this._hasProportionalSymbols){this._createPointLayer();var e=EsriLeafletRenderers.classBreaksRenderer(c,d);e.attachStylesToLayer(this._pointLayer),d.proportionalPolygon=!0}b=EsriLeafletRenderers.classBreaksRenderer(c,d);break;case"uniqueValue":b=EsriLeafletRenderers.uniqueValueRenderer(c,d);break;default:b=EsriLeafletRenderers.simpleRenderer(c,d)}b.attachStylesToLayer(this)}}); +//# sourceMappingURL=esri-leaflet-renderers.js.map \ No newline at end of file diff --git a/dist/esri-leaflet-renderers.js.map b/dist/esri-leaflet-renderers.js.map new file mode 100644 index 0000000..d34764a --- /dev/null +++ b/dist/esri-leaflet-renderers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"esri-leaflet-renderers.js","sources":["../src/EsriLeafletRenderers.js","../src/Symbols/Symbol.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/Markers/SquareMarker.js","../src/Markers/DiamondMarker.js","../src/Markers/CrossMarker.js","../src/Markers/XMarker.js","../src/FeatureLayerHook.js"],"names":["EsriLeafletRenderers","VERSION","window","L","esri","Renderers","Esri","Symbol","Class","extend","initialize","symbolJson","this","_symbolJson","val","_styles","pixelValue","pointValue","colorValue","color","alphaValue","PointSymbol","statics","MARKERTYPES","options","prototype","call","serviceUrl","url","type","_createIcon","_fillStyles","outline","size","stroke","weight","width","opacity","fillColor","fillOpacity","style","radius","height","xOffset","xoffset","yOffset","yoffset","icon","iconUrl","iconSize","iconAnchor","pointToLayer","geojson","latlng","marker","squareMarker","diamondMarker","crossMarker","xMarker","circleMarker","pointSymbol","LineSymbol","LINETYPES","lineCap","lineJoin","dashArray","lineSymbol","PolygonSymbol","POLYGONTYPES","_lineStyles","styleAttr","polygonSymbol","Renderer","proportionalPolygon","clickable","rendererJson","_rendererJson","_pointSymbols","_symbols","Util","setOptions","_createDefaultSymbol","defaultSymbol","_defaultSymbol","_newSymbol","_getSymbol","attachStylesToLayer","layer","bind","sym","feature","SimpleRenderer","_createSymbol","symbol","push","simpleRenderer","ClassBreaksRenderer","_field","field","_createSymbols","classbreaks","classBreakInfos","i","length","backgroundFillSymbol","classMaxValue","sort","a","b","_maxValue","properties","classBreaksRenderer","UniqueValueRenderer","field1","uniques","uniqueValueInfos","value","uniqueValueRenderer","SquareMarker","Path","fill","center","_size","_center","projectLatlngs","_point","_map","latLngToLayerPoint","getPathString","offset","VML","_round","Math","round","str","x","y","Browser","svg","setLatLng","redraw","getLatLng","latLng","getSize","setSize","DiamondMarker","CrossMarker","XMarker","FeatureLayer","addInitHook","oldOnAdd","onAdd","oldUnbindPopup","unbindPopup","oldOnRemove","onRemove","createNewLayer","metadata","error","response","drawingInfo","_setRenderers","_metadataLoaded","_loadedMap","_addPointLayer","map","_pointLayer","pointLayers","getLayers","removeLayer","addTo","bringToFront","_createPointLayer","geoJson","_popup","popupFunction","bindPopup","_popupOptions","onEachFeature","fLayer","GeoJSON","geometryToLayer","coordsToLatLng","_hasProportionalSymbols","centroid","getPolygonCentroid","geometry","coordinates","isNaN","pointjson","getPointJson","addData","pts","p1","p2","f","twicearea","nPts","j","id","_checkForProportionalSymbols","geometryType","renderer","rend","rendererInfo","_service","pRend"],"mappings":";;;;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attach to the L.esri global if we can\nif(typeof window !== 'undefined' && window.L && window.L.esri) {\n window.L.esri.Renderers = EsriLeafletRenderers;\n}\n\n// We do not have an 'Esri' variable e.g loading this file directly from source define 'Esri'\nif(!Esri){\n var Esri = window.L.esri;\n}\n","EsriLeafletRenderers.Symbol = L.Class.extend({\n\n initialize: function(symbolJson){\n this._symbolJson = symbolJson;\n this.val = null;\n this._styles = {};\n },\n\n //the geojson values returned are in points\n pixelValue: function(pointValue){\n return pointValue * 1.3333333333333;\n },\n\n //color is an array [r,g,b,a]\n colorValue: function(color){\n return 'rgb(' + color[0] + ',' + color[1] + ',' + color[2] + ')';\n },\n\n alphaValue: function(color){\n return color[3] / 255.0;\n }\n});\n","EsriLeafletRenderers.PointSymbol = EsriLeafletRenderers.Symbol.extend({\n statics: {\n MARKERTYPES: ['esriSMSCircle','esriSMSCross', 'esriSMSDiamond', 'esriSMSSquare', 'esriSMSX', 'esriPMS']\n },\n initialize: function(symbolJson, options){\n EsriLeafletRenderers.Symbol.prototype.initialize.call(this, symbolJson);\n if(options) {\n this.serviceUrl = options.url;\n }\n if(symbolJson){\n if(symbolJson.type === 'esriPMS'){\n this._createIcon();\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 }\n\n if(this._symbolJson.style === 'esriSMSCircle'){\n this._styles.radius = this.pixelValue(this._symbolJson.size) / 2.0;\n }\n },\n\n _createIcon: function(){\n var height = this.pixelValue(this._symbolJson.height);\n var width = this.pixelValue(this._symbolJson.width);\n var xOffset = width / 2.0 + this.pixelValue(this._symbolJson.xoffset);\n var yOffset = height / 2.0 + this.pixelValue(this._symbolJson.yoffset);\n var url = this.serviceUrl + 'images/' + this._symbolJson.url;\n\n this.icon = L.icon({\n iconUrl: url,\n iconSize: [width, height],\n iconAnchor: [xOffset, yOffset]\n });\n },\n pointToLayer: function(geojson, latlng){\n if (this._symbolJson.type === 'esriPMS'){\n return L.marker(latlng, {icon: this.icon});\n }\n\n var size = this.pixelValue(this._symbolJson.size);\n\n switch(this._symbolJson.style){\n case 'esriSMSSquare':\n return EsriLeafletRenderers.squareMarker(latlng, size, this._styles);\n case 'esriSMSDiamond':\n return EsriLeafletRenderers.diamondMarker(latlng, size, this._styles);\n case 'esriSMSCross':\n return EsriLeafletRenderers.crossMarker(latlng, size, this._styles);\n case 'esriSMSX':\n return EsriLeafletRenderers.xMarker(latlng, size, this._styles);\n }\n return L.circleMarker(latlng, this._styles);\n }\n});\nEsriLeafletRenderers.pointSymbol = function(symbolJson, options){\n return new EsriLeafletRenderers.PointSymbol(symbolJson, options);\n};\n","EsriLeafletRenderers.LineSymbol = EsriLeafletRenderers.Symbol.extend({\n statics: {\n //Not implemented 'esriSLSNull'\n LINETYPES: ['esriSLSDash','esriSLSDot','esriSLSDashDotDot','esriSLSDashDot','esriSLSSolid']\n },\n initialize: function(symbolJson){\n EsriLeafletRenderers.Symbol.prototype.initialize.call(this, symbolJson);\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\n\n if (!this._symbolJson){\n return;\n }\n\n if(this._symbolJson.width){\n this._styles.weight = this.pixelValue(this._symbolJson.width);\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 //usuing dash patterns pulled from arcgis online (converted to pixels)\n switch(this._symbolJson.style){\n case 'esriSLSDash':\n //4,3\n this._styles.dashArray = '5,4';\n break;\n case 'esriSLSDot':\n //1,3\n this._styles.dashArray = '1,4';\n break;\n case 'esriSLSDashDot':\n //8,3,1,3\n this._styles.dashArray = '11,4,1,4';\n break;\n case 'esriSLSDashDotDot':\n //8,3,1,3,1,3\n this._styles.dashArray = '11,4,1,4,1,4';\n break;\n }\n },\n\n style: function(){\n return this._styles;\n }\n});\nEsriLeafletRenderers.lineSymbol = function(symbolJson){\n return new EsriLeafletRenderers.LineSymbol(symbolJson);\n};\n","EsriLeafletRenderers.PolygonSymbol = EsriLeafletRenderers.Symbol.extend({\n statics: {\n //not implemented: 'esriSFSBackwardDiagonal','esriSFSCross','esriSFSDiagonalCross','esriSFSForwardDiagonal','esriSFSHorizontal','esriSFSNull','esriSFSVertical'\n POLYGONTYPES: ['esriSFSSolid']\n },\n initialize: function(symbolJson){\n EsriLeafletRenderers.Symbol.prototype.initialize.call(this, symbolJson);\n if (symbolJson){\n this._lineStyles = EsriLeafletRenderers.lineSymbol(symbolJson.outline).style();\n this._fillStyles();\n }\n },\n\n _fillStyles: function(){\n //set the fill for the polygon\n if (this._symbolJson && this._symbolJson.color){\n this._styles.fillColor = this.colorValue(this._symbolJson.color);\n this._styles.fillOpacity = this.alphaValue(this._symbolJson.color);\n }\n\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\n style: function() {\n return this._styles;\n }\n});\nEsriLeafletRenderers.polygonSymbol = function(symbolJson){\n return new EsriLeafletRenderers.PolygonSymbol(symbolJson);\n};\n","EsriLeafletRenderers.Renderer = L.Class.extend({\n\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 L.Util.setOptions(this, options);\n },\n\n\n _createDefaultSymbol: function(){\n if(this._rendererJson.defaultSymbol){\n this._defaultSymbol = this._newSymbol(this._rendererJson.defaultSymbol);\n }\n },\n\n _newSymbol: function(symbolJson){\n if(symbolJson.type === 'esriSMS' || symbolJson.type === 'esriPMS'){\n this._pointSymbols = true;\n return EsriLeafletRenderers.pointSymbol(symbolJson, this.options);\n }\n if(symbolJson.type === 'esriSLS'){\n return EsriLeafletRenderers.lineSymbol(symbolJson);\n }\n if(symbolJson.type === 'esriSFS'){\n return EsriLeafletRenderers.polygonSymbol(symbolJson);\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){\n return sym.pointToLayer(geojson, latlng);\n }\n //invisible symbology\n return L.circleMarker(latlng, {radius: 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);\n }else{\n //invisible symbology\n return {opacity: 0, fillOpacity: 0};\n }\n }\n});\n","EsriLeafletRenderers.SimpleRenderer = EsriLeafletRenderers.Renderer.extend({\n\n initialize: function(rendererJson, options){\n EsriLeafletRenderers.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\nEsriLeafletRenderers.simpleRenderer = function(rendererJson, options){\n return new EsriLeafletRenderers.SimpleRenderer(rendererJson, options);\n};\n","EsriLeafletRenderers.ClassBreaksRenderer = EsriLeafletRenderers.Renderer.extend({\n\n initialize: function(rendererJson, options){\n EsriLeafletRenderers.Renderer.prototype.initialize.call(this, rendererJson, options);\n this._field = this._rendererJson.field;\n this._createSymbols();\n },\n\n _createSymbols: function(){\n var symbol,\n 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(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\nEsriLeafletRenderers.classBreaksRenderer = function(rendererJson, options){\n return new EsriLeafletRenderers.ClassBreaksRenderer(rendererJson, options);\n};\n","EsriLeafletRenderers.UniqueValueRenderer = EsriLeafletRenderers.Renderer.extend({\n\n initialize: function(rendererJson, options){\n EsriLeafletRenderers.Renderer.prototype.initialize.call(this, rendererJson, options);\n\n //what to do when there are other fields?\n this._field = this._rendererJson.field1;\n this._createSymbols();\n },\n\n _createSymbols: function(){\n var symbol, 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 /* jshint ignore:start */\n _getSymbol: function(feature){\n var val = feature.properties[this._field];\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 if(this._symbols[i].val == val){\n symbol = this._symbols[i];\n }\n }\n return symbol;\n }\n /* jshint ignore:end */\n});\n\nEsriLeafletRenderers.uniqueValueRenderer = function(rendererJson, options){\n return new EsriLeafletRenderers.UniqueValueRenderer(rendererJson, options);\n};\n","EsriLeafletRenderers.SquareMarker = L.Path.extend({\n options: {\n fill: true\n },\n\n initialize: function(center, size, options){\n L.Path.prototype.initialize.call(this, options);\n this._size = size;\n this._center = center;\n },\n\n projectLatlngs: function(){\n this._point = this._map.latLngToLayerPoint(this._center);\n },\n\n getPathString: function(){\n if (!this._map){\n return '';\n }\n\n var center = this._point,\n offset = this._size / 2.0;\n\n if(L.Path.VML){\n center._round();\n offset = Math.round(offset);\n }\n\n var str = 'M' + (center.x + offset) + ',' + (center.y + offset) +\n 'L' + (center.x - offset) + ',' + (center.y + offset) +\n 'L' + (center.x - offset) + ',' + (center.y - offset) +\n 'L' + (center.x + offset) + ',' + (center.y - offset);\n\n return str + (L.Browser.svg ? 'z' : 'x');\n },\n\n setLatLng: function(latlng){\n this._center = latlng;\n return this.redraw();\n },\n\n getLatLng: function(){\n return L.latLng(this._center);\n },\n\n getSize: function(){\n return this._size;\n },\n\n setSize: function(size){\n this._size = size;\n return this.redraw();\n }\n});\n\nEsriLeafletRenderers.squareMarker = function(center, size, options){\n return new EsriLeafletRenderers.SquareMarker(center, size, options);\n};\n","EsriLeafletRenderers.DiamondMarker = L.Path.extend({\n options: {\n fill: true\n },\n\n initialize: function(center, size, options){\n L.Path.prototype.initialize.call(this, options);\n this._size = size;\n this._center = center;\n },\n\n projectLatlngs: function(){\n this._point = this._map.latLngToLayerPoint(this._center);\n },\n\n getPathString: function(){\n if (!this._map){\n return '';\n }\n\n var center = this._point,\n offset = this._size / 2.0;\n\n if(L.Path.VML){\n center._round();\n offset = Math.round(offset);\n }\n\n var str = 'M' + center.x + ',' + (center.y + offset) +\n 'L' + (center.x - offset) + ',' + center.y +\n 'L' + center.x + ',' + (center.y - offset) +\n 'L' + (center.x + offset) + ',' + center.y;\n\n return str + (L.Browser.svg ? 'z' : 'x');\n },\n\n setLatLng: function(latlng){\n this._center = latlng;\n return this.redraw();\n },\n\n getLatLng: function(){\n return L.latLng(this._center);\n },\n\n getSize: function(){\n return this._size;\n },\n\n setSize: function(size){\n this._size = size;\n return this.redraw();\n }\n});\n\nEsriLeafletRenderers.diamondMarker = function(center, size, options){\n return new EsriLeafletRenderers.DiamondMarker(center, size, options);\n};\n","EsriLeafletRenderers.CrossMarker = L.Path.extend({\n initialize: function (center, size, options){\n L.Path.prototype.initialize.call(this, options);\n this._size = size;\n this._center = center;\n },\n\n projectLatlngs: function(){\n this._point = this._map.latLngToLayerPoint(this._center);\n },\n\n getPathString: function(){\n if (!this._map){\n return '';\n }\n\n var center = this._point,\n offset = this._size / 2.0;\n\n if(L.Path.VML){\n center._round();\n offset = Math.round(offset);\n }\n\n return 'M' + center.x + ',' + (center.y + offset) +\n 'L' + center.x + ',' + (center.y - offset) +\n 'M' + (center.x - offset) + ',' + center.y +\n 'L' + (center.x + offset) + ',' + center.y;\n },\n\n setLatLng: function(latlng){\n this._center = latlng;\n return this.redraw();\n },\n\n getLatLng: function(){\n return L.latLng(this._center);\n },\n\n getSize: function(){\n return this._size;\n },\n\n setSize: function(size){\n this._size = size;\n return this.redraw();\n }\n});\n\nEsriLeafletRenderers.crossMarker = function(center, size, options){\n return new EsriLeafletRenderers.CrossMarker(center, size, options);\n};\n","EsriLeafletRenderers.XMarker = L.Path.extend({\n initialize: function(center, size, options){\n L.Path.prototype.initialize.call(this, options);\n this._size = size;\n this._center = center;\n },\n\n projectLatlngs: function(){\n this._point = this._map.latLngToLayerPoint(this._center);\n },\n\n getPathString: function(){\n if (!this._map){\n return '';\n }\n\n var center = this._point,\n offset = this._size / 2.0;\n\n if(L.Path.VML){\n center._round();\n offset = Math.round(offset);\n }\n\n return 'M' + (center.x + offset) + ',' + (center.y + offset) +\n 'L' + (center.x - offset) + ',' + (center.y - offset) +\n 'M' + (center.x - offset) + ',' + (center.y + offset) +\n 'L' + (center.x + offset) + ',' + (center.y - offset);\n },\n\n setLatLng: function(latlng){\n this._center = latlng;\n return this.redraw();\n },\n\n getLatLng: function(){\n return L.latLng(this._center);\n },\n\n getSize: function(){\n return this._size;\n },\n\n setSize: function(size){\n this._size = size;\n return this.redraw();\n }\n});\n\nEsriLeafletRenderers.xMarker = function(center, size, options){\n return new EsriLeafletRenderers.XMarker(center, size, options);\n};\n","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(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\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\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\n var fLayer = L.GeoJSON.geometryToLayer(geojson, this.options.pointToLayer, L.GeoJSON.coordsToLatLng, 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 pointjson = this.getPointJson(geojson, centroid);\n this._pointLayer.addData(pointjson);\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\n var twicearea=0,\n x=0, y=0,\n nPts = pts.length,\n p1, p2, f;\n\n for (var i=0, j=nPts-1 ;i