cms/app-client/app/components/visu-carto.js
changeset 481 002a05cd849f
parent 475 dbb941b9fb66
equal deleted inserted replaced
480:814468b0fc69 481:002a05cd849f
     6 
     6 
     7 export default Ember.Component.extend({
     7 export default Ember.Component.extend({
     8 
     8 
     9   constants: Ember.inject.service(),
     9   constants: Ember.inject.service(),
    10   colors: Ember.inject.service(),
    10   colors: Ember.inject.service(),
       
    11   filter: Ember.inject.service(),
    11 
    12 
    12   map: null,
    13   map: null,
    13 
    14 
    14   continentsMapVar: AmCharts.maps.continentsLow,
    15   continentsMapVar: AmCharts.maps.continentsLow,
    15   continentsAreas: [],
    16   continentsAreas: [],
    18   franceMapVar: AmCharts.maps.france2016Low,
    19   franceMapVar: AmCharts.maps.france2016Low,
    19   franceAreas: [],
    20   franceAreas: [],
    20 
    21 
    21   dataProvider: {},
    22   dataProvider: {},
    22 
    23 
       
    24   colorScale: Ember.computed('maxCount', 'minCount', function () {
       
    25     let maxCount = this.get('maxCount');
       
    26     let minCount = this.get('minCount');
       
    27     return this.get('colors').getScaleLinear(minCount, maxCount);
       
    28   }),
       
    29   counts: Ember.computed.mapBy('geostats', 'count'),
       
    30   maxCount: Ember.computed.max('counts'),
       
    31   minCount: Ember.computed.min('counts'),
    23 
    32 
    24   area: null,
    33   area: null,
    25   originalZoomLevel: null,
    34   originalZoomLevel: null,
    26   originalZoomLongitude: null,
    35   originalZoomLongitude: null,
    27   originalZoomLatitude: null,
    36   originalZoomLatitude: null,
    28 
    37 
    29   color: 'rgba(113,132,141,.2)',
    38   color: 'rgba(113,132,141,.2)',
    30 
    39 
    31   filter: Ember.inject.service(),
       
    32   locationObserver: Ember.observer('filter.location', function () {
    40   locationObserver: Ember.observer('filter.location', function () {
    33     if (this.get('filter').get('location') === null) {
    41     if (this.get('filter').get('location') === null) {
    34       this.sendAction('setLocation', this.get('constants').GEONAMES['world']);
    42       this.sendAction('setLocation', this.get('constants').GEONAMES['world']);
    35       this.get('map').selectObject();
    43       this.get('map').selectObject();
    36     } else {
    44     } else {
   237       }]
   245       }]
   238     }));
   246     }));
   239   },
   247   },
   240 
   248 
   241   clickMapObject: function (event) {
   249   clickMapObject: function (event) {
   242     this.get('filter').setFilter('location', commonConstants.GEONAMES_BASE_URL + event.mapObject.id);
   250     const changed = this.get('filter').setFilter('location', commonConstants.GEONAMES_BASE_URL + event.mapObject.id);
       
   251     if(!changed) {
       
   252       //force filter change
       
   253       this.notifyPropertyChange('filter.location');
       
   254     }
   243   },
   255   },
   244 
   256 
   245   homeButtonClicked: function () {
   257   homeButtonClicked: function () {
   246     const map = this.get('map');
   258     const map = this.get('map');
   247     const { area, originalZoomLevel, originalZoomLongitude, originalZoomLatitude } =
   259     const { area, originalZoomLevel, originalZoomLongitude, originalZoomLatitude } =