cms/app-client/app/components/visu-carto.js
author Chloe Laisne <chloe.laisne@gmail.com>
Tue, 04 Oct 2016 23:04:06 +0200
changeset 331 9836845ed1e8
parent 309 6ab16926b675
child 355 83f5247f3c7a
permissions -rw-r--r--
AmMaps geonames constants
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     1
import Ember from 'ember';
123
4c97e9da1416 Remove use of global variables + remove ember-cli-content-security-policy from package.json to avoid bogus csp violation warnings
ymh <ymh.work@gmail.com>
parents: 95
diff changeset
     2
import AmCharts from 'ammaps';
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
     3
import ENV from 'app-client/config/environment';
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     4
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     5
export default Ember.Component.extend({
197
7b266ccf6d3d Setup filter service
Chloe Laisne <chloe.laisne@gmail.com>
parents: 193
diff changeset
     6
331
9836845ed1e8 AmMaps geonames constants
Chloe Laisne <chloe.laisne@gmail.com>
parents: 309
diff changeset
     7
    constants: Ember.inject.service(),
9836845ed1e8 AmMaps geonames constants
Chloe Laisne <chloe.laisne@gmail.com>
parents: 309
diff changeset
     8
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
     9
    map: null,
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    10
274
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    11
    continentsMapVar: AmCharts.maps.continentsLow,
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    12
    continentsAreas: [],
274
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    13
    countriesMapVar: AmCharts.maps.worldLow,
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    14
    countriesAreas: [],
274
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    15
    franceMapVar: AmCharts.maps.france2016Low,
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    16
    franceAreas: [],
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    17
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    18
    locationQueryParam: '',
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    19
    dataProvider: {},
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    20
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
    21
    color: 'rgba(113,132,141,.2)',
274
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    22
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
    23
    filter: Ember.inject.service(),
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
    24
    locationObserver: Ember.observer('filter.location', function() {
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
    25
        if(!this.get('filter').get('location')) {
331
9836845ed1e8 AmMaps geonames constants
Chloe Laisne <chloe.laisne@gmail.com>
parents: 309
diff changeset
    26
            this.sendAction('setLocation', this.get('constants').GEONAMES['world']);
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
    27
        }
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
    28
    }),
200
a441c40f9c5e Fix playlist filtering
Chloe Laisne <chloe.laisne@gmail.com>
parents: 197
diff changeset
    29
274
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    30
    geostats: [],
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    31
    observerGeostats: Ember.observer('geostats', function() {
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    32
        if(this.get('map')) {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    33
            if(this.get('map').selectedObject.id) {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    34
                if(this.get('map').selectedObject.parentObject.mapVar === this.get('countriesMapVar')) {
331
9836845ed1e8 AmMaps geonames constants
Chloe Laisne <chloe.laisne@gmail.com>
parents: 309
diff changeset
    35
                    if(this.get('map').selectedObject.id === this.get('constants').GEONAMES['france']) {
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    36
                        this.setFranceAreas();
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    37
                        this.set('dataProvider', {
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    38
                            'mapVar': this.get('franceMapVar'),
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    39
                            'getAreasFromMap': true,
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    40
                            'areas': this.get('franceAreas')
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    41
                        });
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    42
                        this.get('map')['dataProvider'] = this.get('dataProvider');
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    43
                        this.get('map').validateData();
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    44
                    }
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    45
                } else if(this.get('map').selectedObject.parentObject.mapVar === this.get('continentsMapVar')) {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    46
                    this.setCountriesAreas();
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    47
                    this.set('dataProvider', {
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    48
                        'mapVar': this.get('countriesMapVar'),
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    49
                        'getAreasFromMap': true,
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    50
                        'areas': this.get('countriesAreas'),
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    51
                        'zoomLevel': this.get('map').zoomLevel(),
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    52
                        'zoomLatitude': this.get('map').zoomLatitude(),
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    53
                        'zoomLongitude': this.get('map').zoomLongitude()
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    54
                    });
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    55
                    this.get('map')['dataProvider'] = this.get('dataProvider');
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    56
                    this.get('map').validateData();
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    57
                }
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    58
            } else {
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    59
                this.setContinentsAreas();
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    60
                this.set('dataProvider', {
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    61
                    'mapVar': this.get('continentsMapVar'),
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    62
                    'areas': this.get('continentsAreas')
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    63
                });
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    64
                this.createAmMap();
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    65
            }
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    66
        }
274
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    67
    }),
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    68
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    69
    init: function() {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    70
        this._super(...arguments);
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    71
        if (ENV.environment === 'development') {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    72
            this.set('color', 'rgba(141,113,113,.2)');
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    73
        }
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    74
    },
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    75
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    76
    setFranceAreas: function() {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    77
        var self = this;
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    78
        var france2016LowAreas = [];
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    79
        this.get('franceMapVar')['svg']['g']['path'].forEach(function(area) {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    80
            var object = {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    81
                'id': area.id,
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    82
                'passZoomValuesToTarget': false,
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    83
                'autoZoom': false
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    84
            };
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
    85
            var departments = self.get('geostats').find(geostat => geostat.id === area.id);
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
    86
            if(typeof departments === 'undefined') {
306
3fccf43160a7 Some more changes linked to the change of api organization + some jshint error cleaning
ymh <ymh.work@gmail.com>
parents: 291
diff changeset
    87
                object['mouseEnabled'] = false;
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    88
                object['color'] = self.get('color');
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
    89
            } else {
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
    90
                object['value'] = departments.get('count');
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    91
            }
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    92
            france2016LowAreas.push(object);
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    93
        });
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    94
        this.set('franceAreas', france2016LowAreas);
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    95
    },
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    96
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    97
    setCountriesAreas: function() {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    98
        var self = this;
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
    99
        var worldLowAreas = [];
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   100
        this.get('countriesMapVar')['svg']['g']['path'].forEach(function(area) {
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   101
            var countries = self.get('geostats').find(geostat => geostat.id === area.id);
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   102
            if(typeof countries === 'undefined') {
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   103
                worldLowAreas.push({
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   104
                    'id': area.id,
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   105
                    'mouseEnabled': false,
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   106
                    'color': self.get('color')
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   107
                });
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   108
            } else {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   109
                if(typeof worldLowAreas.find(country => country.id === area.id) === 'undefined') {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   110
                    var object = {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   111
                        'id': area.id,
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   112
                        'selectable': true,
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   113
                        'value': countries.get('count')
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   114
                    };
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   115
                    if(area.id === 'FR') {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   116
                        object['autoZoom'] = true;
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   117
                    }
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   118
                    worldLowAreas.push(object);
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   119
                }
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   120
            }
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   121
        });
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   122
        this.set('countriesAreas', worldLowAreas);
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   123
    },
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   124
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   125
    setContinentsAreas: function() {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   126
        var self = this;
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   127
        var continentsLowAreas = [];
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   128
        this.get('continentsMapVar')['svg']['g']['path'].forEach(function(area) {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   129
            var object = {
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   130
                'id': area.id,
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   131
                'passZoomValuesToTarget': true,
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   132
                'selectable': true,
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   133
                'mouseEnabled': true,
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   134
                'autoZoom': true
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   135
            };
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   136
            var continent = self.get('geostats').find(geostat => geostat.id === area.id);
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   137
            if(typeof continent === 'undefined') {
306
3fccf43160a7 Some more changes linked to the change of api organization + some jshint error cleaning
ymh <ymh.work@gmail.com>
parents: 291
diff changeset
   138
                object['mouseEnabled'] = false;
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   139
                object['color'] = self.get('color');
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   140
            } else {
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   141
                object['value'] = continent.get('count');
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   142
            }
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   143
            continentsLowAreas.push(object);
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   144
        });
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   145
        this.set('continentsAreas', continentsLowAreas);
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   146
    },
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   147
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   148
    didInsertElement: function(){
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   149
        this.$('#mapdiv').height(Ember.$('.corpus-app-container').height());
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   150
        this.createAmMap();
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   151
    },
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   152
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   153
    createAmMap: function() {
306
3fccf43160a7 Some more changes linked to the change of api organization + some jshint error cleaning
ymh <ymh.work@gmail.com>
parents: 291
diff changeset
   154
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 274
diff changeset
   155
        this.setContinentsAreas();
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
   156
        this.set('dataProvider', {
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
   157
            'mapVar': this.get('continentsMapVar'),
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
   158
            'areas': this.get('continentsAreas')
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
   159
        });
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   160
        this.set('map', AmCharts.makeChart('mapdiv', {
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   161
            'type': 'map',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   162
            'fontFamily': 'sans-serif',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   163
            'fontSize': '12px',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   164
            'dragMap': false,
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   165
            'zoomOnDoubleClick': false,
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   166
            'language': 'fr',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   167
            'areasSettings': {
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   168
                'autoZoom': false,
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   169
                'selectable': true,
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   170
                'color': '#becfd4',
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   171
                'colorSolid': '#71848d',
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   172
                'colorOutline': '#253946',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   173
                'selectedColor': '#253946',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   174
                'rollOverOutlineColor': '#253946'
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   175
            },
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   176
            'zoomControl': {
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   177
                'zoomControlEnabled': false,
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   178
            },
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
   179
            'dataProvider': this.get('dataProvider'),
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   180
            listeners: [{
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   181
                'event':'clickMapObject',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   182
                'method': Ember.run.bind(this, 'clickMapObject')
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   183
            }, {
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   184
                'event':'homeButtonClicked',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   185
                'method': Ember.run.bind(this, 'homeButtonClicked')
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   186
            }]
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   187
        }));
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   188
    },
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   189
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   190
    clickMapObject: function(event) {
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   191
        this.set('locationQueryParam', event.mapObject.id);
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   192
        this.sendAction('setLocation', event.mapObject.id);
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   193
        this.get('filter').set('location', event.mapObject.title);
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   194
    },
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   195
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   196
    homeButtonClicked: function(event) {
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   197
        if(event.chart.dataProvider.map !== 'continentsLow') {
290
ca990333f838 Unselect filter when clicking home button + Go back to world map level when removing filter
Chloe Laisne <chloe.laisne@gmail.com>
parents: 281
diff changeset
   198
            this.get('filter').set('location', null);
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   199
        }
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   200
    }
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   201
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   202
});