PageSourceSearch

https://trainfo.ca/wp-content/plugins/relish-freemium/js/vendor/dc.leaflet.js?ver=6.5.12

js trainfo.ca collected 2026-10-03 21:01:38 UTC 28,925 bytes, 1,039 lines download raw bytes

1/*!
2 *  dc.leaflet 0.5.6
3 *  http://dc-js.github.io/dc.leaflet.js/
4 *  Copyright 2014-2015 Boyan Yurukov and the dc.leaflet Developers
5 *  https://github.com/dc-js/dc.leaflet.js/blob/master/AUTHORS
6 *
7 *  Licensed under the Apache License, Version 2.0 (the "License");
8 *  you may not use this file except in compliance with the License.
9 *  You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 *  Unless required by applicable law or agreed to in writing, software
14 *  distributed under the License is distributed on an "AS IS" BASIS,
15 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 *  See the License for the specific language governing permissions and
17 *  limitations under the License.
18 */
19(function() { function _dc_leaflet(dc, d3, L) {
20'use strict';
21
22var dc_leaflet = {
23    version: '0.5.6'
24};
25
26dc_leaflet.leafletBase = function(Base) {
27    var _chart = new Base();
28
29    _chart.margins({left:0, top:0, right:0, bottom:0});
30
31    var _map;
32    var _reuseMap = false;
33
34    var _mapOptions=false;
35    var _defaultCenter=false;
36    var _defaultZoom=false;
37
38    var _popupMod = null;
39    var _filterMod = null;
40
41    var _cachedHandlers = {};
42
43    var _createLeaflet = function(root) {
44        // append sub-div if not there, to allow client to put stuff (reset link etc.)
45        // in main div. might also use relative positioning here, for now assume
46        // appending will put in right position
47        var child_div = root.selectAll('div.dc-leaflet');
48        child_div = child_div.data([0]).enter()
49            .append('div').attr('class', 'dc-leaflet')
50            .style('width', _chart.effectiveWidth() + "%")
51            .style('height', _chart.effectiveHeight() + "px")
52            .merge(child_div);
53        return L.map(child_div.node(),_mapOptions);
54    };
55
56    var _tiles=function(map) {
57        L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
58            attribution: '&copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap</a> contributors'
59        }).addTo(map);
60    };
61
62    _chart.createLeaflet = function(_) {
63        if(!arguments.length) {
64            return _createLeaflet;
65        }
66        _createLeaflet = _;
67        return _chart;
68    };
69
70    _chart._doRender = function() {
71        if(! _chart.map()){
72            _map = _createLeaflet(_chart.root());
73            for(var ev in _cachedHandlers)
74                _map.on(ev, _cachedHandlers[ev]);
75
76            if (_defaultCenter && _defaultZoom) {
77                _map.setView(_chart.toLocArray(_defaultCenter), _defaultZoom);
78            }
79
80            _chart.tiles()(_map);
81            _chart._postRender();
82        }
83        else if (_chart.map() && _reuseMap)
84            _chart._postRender();
85        else
86            console.warn("WARNING: Leaflet map already rendered.");
87
88        return _chart._doRedraw();
89    };
90
91    _chart._doRedraw = function() {
92        return _chart;
93    };
94
95    _chart._postRender = function() {
96        return _chart;
97    };
98
99    _chart.mapOptions = function(_) {
100        if (!arguments.length) {
101            return _mapOptions;
102        }
103        _mapOptions = _;
104        return _chart;
105    };
106
107    _chart.center = function(_) {
108        if (!arguments.length) {
109            return _defaultCenter;
110        }
111        _defaultCenter = _;
112        return _chart;
113    };
114
115    _chart.zoom = function(_) {
116        if (!arguments.length) {
117            return _defaultZoom;
118        }
119        _defaultZoom = _;
120        return _chart;
121    };
122
123    _chart.tiles = function(_) {
124        if (!arguments.length) {
125            return _tiles;
126        }
127        _tiles = _;
128        return _chart;
129    };
130
131    _chart.map = function(_) {
132        if (!arguments.length) {
133            return _map;
134        }
135        _map = _;
136        _reuseMap = true;
137        return _chart;
138    };
139
140    _chart._isMac = navigator.platform.toUpperCase().includes('MAC');
141
142    _chart._modAssignment = {
143        shift: 'shiftKey',
144        alt: 'altKey',
145        ctrlCmd: _chart._isMac ? 'metaKey' : 'ctrlKey'
146    };
147
148    _chart.popupMod = function(_) {
149        if (!arguments.length)
150            return _popupMod;
151        _popupMod = _;
152        return _chart;
153    };
154
155    _chart.filterMod = function(_) {
156        if (!arguments.length)
157            return _filterMod;
158        _filterMod = _;
159        return _chart;
160    };
161
162    _chart.modKeyMatches = function(e, modKey) {
163        if (modKey)
164            return e.originalEvent[_chart._modAssignment[modKey]];
165        else
166            return !e.originalEvent.shiftKey && !e.originalEvent.altKey &&
167                !e.originalEvent.ctrlKey && !e.originalEvent.metaKey;
168    };
169
170    _chart.bindPopupWithMod = function(layer, value) {
171        layer.bindPopup(value);
172        layer.off('click', layer._openPopup);
173        layer.on('click', function(e) {
174            if (_chart.modKeyMatches(e, _chart.popupMod()))
175                layer._openPopup(e);
176        });
177    };
178
179    _chart.toLocArray = function(value) {
180        if (typeof value === "string") {
181            // expects '11.111,1.111'
182            value = value.split(",");
183        }
184        // else expects [11.111,1.111]
185        return value;
186    };
187
188    // combine Leaflet events into d3 & dc events
189    const super_on = _chart.on;
190    _chart.on = function(event, callback) {
191        var leaflet_events = ['zoomend', 'moveend'];
192        if(leaflet_events.indexOf(event) >= 0) {
193            if(_map) {
194                _map.on(event, callback);
195            }
196            else {
197                _cachedHandlers[event] = callback;
198            }
199            return this;
200        }
201        else return super_on.call(this, event, callback);
202    };
203
204    return _chart;
205};
206//Legend code adapted from http://leafletjs.com/examples/choropleth.html
207dc_leaflet.legend = function() {
208    var _parent, _legend = {};
209    var _leafletLegend = null;
210    var _position = 'bottomleft';
211    var _legendTitle = false;
212
213    _legend.parent = function (parent) {
214        if(!arguments.length)
215            return _parent;
216        _parent = parent;
217        return this;
218    };
219
220    function _LegendClass() {
221        return L.Control.extend({
222            options: {position: _position},
223            onAdd: function (map) {
224                if (map.legend)
225                    map.legend.setContent("");
226                else
227                    map.legend = this;
228                this._div = L.DomUtil.create('div', 'info legend');
229                map.on('moveend',this._update,this);
230                this._update();
231                return this._div;
232            },
233            setContent: function (content) {
234                return this.getContainer().innerHTML = content;
235            },
236            _update: function () {
237                if (!_parent.colorDomain)
238                    console.warn('legend not supported for this dc.leaflet chart type, ignoring');
239                else {
240                    var minValue = _parent.colorDomain()[0],
241                        maxValue = _parent.colorDomain()[1],
242                        palette = _parent.colors().range(),
243                        colorLength = _parent.colors().range().length,
244                        delta = (maxValue - minValue)/colorLength,
245                        i;
246
247                    // define grades for legend colours
248                    // based on equation in dc.js colorCalculator (before version based on colorMixin)
249                    var grades = [];
250                    grades[0] = Math.round(minValue);
251                    for (i= 1; i < colorLength; i++) {
252                        grades[i] = Math.round((0.5 + (i - 1)) * delta + minValue);
253                    }
254
255                    var div = L.DomUtil.create('div', 'info legend');
256                    if (_legendTitle)
257                        this._div.innerHTML = "<strong>" + _legendTitle + "</strong><br/>";
258                    else
259                        this._div.innerHTML = ""; //reset so that legend is not plotted multiple times
260                    // loop through our density intervals and generate a label with a colored
261                    // square for each interval
262                    for (i = 0; i < grades.length; i++) {
263                        this._div.innerHTML +=
264                            '<i style="background:' + palette[i] + '"></i> ' +
265                            grades[i] + (grades[i + 1] ? '&ndash;' + grades[i + 1] + '<br>' : '+');
266                    }
267                }
268            }
269        });
270    }
271
272    _legend.LegendClass = function(LegendClass) {
273        if(!arguments.length)
274            return _LegendClass;
275        _LegendClass = LegendClass;
276        return _legend;
277    };
278
279    _legend.legendTitle = function(_) {
280        if(!arguments.length)
281            return _legendTitle;
282        _legendTitle = _;
283        return _legend;
284    };
285
286    _legend.render = function () {
287        // unfortunately the dc.js legend has no concept of redraw, it's always render
288        if(!_leafletLegend) {
289            // fetch the legend class creator, invoke it
290            var Legend = _legend.LegendClass()();
291            // and constuct that class
292            _leafletLegend = new Legend();
293            _leafletLegend.addTo(_parent.map());
294        }
295
296        return _legend.redraw();
297    };
298
299    _legend.redraw = function () {
300        _leafletLegend._update();
301        return _legend;
302    };
303
304    _legend.leafletLegend = function () {
305        return _leafletLegend;
306    };
307
308    _legend.position = function (position) {
309        if(!arguments.length) return _position;
310        _position = position;
311        return _legend;
312    };
313
314    return _legend;
315};
316dc_leaflet.markerChart = function(parent, chartGroup) {
317    var _chart = dc_leaflet.leafletBase(dc.MarginMixin);
318
319    var _renderPopup = true;
320    var _cluster = false; // requires leaflet.markerCluster
321    var _clusterOptions=false;
322    var _rebuildMarkers = false;
323    var _brushOn = true;
324    var _filterByArea = false;
325    var _clickEvent = false;
326    var _featureGroup = false;
327
328    var _filter;
329    var _innerFilter=false;
330    var _zooming=true;
331    var _layerGroup = false;
332    var _markerList = [];
333    var _currentGroups=false;
334
335    var _fitOnRender = true;
336    var _fitOnRedraw = true;
337    var _disableFitOnRedraw = false;
338    var _showMarkerTitle = true;
339
340    var _location = function(d) {
341        return _chart.keyAccessor()(d);
342    };
343
344    var _marker = function(d, map) {
345        var marker = new L.Marker(_chart.toLocArray(_chart.locationAccessor()(d)), {
346            title: _showMarkerTitle ? _chart.title()(d) : '',
347            alt: _showMarkerTitle ? _chart.title()(d) : '',
348            icon: _icon(d, map),
349            clickable: _chart.renderPopup() || (_chart.brushOn() && !_filterByArea),
350            draggable: false
351        });
352        return marker;
353    };
354
355    var _icon = function(d, map) {
356        return new L.Icon.Default();
357    };
358
359    var _popup = function(d, marker) {
360	    debugger;
361        return _chart.title()(d);
362    };
363
364    _chart._postRender = function() {
365        if (_chart.brushOn()) {
366            if (_filterByArea) {
367                _chart.filterHandler(doFilterByArea);
368            }
369
370            _chart.map().on('zoomend moveend', zoomFilter, this );
371            if (!_filterByArea)
372                _chart.map().on('click', zoomFilter, this );
373            _chart.map().on('zoomstart', zoomStart, this);
374        }
375
376        if (_cluster) {
377            _layerGroup = new L.MarkerClusterGroup(_clusterOptions?_clusterOptions:null);
378        }
379        else {
380            _layerGroup = new L.LayerGroup();
381        }
382        _chart.map().addLayer(_layerGroup);
383    };
384
385    _chart._doRedraw = function() {
386	   
387        var groups = _chart._computeOrderedGroups(_chart.data()).filter(function (d) {
388            return _chart.valueAccessor()(d) !== 0;
389        });
390        if (_currentGroups && _currentGroups.toString() === groups.toString()) {
391            return;
392        }
393        _currentGroups=groups;
394
395        if (_rebuildMarkers) {
396            _markerList=[];
397        }
398        _layerGroup.clearLayers();
399
400        var addList=[];
401        _featureGroup = false;
402        groups.forEach(function(v, i) {
403            var key = _chart.keyAccessor()(v);
404            var marker = null;
405            if (!_rebuildMarkers && key in _markerList) {
406                marker = _markerList[key];
407            }
408            else {
409                marker = createmarker(v, key);
410            }
411            if (!_chart.cluster()) {
412                _layerGroup.addLayer(marker);
413            }
414            else {
415                addList.push(marker);
416            }
417        });
418
419        if (_chart.cluster() && addList.length > 0) {
420            _layerGroup.addLayers(addList);
421        }
422
423        if (addList.length > 0) {
424            if (_fitOnRender || (_fitOnRedraw && !_disableFitOnRedraw)) {
425                _featureGroup = new L.featureGroup(addList);
426                _chart.map().fitBounds(_featureGroup.getBounds());
427                
428            }
429        }
430		
431        _disableFitOnRedraw = false;
432        _fitOnRender = false;
433    };
434
435    _chart.locationAccessor = function(_) {
436        if (!arguments.length) {
437            return _location;
438        }
439        _location= _;
440        return _chart;
441    };
442
443    _chart.marker = function(_) {
444        if (!arguments.length) {
445            return _marker;
446        }
447        _marker= _;
448        return _chart;
449    };
450
451    _chart.featureGroup = function(_) {
452        if (!arguments.length) {
453            return _featureGroup;
454        }
455        _featureGroup= _;
456        return _chart;
457    };
458
459    _chart.icon = function(_) {
460        if (!arguments.length) {
461            return _icon;
462        }
463        _icon= _;
464        return _chart;
465    };
466
467    _chart.popup = function(_) {
468        if (!arguments.length) {
469            return _popup;
470        }
471        _popup= _;
472        return _chart;
473    };
474
475    _chart.clickEvent = function(_) {
476        if (!arguments.length) {
477            return _clickEvent;
478        }
479        _clickEvent= _;
480        return _chart;
481    };
482
483    _chart.renderPopup = function(_) {
484        if (!arguments.length) {
485            return _renderPopup;
486        }
487        _renderPopup = _;
488        return _chart;
489    };
490
491
492    _chart.cluster = function(_) {
493        if (!arguments.length) {
494            return _cluster;
495        }
496        _cluster = _;
497        return _chart;
498    };
499
500    _chart.clusterOptions = function(_) {
501        if (!arguments.length) {
502            return _clusterOptions;
503        }
504        _clusterOptions = _;
505        return _chart;
506    };
507
508    _chart.rebuildMarkers = function(_) {
509        if (!arguments.length) {
510            return _rebuildMarkers;
511        }
512        _rebuildMarkers = _;
513        return _chart;
514    };
515
516    _chart.brushOn = function(_) {
517        if (!arguments.length) {
518            return _brushOn;
519        }
520        _brushOn = _;
521        return _chart;
522    };
523
524    _chart.filterByArea = function(_) {
525        if (!arguments.length) {
526            return _filterByArea;
527        }
528        _filterByArea = _;
529        return _chart;
530    };
531
532    _chart.fitOnRender = function(_) {
533        if (!arguments.length) {
534            return _fitOnRender;
535        }
536        _fitOnRender = _;
537        return _chart;
538    };
539
540    _chart.fitOnRedraw = function(_) {
541        if (!arguments.length) {
542            return _fitOnRedraw;
543        }
544        _fitOnRedraw = _;
545        return _chart;
546    };
547
548    _chart.showMarkerTitle = function(_) {
549        if (!arguments.length) {
550            return _showMarkerTitle;
551        }
552        _showMarkerTitle = _;
553        return _chart;
554    };
555
556    _chart.markerGroup = function() {
557        return _layerGroup;
558    };
559
560    var createmarker = function(v, k) {
561        var marker = _marker(v, _chart.map());
562        marker.key = k;
563        if (_chart.renderPopup()) {
564            _chart.bindPopupWithMod(marker, _chart.popup()(v, marker));
565        }
566        if (_chart.brushOn() && !_filterByArea) {
567            marker.on("click", selectFilter);
568        }
569        if (_clickEvent)
570            marker.on("click", _clickEvent)
571
572        _markerList[k]=marker;
573        return marker;
574    };
575
576    var zoomStart = function(e) {
577        _zooming=true;
578    };
579
580    var zoomFilter = function(e) {
581        if (e.type === "moveend" && (_zooming || e.hard)) {
582            return;
583        }
584        _zooming=false;
585
586        if (_filterByArea) {
587            var filter;
588            if (_chart.map().getCenter().equals(_chart.center()) && _chart.map().getZoom() === _chart.zoom()) {
589                filter = null;
590            }
591            else {
592                filter = _chart.map().getBounds();
593            }
594            dc.events.trigger(function () {
595                _chart.filter(null);
596                if (filter) {
597                    _innerFilter=true;
598                    _chart.filter(filter);
599                    _innerFilter=false;
600                }
601                dc.redrawAll(_chart.chartGroup());
602            });
603        } else if (_chart.filter() && (e.type === "click" ||
604                                       (_markerList.indexOf(_chart.filter()) !== -1 &&
605                                        !_chart.map().getBounds().contains(_markerList[_chart.filter()].getLatLng())))) {
606            dc.events.trigger(function () {
607                _chart.filter(null);
608                if (_renderPopup) {
609                    _chart.map().closePopup();
610                }
611                dc.redrawAll(_chart.chartGroup());
612            });
613        }
614    };
615
616    var doFilterByArea = function(dimension, filters) {
617        _chart.dimension().filter(null);
618        if (filters && filters.length>0) {
619            _chart.dimension().filterFunction(function(d) {
620                if (!(d in _markerList)) {
621                    return false;
622                }
623                var locO = _markerList[d].getLatLng();
624                return locO && filters[0].contains(locO);
625            });
626            if (!_innerFilter && _chart.map().getBounds().toString !== filters[0].toString()) {
627                _chart.map().fitBounds(filters[0]);
628            }
629        }
630    };
631
632    var selectFilter = function(e) {
633        if (!e.target) return;
634        if (!_chart.modKeyMatches(e, _chart.filterMod())) return;
635        var filter = e.target.key;
636        dc.events.trigger(function () {
637            _chart.filter(filter);
638            dc.redrawAll(_chart.chartGroup());
639        });
640    };
641
642    return _chart.anchor(parent, chartGroup);
643};
644dc_leaflet.choroplethChart = function(parent, chartGroup) {
645    var _chart = dc_leaflet.leafletBase(dc.ColorMixin(dc.MarginMixin));
646
647    var _geojsonLayer = false;
648    var _dataMap = [];
649
650    var _geojson = false;
651    var _renderPopup = true;
652    var _brushOn = true;
653    var _featureOptions = {
654        'fillColor':'black',
655        'color':'gray',
656        'opacity':0.4,
657        'fillOpacity':0.6,
658        'weight':1
659    };
660
661    var _featureKey = function(feature) {
662        return feature.key;
663    };
664
665    var _featureStyle = function(feature) {
666        var options = _chart.featureOptions();
667        if (options instanceof Function) {
668            options=options(feature);
669        }
670        options = JSON.parse(JSON.stringify(options));
671        var v = _dataMap[_chart.featureKeyAccessor()(feature)];
672        if (v && v.d) {
673            options.fillColor=_chart.getColor(v.d, v.i);
674            if (_chart.filters().indexOf(v.d.key) !== -1) {
675                options.opacity=0.8;
676                options.fillOpacity=1;
677            }
678        }
679        return options;
680    };
681
682    var _popup = function(d, feature) {
683        return _chart.title()(d);
684    };
685
686    _chart._postRender = function() {
687        _geojsonLayer=L.geoJson(_chart.geojson(), {
688            style: _chart.featureStyle(),
689            onEachFeature: processFeatures
690        });
691        _chart.map().addLayer(_geojsonLayer);
692    };
693
694    const super_doRedraw = _chart._doRedraw;
695    _chart._doRedraw = function() {
696        _geojsonLayer.clearLayers();
697        _dataMap=[];
698        _chart._computeOrderedGroups(_chart.data()).forEach(function (d, i) {
699            _dataMap[_chart.keyAccessor()(d)] = {'d':d, 'i':i};
700        });
701        _geojsonLayer.addData(_chart.geojson());
702        return super_doRedraw.call(this);
703    };
704
705    _chart.geojson = function(_) {
706        if (!arguments.length) {
707            return _geojson;
708        }
709        _geojson = _;
710        return _chart;
711    };
712
713    _chart.featureOptions = function(_) {
714        if (!arguments.length) {
715            return _featureOptions;
716        }
717        _featureOptions = _;
718        return _chart;
719    };
720
721    _chart.featureKeyAccessor = function(_) {
722        if (!arguments.length) {
723            return _featureKey;
724        }
725        _featureKey= _;
726        return _chart;
727    };
728
729    _chart.featureStyle = function(_) {
730        if (!arguments.length) {
731            return _featureStyle;
732        }
733        _featureStyle= _;
734        return _chart;
735    };
736
737    _chart.popup = function(_) {
738        if (!arguments.length) {
739            return _popup;
740        }
741        _popup= _;
742        return _chart;
743    };
744
745    _chart.renderPopup = function(_) {
746        if (!arguments.length) {
747            return _renderPopup;
748        }
749        _renderPopup = _;
750        return _chart;
751    };
752
753    _chart.brushOn = function(_) {
754        if (!arguments.length) {
755            return _brushOn;
756        }
757        _brushOn = _;
758        return _chart;
759    };
760
761    var processFeatures = function (feature, layer) {
762        var v = _dataMap[_chart.featureKeyAccessor()(feature)];
763        if (v && v.d) {
764            layer.key=v.d.key;
765            if (_chart.renderPopup())
766                _chart.bindPopupWithMod(layer, _chart.popup()(v.d, feature));
767            if (_chart.brushOn())
768                layer.on("click", selectFilter);
769        }
770    };
771
772    var selectFilter = function(e) {
773        if (!e.target) {
774            return;
775        }
776        if (!_chart.modKeyMatches(e, _chart.filterMod()))
777            return;
778        var filter = e.target.key;
779        dc.events.trigger(function () {
780            _chart.filter(filter);
781            dc.redrawAll(_chart.chartGroup());
782        });
783    };
784
785    return _chart.anchor(parent, chartGroup);
786};
787
788dc_leaflet.bubbleChart = function (parent, chartGroup) {
789    "use strict";
790
791    /* ####################################
792     * Private variables -- default values.
793     * ####################################
794     */
795    var _chart = dc_leaflet.leafletBase(dc.ColorMixin(dc.MarginMixin));
796    _chart.linearColors(['gray']);
797    var _selectedColor = 'blue';
798
799    var _unselectedColor = function(d) {
800        return _chart.getColor(d);
801    };
802    
803
804    var _renderPopup = true;
805    var _layerGroup = false;
806
807    var _location = function (d) {
808        return _chart.keyAccessor()(d);
809    };
810
811    var _popup = function(d, feature) {
812        return _chart.title()(d);
813    };
814
815    var _r = d3.scaleLinear().domain([0, 100]);
816    var _brushOn = true;
817
818    var _marker = function (d, map) {
819        var loc = _chart.locationAccessor()(d);
820       // var locArray = _chart.toLocArray(loc);
821       // modified as I don't know wtf this was supposed to do originally
822	   var locArray = d.key;
823	   
824	   
825	   
826        var latlng = L.latLng(+locArray[0], +locArray[1]);
827        var circle = L.circleMarker(latlng);
828
829        circle.setRadius(_chart.r()(_chart.valueAccessor()(d)));
830        
831        circle.on("mouseover", function (e) {
832            if (_chart.renderPopup) this.openPopup();
833        });
834        circle.on("mouseout", function (e) {
835            if (_chart.renderPopup) this.closePopup();
836        });
837
838        var key = _chart.keyAccessor()(d);
839        var isSelected = (-1 !== _chart.filters().indexOf(key));
840
841        //circle.options.color = isSelected ? _chart.selectedColor() : _chart.unselectedColor()(d);
842        circle.options.color =  _chart.unselectedColor()(d);
843
844        return circle;
845    };
846
847    /* ########################
848     * Private helper functions
849     * ########################
850     */
851
852    /* ################
853     * Public interface
854     * ################
855     */
856
857
858    /**
859     #### .r([bubbleRadiusScale])
860     Get or set bubble radius scale. By default bubble chart uses ```d3.scaleLinear().domain([0, 100])``` as its r scale .
861
862     **/
863    _chart.r = function (_) {
864        if (!arguments.length) return _r;
865        _r = _;
866        return _chart;
867    };
868
869    _chart.brushOn = function (_) {
870        if (!arguments.length) {
871            return _brushOn;
872        }
873        _brushOn = _;
874        return _chart;
875    };
876
877    _chart.locationAccessor = function (_) {
878        if (!arguments.length) {
879            return _location;
880        }
881        _location = _;
882        return _chart;
883    };
884    /**
885     #### .selectedColor([color])
886     Get or set the color of a selected (filter) bubble.
887     */
888    _chart.selectedColor = function (_) {
889        if (!arguments.length) {
890            return _selectedColor;
891        }
892        _selectedColor = _;
893        return _chart;
894    };
895
896    /**
897     #### .unselectedColor([color])
898     Get or set the color of a bubble which is not currently in the filter.
899
900     */
901    _chart.unselectedColor = function (_) {
902        if (!arguments.length) {
903            return _unselectedColor;
904        }
905        _unselectedColor = _;
906        return _chart;
907    };
908
909    _chart.popup = function(_) {
910        if (!arguments.length) {
911            return _popup;
912        }
913        _popup= _;
914        return _chart;
915    };
916
917    _chart.layerGroup = function() {
918        return _layerGroup;
919    };
920
921    _chart.renderPopup = function(_) {
922        if (!arguments.length) {
923            return _renderPopup;
924        }
925        _renderPopup = _;
926        return _chart;
927    };
928
929    var createmarker = function (v, k) {
930        var marker = _chart.marker()(v, _chart.map());
931        marker.key = k;
932        if (_chart.renderPopup()) {
933            _chart.bindPopupWithMod(marker, _chart.popup()(v, marker));
934        }
935        if (_chart.brushOn()) {
936            marker.on("click", selectFilter);
937        }
938        return marker;
939    };
940
941    _chart.marker = function (_) {
942        if (!arguments.length) {
943            return _marker;
944        }
945        _marker = _;
946        return _chart;
947    };
948
949    /* Render and redraw overrides */
950    _chart._postRender = function () {
951        if (_chart.brushOn()) {
952
953            _chart.map().on('click', function (e) {
954                _chart.filter(null);
955                _chart.redrawGroup();
956            });
957        }
958        _chart.map().on('boxzoomend', boxzoomFilter, this);
959        _layerGroup = new L.LayerGroup();
960        _chart.map().addLayer(_layerGroup);
961        
962        
963    };
964
965    _chart._doRedraw = function () {
966	    
967        var groups = _chart._computeOrderedGroups(_chart.data()).filter(function (d) {
968            return _chart.valueAccessor()(d) !== 0;
969        });
970        
971        _layerGroup.clearLayers();
972        groups.forEach(function (v, i) {
973            var key = _chart.keyAccessor()(v);
974            var marker = null;
975
976            marker = createmarker(v, key);
977            _layerGroup.addLayer(marker);
978        });
979    };
980
981    /* Callback functions */
982    function boxzoomFilter(e) {
983        var filters = [];
984
985        _layerGroup.eachLayer(function (layer) {
986            var latLng = layer.getLatLng();
987            if (e.boxZoomBounds.contains(latLng)) {
988                filters.push(layer.key);
989            }
990        });
991
992        dc.events.trigger(function (e) {
993            _chart.replaceFilter([filters]);
994            _chart.redrawGroup();
995        });
996    }
997
998    var selectFilter = function (e) {
999        if (!e.target) {
1000            return;
1001        }
1002        var filter = e.target.key;
1003        L.DomEvent.stopPropagation(e);
1004        var filter = e.target.key;
1005        if (e.originalEvent.ctrlKey || e.originalEvent.metaKey) {
1006            // If ctrl/cmd key modifier was pressed on click, toggle the target
1007            _chart.filter(filter);
1008        }
1009        else {
1010            // If ctrl key wasn't pressed, clear selection and add target
1011            _chart.replaceFilter([[filter]]);
1012        }
1013        _chart.redrawGroup();
1014    };
1015
1016
1017    return _chart.anchor(parent, chartGroup);
1018};
1019dc_leaflet.d3 = d3;
1020dc_leaflet.dc = dc;
1021
1022return dc_leaflet;
1023}
1024    if (typeof define === 'function' && define.amd) {
1025        define(["dc", "d3", "leaflet", "leaflet.markercluster"], _dc_leaflet);
1026    } else if (typeof module == "object" && module.exports) {
1027        var _dc = require('dc');
1028        var _d3 = require('d3');
1029        var L = require('leaflet');
1030        var lmc = require('leaflet.markercluster');
1031        module.exports = _dc_leaflet(_dc, _d3, L);
1032    } else {
1033        const that = typeof self !== undefined ? self : this;
1034        that.dc_leaflet = _dc_leaflet(that.dc, that.d3, that.L);
1035    }
1036}
1037)();
1038
1039//# sourceMappingURL=dc.leaflet.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.