cms/app-client/app/components/visu-carto.js
author Chloe Laisne <chloe.laisne@gmail.com>
Sun, 25 Sep 2016 20:05:56 +0200
changeset 291 478cdcc56a63
parent 290 ca990333f838
child 306 3fccf43160a7
permissions -rw-r--r--
Reset geonames model parameter when coming back to cartography tab
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
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
     7
    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
     8
274
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
     9
    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
    10
    continentsAreas: [],
274
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    11
    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
    12
    countriesAreas: [],
274
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    13
    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
    14
    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
    15
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    16
    locationQueryParam: '',
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    17
    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
    18
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
    19
    color: 'rgba(113,132,141,.2)',
274
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    20
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
    21
    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
    22
    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
    23
        if(!this.get('filter').get('location')) {
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
    24
            this.sendAction('setLocation', 'world');
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
    25
        }
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
    26
    }),
200
a441c40f9c5e Fix playlist filtering
Chloe Laisne <chloe.laisne@gmail.com>
parents: 197
diff changeset
    27
274
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    28
    geostats: [],
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    29
    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
    30
        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
    31
            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
    32
                if(this.get('map').selectedObject.parentObject.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
    33
                    if(this.get('map').selectedObject.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
    34
                        this.setFranceAreas();
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    35
                        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
    36
                            '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
    37
                            '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
    38
                            '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
    39
                        });
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    40
                        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
    41
                        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
    42
                    }
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
                } 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
    44
                    this.setCountriesAreas();
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    45
                    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
    46
                        '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
    47
                        '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
    48
                        '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
    49
                        '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
    50
                        '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
    51
                        '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
    52
                    });
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    53
                    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
    54
                    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
    55
                }
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
            } else {
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    57
                this.setContinentsAreas();
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    58
                this.set('dataProvider', {
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
    59
                    '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
    60
                    '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
    61
                });
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
    62
                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
    63
            }
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
        }
274
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    65
    }),
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
    66
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
    67
    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
    68
        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
    69
        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
    70
            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
    71
        }
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
    },
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
    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
    75
        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
    76
        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
    77
        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
    78
            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
    79
                '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
    80
                '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
    81
                '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
    82
            };
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
    83
            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
    84
            if(typeof departments === '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
    85
                object['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
    86
                object['color'] = self.get('color');
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
    87
            } else {
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
    88
                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
    89
            }
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
    90
            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
    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
        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
    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
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
    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
    96
        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
    97
        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
    98
        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
    99
            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
   100
            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
   101
                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
   102
                    '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
   103
                    '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
   104
                    '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
   105
                });
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
            } 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
   107
                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
   108
                    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
   109
                        'id': area.id,
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   110
                        'selectable': true,
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   111
                        '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
   112
                    };
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
   113
                    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
   114
                        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
   115
                    }
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
                    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
   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
            }
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
        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
   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
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
    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
   124
        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
   125
        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
   126
        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
   127
            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
   128
                '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
   129
                '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
   130
                '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
   131
                '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
   132
                '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
   133
            };
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   134
            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
   135
            if(typeof continent === '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
   136
                object['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
   137
                object['color'] = self.get('color');
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   138
            } else {
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   139
                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
   140
            }
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
   141
            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
   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
        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
   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
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   146
    didInsertElement: function(){
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   147
        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
   148
        this.createAmMap();
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   149
    },
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   150
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   151
    createAmMap: function() {
274
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 273
diff changeset
   152
        var self = this;
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
   153
        
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
   154
        this.setContinentsAreas();
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
   155
        this.set('dataProvider', {
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
   156
            '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
   157
            '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
   158
        });
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   159
        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
   160
            'type': 'map',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   161
            'fontFamily': 'sans-serif',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   162
            'fontSize': '12px',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   163
            'dragMap': false,
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   164
            'zoomOnDoubleClick': false,
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   165
            'language': 'fr',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   166
            'areasSettings': {
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   167
                'autoZoom': false,
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   168
                'selectable': true,
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   169
                'color': '#becfd4',
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   170
                'colorSolid': '#71848d',
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   171
                'colorOutline': '#253946',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   172
                'selectedColor': '#253946',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   173
                'rollOverOutlineColor': '#253946'
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   174
            },
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   175
            'zoomControl': {
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   176
                'zoomControlEnabled': false,
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   177
            },
291
478cdcc56a63 Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents: 290
diff changeset
   178
            '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
   179
            listeners: [{
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   180
                'event':'clickMapObject',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   181
                'method': Ember.run.bind(this, 'clickMapObject')
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   182
            }, {
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   183
                'event':'homeButtonClicked',
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   184
                '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
   185
            }]
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
    },
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   188
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   189
    clickMapObject: function(event) {
281
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   190
        this.set('locationQueryParam', event.mapObject.id);
618aec1734d5 Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents: 278
diff changeset
   191
        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
   192
        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
   193
    },
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   194
273
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   195
    homeButtonClicked: function(event) {
a719b2dcea34 Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents: 204
diff changeset
   196
        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
   197
            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
   198
        }
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
});