From 42b6c318841d049d9e26331e48c69b4a55e1159b Mon Sep 17 00:00:00 2001 From: Rachel Nehmer Date: Thu, 10 Sep 2015 14:51:31 -0700 Subject: [PATCH 01/27] install semistandard not grunt --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 071fff2..a68448f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ language: node_js +before_install: npm install -g semistandard sudo: false node_js: - "0.12" cache: directories: - - node_modules \ No newline at end of file + - node_modules From 38f7221bce11fbff3952024008699ee7d544bccb Mon Sep 17 00:00:00 2001 From: Rachel Nehmer Date: Fri, 11 Sep 2015 11:53:29 -0700 Subject: [PATCH 02/27] use newer shape markers with correct case on filename --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 03a7400..636efe6 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "dependencies": { "esri-leaflet": "^2.0.0-beta.5", "leaflet": "^1.0.0-beta.1", - "leaflet-shape-markers": "^1.0.3" + "leaflet-shape-markers": "^1.0.4" }, "devDependencies": { "babelify": "^6.1.3", From 3dad2ce5a4eaf0c138c87cec135b15311da3c9c2 Mon Sep 17 00:00:00 2001 From: Rachel Nehmer Date: Fri, 11 Sep 2015 11:57:52 -0700 Subject: [PATCH 03/27] fix filename case --- src/FeatureLayerHook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FeatureLayerHook.js b/src/FeatureLayerHook.js index 7110095..5101b10 100644 --- a/src/FeatureLayerHook.js +++ b/src/FeatureLayerHook.js @@ -3,7 +3,7 @@ import classBreaksRenderer from './Renderers/ClassBreaksRenderer'; import uniqueValueRenderer from './Renderers/UniqueValueRenderer'; -import simpleRenderer from './Renderers/simpleRenderer'; +import simpleRenderer from './Renderers/SimpleRenderer'; L.esri.FeatureLayer.addInitHook(function () { var oldOnAdd = L.Util.bind(this.onAdd, this); From bd87b01eec52bb0f8ad7fe082c383a7a021bacfe Mon Sep 17 00:00:00 2001 From: Rachel Nehmer Date: Fri, 11 Sep 2015 12:04:05 -0700 Subject: [PATCH 04/27] remove unnecessary before_install --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a68448f..3d5f0ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: node_js -before_install: npm install -g semistandard sudo: false node_js: - "0.12" From 4515d3f1861ac773524ff193ba5ccedf8f226667 Mon Sep 17 00:00:00 2001 From: Rachel Nehmer Date: Fri, 11 Sep 2015 12:40:48 -0700 Subject: [PATCH 05/27] add leaflet and karma globals to comment for semistandard and removed a test --- spec/Markers/CrossMarkerSpec.js | 1 + spec/Markers/DiamondMarkerSpec.js | 1 + spec/Markers/SquareMarkerSpec.js | 1 + spec/Markers/XMarkerSpec.js | 1 + spec/Renderers/ClassBreaksRendererSpec.js | 1 + spec/Renderers/SimpleRendererSpec.js | 1 + spec/Renderers/SmartClassBreaksRendererSpec.js | 1 + spec/Renderers/UniqueValueRendererSpec.js | 1 + spec/Symbols/LineSymbolSpec.js | 1 + spec/Symbols/PointSymbolSpec.js | 1 + spec/Symbols/PolygonSymbolSpec.js | 7 +------ 11 files changed, 11 insertions(+), 6 deletions(-) diff --git a/spec/Markers/CrossMarkerSpec.js b/spec/Markers/CrossMarkerSpec.js index a8024b6..e23652d 100644 --- a/spec/Markers/CrossMarkerSpec.js +++ b/spec/Markers/CrossMarkerSpec.js @@ -1,3 +1,4 @@ +/* global L beforeEach describe expect it */ describe('CrossMarker', function () { describe('#_size', function () { var map; diff --git a/spec/Markers/DiamondMarkerSpec.js b/spec/Markers/DiamondMarkerSpec.js index 97dc39a..27be6e9 100644 --- a/spec/Markers/DiamondMarkerSpec.js +++ b/spec/Markers/DiamondMarkerSpec.js @@ -1,3 +1,4 @@ +/* global L beforeEach describe expect it */ describe('DiamondMarker', function () { describe('#_size', function () { var map; diff --git a/spec/Markers/SquareMarkerSpec.js b/spec/Markers/SquareMarkerSpec.js index 3951f29..b18d6ae 100644 --- a/spec/Markers/SquareMarkerSpec.js +++ b/spec/Markers/SquareMarkerSpec.js @@ -1,3 +1,4 @@ +/* global L beforeEach describe expect it */ describe('SquareMarker', function () { describe('#_size', function () { var map; diff --git a/spec/Markers/XMarkerSpec.js b/spec/Markers/XMarkerSpec.js index 5b18fc4..ab71920 100644 --- a/spec/Markers/XMarkerSpec.js +++ b/spec/Markers/XMarkerSpec.js @@ -1,3 +1,4 @@ +/* global L beforeEach describe expect it */ describe('XMarker', function () { describe('#_size', function () { var map; diff --git a/spec/Renderers/ClassBreaksRendererSpec.js b/spec/Renderers/ClassBreaksRendererSpec.js index 6da6510..5aa130f 100644 --- a/spec/Renderers/ClassBreaksRendererSpec.js +++ b/spec/Renderers/ClassBreaksRendererSpec.js @@ -1,3 +1,4 @@ +/* global L beforeEach describe expect it */ describe('ClassBreaksRenderer', function () { describe('should create renderer from JSON', function () { var rendererJson; diff --git a/spec/Renderers/SimpleRendererSpec.js b/spec/Renderers/SimpleRendererSpec.js index 5274a73..c481234 100644 --- a/spec/Renderers/SimpleRendererSpec.js +++ b/spec/Renderers/SimpleRendererSpec.js @@ -1,3 +1,4 @@ +/* global L beforeEach describe expect it */ describe('SimpleRenderer', function () { describe('should create renderer from JSON', function () { var rendererJson; diff --git a/spec/Renderers/SmartClassBreaksRendererSpec.js b/spec/Renderers/SmartClassBreaksRendererSpec.js index f823deb..e4363b6 100644 --- a/spec/Renderers/SmartClassBreaksRendererSpec.js +++ b/spec/Renderers/SmartClassBreaksRendererSpec.js @@ -1,3 +1,4 @@ +/* global L beforeEach describe expect it */ describe('SmartClassbreaksRenderer', function () { describe('should create renderer with size variables from JSON', function () { var renderer, pointFeatureOne, pointFeatureTwo, sizeInfoJson; diff --git a/spec/Renderers/UniqueValueRendererSpec.js b/spec/Renderers/UniqueValueRendererSpec.js index e29daeb..fff8f60 100644 --- a/spec/Renderers/UniqueValueRendererSpec.js +++ b/spec/Renderers/UniqueValueRendererSpec.js @@ -1,3 +1,4 @@ +/* global L beforeEach describe expect it */ describe('UniqueValueRenderer', function () { describe('should create renderer from JSON', function () { var rendererJson; diff --git a/spec/Symbols/LineSymbolSpec.js b/spec/Symbols/LineSymbolSpec.js index a60d612..8d7424f 100644 --- a/spec/Symbols/LineSymbolSpec.js +++ b/spec/Symbols/LineSymbolSpec.js @@ -1,3 +1,4 @@ +/* global L beforeEach describe expect it */ describe('LineSymbol', function () { describe('#_symbolJson', function () { var symbolHelper; diff --git a/spec/Symbols/PointSymbolSpec.js b/spec/Symbols/PointSymbolSpec.js index 503d895..379b057 100644 --- a/spec/Symbols/PointSymbolSpec.js +++ b/spec/Symbols/PointSymbolSpec.js @@ -1,3 +1,4 @@ +/* global L beforeEach describe expect it */ describe('PointSymbol', function () { describe('#_symbolJson', function () { it('should set defaults', function () { diff --git a/spec/Symbols/PolygonSymbolSpec.js b/spec/Symbols/PolygonSymbolSpec.js index f67b88a..bea9b0f 100644 --- a/spec/Symbols/PolygonSymbolSpec.js +++ b/spec/Symbols/PolygonSymbolSpec.js @@ -1,3 +1,4 @@ +/* global L beforeEach describe expect it */ describe('PolygonSymbol', function () { describe('#_symbolJson', function () { var symbolHelper; @@ -6,12 +7,6 @@ describe('PolygonSymbol', function () { symbolHelper = new L.esri.Renderers.Symbol(); }); - it('should set defaults', function () { - var symbol = L.esri.Renderers.polygonSymbol({}); - var styles = symbol.style(); - // TODO: make an actual test - }); - describe('should set style from solid polygon symbol esriFSSolid', function () { var solidPolygon; From 9b29c1d1936e7ebad659f0b3769021bc00d5f5bb Mon Sep 17 00:00:00 2001 From: john gravois Date: Fri, 11 Sep 2015 17:02:29 -0700 Subject: [PATCH 06/27] bump comparisons sample --- spec/comparisons.html | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/spec/comparisons.html b/spec/comparisons.html index 68979f7..bdecb96 100644 --- a/spec/comparisons.html +++ b/spec/comparisons.html @@ -11,11 +11,10 @@ + - - - - + + @@ -47,9 +46,9 @@

Esri JS API

title: 'Freeways', geoType: 'Line', rendererType: 'Simple', - lat: 38, - lon: -95, - zoomLevel: 4 + lat: 37.4, + lon: -81.7, + zoomLevel: 6 }, { url: 'http://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_States_Generalized/FeatureServer/0', title: 'USA States (Generalized)', @@ -63,9 +62,9 @@

Esri JS API

title: 'Timezones', geoType: 'Polygon', rendererType: 'Unique Value', - lat: 0, - lon: 0, - zoomLevel: 1 + lat: 16.6, + lon: 74.9, + zoomLevel: 3 }, { url: 'http://services.arcgis.com/rOo16HdIMeOBI4Mb/ArcGIS/rest/services/minop3x020_nt00020/FeatureServer/0', title: 'Esri Marker Symbols Test', @@ -81,7 +80,7 @@

Esri JS API

rendererType: 'Unique Value', lat: 0, lon: 0, - zoomLevel: 1 + zoomLevel: 4 }]; var options = ""; @@ -125,7 +124,11 @@

Esri JS API

var map = L.map('map').setView([layer.lat, layer.lon], layer.zoomLevel); L.esri.basemapLayer('Gray').addTo(map); L.esri.basemapLayer('GrayLabels').addTo(map); - var fl = L.esri.featureLayer({url: layer.url}); + var fl = L.esri.featureLayer({ + url: layer.url, + simplifyFactor: .005 + + }); map.addLayer(fl); function updateLeafletMap(layer) { From 5227f0aa5edfc59f8a258f04cfac11a1443d9921 Mon Sep 17 00:00:00 2001 From: john gravois Date: Fri, 11 Sep 2015 12:18:38 -0700 Subject: [PATCH 07/27] add badge to readme and bump sample code added more explicit info about version dependencies --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c18ea17..d004313 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Leaflet plugin for [ArcGIS Feature Services](http://developers.arcgis.com). Esri Leaflet Renderers works in conjunction with the Esri Leaflet Plugin to draw [feature services](http://esri.github.io/esri-leaflet/examples/simple-feature-layer.html) using renderers defined by the service. -**Esri Leaflet Renderers is currently in development and should be thought of as a beta or preview.** +[![travis](https://img.shields.io/travis/Esri/Leaflet.shapeMarkers/master.svg?style=flat-square)](https://travis-ci.org/Esri/Leaflet.shapeMarkers) ### Example Take a look at the [live demo](http://esri.github.io/esri-leaflet-renderers/index.html). @@ -18,15 +18,16 @@ You can also find a side by side comparison of the ArcGIS API for JavaScript [he - - + + - + - + + + + + +
+ + + + + diff --git a/src/Renderers/Renderer.js b/src/Renderers/Renderer.js index ae92f05..45b7b75 100644 --- a/src/Renderers/Renderer.js +++ b/src/Renderers/Renderer.js @@ -57,6 +57,7 @@ export var Renderer = L.Class.extend({ layer.options.pointToLayer = L.Util.bind(this.pointToLayer, this); } else { layer.options.style = L.Util.bind(this.style, this); + layer._originalStyle = layer.options.style; } }, From 939ea2ced5acdf8cb0e03c070b7732dcd3c068fa Mon Sep 17 00:00:00 2001 From: Rachel Nehmer Date: Tue, 20 Oct 2015 11:39:22 -0700 Subject: [PATCH 16/27] merge user styles into renderer definition styles update resetStyles spec to use merged styles as original styles --- spec/reset-style.html | 7 ++++++- src/FeatureLayerHook.js | 5 ++++- src/Renderers/Renderer.js | 28 ++++++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/spec/reset-style.html b/spec/reset-style.html index 9798565..df4a582 100644 --- a/spec/reset-style.html +++ b/spec/reset-style.html @@ -30,7 +30,12 @@ L.esri.basemapLayer('Gray').addTo(map); var neighborhoods = L.esri.featureLayer({ - url: 'http://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Neighborhoods_pdx/FeatureServer/0' + url: 'http://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Neighborhoods_pdx/FeatureServer/0', + style: function(feature) { + if (feature.properties.NAME === 'DOWNTOWN') { + return {fillColor: '#C00'}; + } + } }).addTo(map); neighborhoods.on('mouseover', function(e){ diff --git a/src/FeatureLayerHook.js b/src/FeatureLayerHook.js index 5101b10..3989305 100644 --- a/src/FeatureLayerHook.js +++ b/src/FeatureLayerHook.js @@ -15,7 +15,7 @@ L.esri.FeatureLayer.addInitHook(function () { if (error) { return; } - if (response && response.drawingInfo && !this.options.style) { + if (response && response.drawingInfo) { this._setRenderers(response); } @@ -167,6 +167,9 @@ L.esri.FeatureLayer.addInitHook(function () { if (geojson.drawingInfo.transparency) { options.layerTransparency = geojson.drawingInfo.transparency; } + if (this.options.style) { + options.userDefinedStyle = this.options.style; + } switch (rendererInfo.type) { case 'classBreaks': diff --git a/src/Renderers/Renderer.js b/src/Renderers/Renderer.js index 45b7b75..eed61da 100644 --- a/src/Renderers/Renderer.js +++ b/src/Renderers/Renderer.js @@ -71,14 +71,38 @@ export var Renderer = L.Class.extend({ }, style: function (feature) { + var userStyles; + if (this.options.userDefinedStyle) { + userStyles = this.options.userDefinedStyle(feature); + } // find the symbol to represent this feature var sym = this._getSymbol(feature); if (sym) { - return sym.style(feature, this._visualVariables); + return this.mergeStyles(sym.style(feature, this._visualVariables), userStyles); } else { // invisible symbology - return {opacity: 0, fillOpacity: 0}; + return this.mergeStyles({opacity: 0, fillOpacity: 0}, userStyles); + } + }, + + mergeStyles: function (styles, userStyles) { + var mergedStyles = {}; + var attr; + // copy renderer style attributes + for (attr in styles) { + if (styles.hasOwnProperty(attr)) { + mergedStyles[attr] = styles[attr]; + } + } + // override with user defined style attributes + if (userStyles) { + for (attr in userStyles) { + if (userStyles.hasOwnProperty(attr)) { + mergedStyles[attr] = userStyles[attr]; + } + } } + return mergedStyles; } }); From 702baccd4ee6c1f24414cf75d373c777bf6cfe3a Mon Sep 17 00:00:00 2001 From: Rachel Nehmer Date: Tue, 20 Oct 2015 14:53:33 -0700 Subject: [PATCH 17/27] tests for style mixin --- spec/Renderers/ClassBreaksRendererSpec.js | 15 +++++++++++++++ spec/Renderers/SimpleRendererSpec.js | 15 +++++++++++++++ spec/Renderers/UniqueValueRendererSpec.js | 15 +++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/spec/Renderers/ClassBreaksRendererSpec.js b/spec/Renderers/ClassBreaksRendererSpec.js index 5aa130f..dfacdcb 100644 --- a/spec/Renderers/ClassBreaksRendererSpec.js +++ b/spec/Renderers/ClassBreaksRendererSpec.js @@ -79,5 +79,20 @@ describe('ClassBreaksRenderer', function () { var sym = renderer._getSymbol(feature); expect(sym.val).to.be.eq(64615118); }); + + it('should merge symbol styles', function () { + var options = { + userDefinedStyle: function (feature) { + return {opacity: 0.5}; + } + } + var renderer = L.esri.Renderers.classBreaksRenderer(rendererJson, options); + var feature = {'properties': {'SHAPE_AREA': 50000000}}; + var style = renderer.style(feature); + // user style + expect(style.opacity).to.be.eq(0.5); + // renderer style + expect(style.weight).to.be.greaterThan(1); + }); }); }); diff --git a/spec/Renderers/SimpleRendererSpec.js b/spec/Renderers/SimpleRendererSpec.js index c481234..978d074 100644 --- a/spec/Renderers/SimpleRendererSpec.js +++ b/spec/Renderers/SimpleRendererSpec.js @@ -24,5 +24,20 @@ describe('SimpleRenderer', function () { var renderer = L.esri.Renderers.simpleRenderer(rendererJson); expect(renderer._symbols.length).to.be.eq(1); }); + + + it('should merge symbol styles', function () { + var options = { + userDefinedStyle: function (feature) { + return {opacity: 0.5}; + } + } + var renderer = L.esri.Renderers.simpleRenderer(rendererJson, options); + var style = renderer.style(); + // user style + expect(style.opacity).to.be.eq(0.5); + // renderer style + expect(style.weight).to.be.lessThan(1); + }); }); }); diff --git a/spec/Renderers/UniqueValueRendererSpec.js b/spec/Renderers/UniqueValueRendererSpec.js index fff8f60..52d1047 100644 --- a/spec/Renderers/UniqueValueRendererSpec.js +++ b/spec/Renderers/UniqueValueRendererSpec.js @@ -70,6 +70,21 @@ describe('UniqueValueRenderer', function () { expect(renderer._symbols.length).to.be.eq(3); }); + it('should merge symbol styles', function () { + var options = { + userDefinedStyle: function (feature) { + return {opacity: 0.5}; + } + } + var renderer = L.esri.Renderers.uniqueValueRenderer(rendererJson, options); + var feature = {'properties': {'ZONE': -12, 'VALUE': '$25.00', 'MARKET': '2Z'}}; + var style = renderer.style(feature); + // user style + expect(style.opacity).to.be.eq(0.5); + // renderer style + expect(style.weight).to.be.greaterThan(1); + }); + describe('symbol transparency', function () { it('should be equal to symbol value when no layer transparency defined', function () { var renderer = L.esri.Renderers.uniqueValueRenderer(rendererJson); From abb2ce545fa4bf32b16ca4dd5edab06a81daf742 Mon Sep 17 00:00:00 2001 From: john gravois Date: Thu, 22 Oct 2015 15:14:56 -0700 Subject: [PATCH 18/27] update changelog and add watch/rebuild --- CHANGELOG.md | 19 +++++++++++++++++++ README.md | 3 ++- package.json | 7 +++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5078f27..fdd376d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com). +## [Unreleased] + +### Added + +* Now developers can now override individual style properties of interest directly in the FeatureLayer constructor. (via #100) + +```js +L.esri.featureLayer({ + url: 'http://[server]/arcgis/rest/services/[yourservice]/MapServer/0', + style: function (feature) { + return { + // override service symbology to make polygon fill 50% transparent + fillOpacity: 0.5 + }; + } +}).addTo(map); +``` + ## [2.0.0] - 2015-09-10 This is the first release that supports [Leaflet 1.0.0-beta.1](http://leafletjs.com/2015/07/15/leaflet-1.0-beta1-released.html). As with version [1.0.0](https://github.com/Esri/esri-leaflet/releases/tag/v1.0.0) of Esri Leaflet, FeatureLayer constructors now expect `url`s to be provided within an options object (ie: `L.esri.featureLayer(url)` should be replaced with `L.esri.featureLayer( {url: url} )`). @@ -42,6 +60,7 @@ This is expected to be the last (and only) stable release of Esri Leaflet Render * First Beta release * Works with esri-leaflet 1.0.0-rc.4 +[Unreleased]: https://github.com/Esri/esri-leaflet-renderers/compare/v2.0.0...HEAD [2.0.0]: https://github.com/Esri/esri-leaflet-renderers/compare/v1.0.0...v2.0.0 [1.0.0]: https://github.com/Esri/esri-leaflet-renderers/compare/v0.0.1-beta.3...v1.0.0 [0.0.1-beta.3]: https://github.com/Esri/esri-leaflet-renderers/compare/v0.0.1-beta.2...v0.0.1-beta.3 diff --git a/README.md b/README.md index 319ef03..8c52034 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,8 @@ You can also find a side by side comparison of the ArcGIS API for JavaScript [he 1. [Fork and clone Esri Leaflet Renderers](https://help.github.com/articles/fork-a-repo) 2. `cd` into the `esri-leaflet-renderers` folder 3. Install the dependencies with `npm install` -4. Run `npm run build` from the command line. This will compile minified source in a brand new `dist` directory. Afterward, you can run `npm test` to make sure things are 'all good'. +4. Run `npm run serve` from the command line. This will compile minified source in a brand new `dist` directory, launch a tiny webserver and begin watching the raw source for changes. +5. Run `npm test` to make sure you haven't introduced a new 'feature' accidently. 5. Make your changes and create a [pull request](https://help.github.com/articles/creating-a-pull-request) ### Limitations diff --git a/package.json b/package.json index 9de03f3..9fe77cc 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "babelify": "^6.1.3", "chai": "2.3.0", "gh-release": "^2.0.0", + "http-server": "^0.8.5", "isparta": "^3.0.3", "istanbul": "gotwarlost/istanbul.git#source-map", "karma": "^0.12.24", @@ -44,6 +45,7 @@ "karma-phantomjs-launcher": "^0.1.4", "karma-sourcemap-loader": "^0.3.5", "mkdirp": "^0.5.1", + "nodemon": "^1.7.2", "phantomjs": "^1.9.17", "rollup": "^0.10.0", "semistandard": "^6.1.2", @@ -77,9 +79,10 @@ "scripts": { "prepublish": "npm run build", "prebuild": "mkdirp dist", - "build": "./scripts/build.js", + "build": "node ./scripts/build.js", "lint": "semistandard src/**/*.js", - "release": "./scripts/release.sh", + "release": "node ./scripts/release.sh", + "serve": "nodemon --watch src --exec 'npm run build' & http-server -p 5678 -c-1 -o", "test": "npm run lint && npm run build && karma start" } } From ac6c46b9fc9df5af4c9d49e754000966ab0cb2c2 Mon Sep 17 00:00:00 2001 From: john gravois Date: Thu, 22 Oct 2015 15:23:02 -0700 Subject: [PATCH 19/27] added note to limitations --- CHANGELOG.md | 2 +- README.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdd376d..85a6ab0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel ### Added -* Now developers can now override individual style properties of interest directly in the FeatureLayer constructor. (via #100) +* Now developers can now override individual style properties of interest directly in the FeatureLayer constructor. (via Esri/esri-leaflet-renderers#100) ```js L.esri.featureLayer({ diff --git a/README.md b/README.md index 8c52034..ef3689d 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ You can also find a side by side comparison of the ArcGIS API for JavaScript [he ### Limitations +* It is possible to override aspects of polyline and polygon symbology defined by the service in the FeatureLayer constructor. For points, it is not. * [Simple Marker](http://resources.arcgis.com/en/help/arcgis-rest-api/02r3/02r3000000n5000000.htm#GUID-C8D40B32-5F4B-45EB-8048-6D5A8763E13B) symbols do not support rotation (ie: the 'angle' property is ignored). * Polygons only support [solid fill](http://resources.arcgis.com/en/help/arcgis-rest-api/02r3/02r3000000n5000000.htm#GUID-517D9B3F-DF13-4E79-9B58-A0D24C5E4994). This does not include advanced fill types like PictureFill, Backward Diagonal, DiagonalCross, etc. * [Text](http://resources.arcgis.com/en/help/arcgis-rest-api/02r3/02r3000000n5000000.htm#ESRI_SECTION1_94E8CE0A9F614ABC8BEDDBCB0E9DC53A) symbols are not supported. From b361aa17e08fa95cb493bdbfcb8fcfabacb138ea Mon Sep 17 00:00:00 2001 From: john gravois Date: Thu, 22 Oct 2015 15:24:08 -0700 Subject: [PATCH 20/27] better hyperlink --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85a6ab0..983a80c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel ### Added -* Now developers can now override individual style properties of interest directly in the FeatureLayer constructor. (via Esri/esri-leaflet-renderers#100) +* Now developers can now override individual style properties of interest directly in the FeatureLayer constructor. (via [pull #100](https://github.com/Esri/esri-leaflet-renderers/pull/100)) ```js L.esri.featureLayer({ From 0d7bf45584ac22f3a7bdc878232ddd061fa377d1 Mon Sep 17 00:00:00 2001 From: john gravois Date: Thu, 22 Oct 2015 15:37:10 -0700 Subject: [PATCH 21/27] arg --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ef3689d..0ac4e1e 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ You can also find a side by side comparison of the ArcGIS API for JavaScript [he 3. Install the dependencies with `npm install` 4. Run `npm run serve` from the command line. This will compile minified source in a brand new `dist` directory, launch a tiny webserver and begin watching the raw source for changes. 5. Run `npm test` to make sure you haven't introduced a new 'feature' accidently. -5. Make your changes and create a [pull request](https://help.github.com/articles/creating-a-pull-request) +6. Make your changes and create a [pull request](https://help.github.com/articles/creating-a-pull-request) ### Limitations From fc7693bfbfdfc29ad5e38b12006f1c5bc5015817 Mon Sep 17 00:00:00 2001 From: john gravois Date: Tue, 19 Jan 2016 15:41:02 -0800 Subject: [PATCH 22/27] bump semistandard --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9fe77cc..4106a8c 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "nodemon": "^1.7.2", "phantomjs": "^1.9.17", "rollup": "^0.10.0", - "semistandard": "^6.1.2", + "semistandard": "^7.0.5", "sinon": "^1.11.1", "sinon-chai": "2.7.0", "uglify-js": "^2.4.23" From b5fde656ffb72ef8db93db9558ea4091d4a424b1 Mon Sep 17 00:00:00 2001 From: john gravois Date: Tue, 19 Jan 2016 15:49:21 -0800 Subject: [PATCH 23/27] :package: 2.0.1 --- CHANGELOG.md | 3 +++ README.md | 12 ++++++------ index.html | 4 ++-- package.json | 4 ++-- spec/comparisons.html | 4 ++-- src/EsriLeafletRenderers.js | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 983a80c..61ff022 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel ## [Unreleased] +## [2.0.1] - 2016-01-19 + ### Added * Now developers can now override individual style properties of interest directly in the FeatureLayer constructor. (via [pull #100](https://github.com/Esri/esri-leaflet-renderers/pull/100)) @@ -61,6 +63,7 @@ This is expected to be the last (and only) stable release of Esri Leaflet Render * Works with esri-leaflet 1.0.0-rc.4 [Unreleased]: https://github.com/Esri/esri-leaflet-renderers/compare/v2.0.0...HEAD +[2.0.1]: https://github.com/Esri/esri-leaflet-renderers/compare/v2.0.0...v2.0.1 [2.0.0]: https://github.com/Esri/esri-leaflet-renderers/compare/v1.0.0...v2.0.0 [1.0.0]: https://github.com/Esri/esri-leaflet-renderers/compare/v0.0.1-beta.3...v1.0.0 [0.0.1-beta.3]: https://github.com/Esri/esri-leaflet-renderers/compare/v0.0.1-beta.2...v0.0.1-beta.3 diff --git a/README.md b/README.md index 0ac4e1e..8f8c60d 100644 --- a/README.md +++ b/README.md @@ -20,15 +20,15 @@ You can also find a side by side comparison of the ArcGIS API for JavaScript [he - - + + - + - - - -
- - - - - diff --git a/spec/comparisons.html b/spec/comparisons.html index e19c00a..4e6305f 100644 --- a/spec/comparisons.html +++ b/spec/comparisons.html @@ -10,8 +10,9 @@ - - + + + From fb65ccfb60f13c0915d51dbda75885f76c9f83c9 Mon Sep 17 00:00:00 2001 From: john gravois Date: Tue, 19 Jan 2016 15:56:31 -0800 Subject: [PATCH 25/27] blha --- spec/comparisons.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/comparisons.html b/spec/comparisons.html index 4e6305f..c838b49 100644 --- a/spec/comparisons.html +++ b/spec/comparisons.html @@ -11,8 +11,8 @@ - - + + From 166da5b97402aede7a5413baea4ed06019e25719 Mon Sep 17 00:00:00 2001 From: john gravois Date: Wed, 20 Jan 2016 07:54:20 -0800 Subject: [PATCH 26/27] tweak release script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8422276..2c345db 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "prebuild": "mkdirp dist", "build": "node ./scripts/build.js", "lint": "semistandard src/**/*.js", - "release": "node ./scripts/release.sh", + "release": "./scripts/release.sh", "start": "nodemon --watch src --exec 'npm run build' & http-server -p 5678 -c-1 -o", "test": "npm run lint && npm run build && karma start" } From d838ab7ecd5989bc0ed1b8cb017cf44d6fbe764d Mon Sep 17 00:00:00 2001 From: john gravois Date: Wed, 20 Jan 2016 07:54:39 -0800 Subject: [PATCH 27/27] build 2.0.1 --- 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..86fa473 --- /dev/null +++ b/dist/esri-leaflet-renderers.js @@ -0,0 +1,5 @@ +/* esri-leaflet-renderers - v2.0.1 - Wed Jan 20 2016 07:54:38 GMT-0800 (PST) + * Copyright (c) 2016 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(!isNaN(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)}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._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 (!isNaN(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 layer._originalStyle = layer.options.style;\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 var userStyles;\n if (this.options.userDefinedStyle) {\n userStyles = this.options.userDefinedStyle(feature);\n }\n // find the symbol to represent this feature\n var sym = this._getSymbol(feature);\n if (sym) {\n return this.mergeStyles(sym.style(feature, this._visualVariables), userStyles);\n } else {\n // invisible symbology\n return this.mergeStyles({opacity: 0, fillOpacity: 0}, userStyles);\n }\n },\n\n mergeStyles: function (styles, userStyles) {\n var mergedStyles = {};\n var attr;\n // copy renderer style attributes\n for (attr in styles) {\n if (styles.hasOwnProperty(attr)) {\n mergedStyles[attr] = styles[attr];\n }\n }\n // override with user defined style attributes\n if (userStyles) {\n for (attr in userStyles) {\n if (userStyles.hasOwnProperty(attr)) {\n mergedStyles[attr] = userStyles[attr];\n }\n }\n }\n return mergedStyles;\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 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) {\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 if (this.options.style) {\n options.userDefinedStyle = this.options.style;\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.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