author | ymh <ymh.work@gmail.com> |
Fri, 09 Dec 2016 11:41:15 +0100 | |
changeset 467 | 762fc0eb4946 |
parent 424 | feb0d3e0fef9 |
child 475 | dbb941b9fb66 |
permissions | -rw-r--r-- |
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'; |
392
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
391
diff
changeset
|
4 |
import * as commonConstants from 'corpus-common-addon/utils/constants'; |
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
391
diff
changeset
|
5 |
import * as commonUtils from 'corpus-common-addon/utils/utils'; |
34
78a7be2ea5db
create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
6 |
|
78a7be2ea5db
create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
7 |
export default Ember.Component.extend({ |
197 | 8 |
|
331
9836845ed1e8
AmMaps geonames constants
Chloe Laisne <chloe.laisne@gmail.com>
parents:
309
diff
changeset
|
9 |
constants: Ember.inject.service(), |
424
feb0d3e0fef9
add dynamic date range calculation for dates, and add color gradient component, add color gradient for language and chrono
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
10 |
colors: Ember.inject.service(), |
331
9836845ed1e8
AmMaps geonames constants
Chloe Laisne <chloe.laisne@gmail.com>
parents:
309
diff
changeset
|
11 |
|
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 |
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
|
13 |
|
274
53a6985443f8
geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents:
273
diff
changeset
|
14 |
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
|
15 |
continentsAreas: [], |
274
53a6985443f8
geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents:
273
diff
changeset
|
16 |
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
|
17 |
countriesAreas: [], |
274
53a6985443f8
geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents:
273
diff
changeset
|
18 |
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
|
19 |
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
|
20 |
|
291
478cdcc56a63
Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents:
290
diff
changeset
|
21 |
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
|
22 |
|
281
618aec1734d5
Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents:
278
diff
changeset
|
23 |
color: 'rgba(113,132,141,.2)', |
274
53a6985443f8
geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents:
273
diff
changeset
|
24 |
|
273
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
25 |
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
|
26 |
locationObserver: Ember.observer('filter.location', function() { |
392
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
391
diff
changeset
|
27 |
if(this.get('filter').get('location') === null) { |
331
9836845ed1e8
AmMaps geonames constants
Chloe Laisne <chloe.laisne@gmail.com>
parents:
309
diff
changeset
|
28 |
this.sendAction('setLocation', this.get('constants').GEONAMES['world']); |
392
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
391
diff
changeset
|
29 |
this.get('map').selectObject(); |
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
391
diff
changeset
|
30 |
} else { |
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
391
diff
changeset
|
31 |
this.sendAction('setLocation', commonUtils.getGeonamesCode(this.get('filter').get('location'))); |
273
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
32 |
} |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
33 |
}), |
200
a441c40f9c5e
Fix playlist filtering
Chloe Laisne <chloe.laisne@gmail.com>
parents:
197
diff
changeset
|
34 |
|
274
53a6985443f8
geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents:
273
diff
changeset
|
35 |
geostats: [], |
53a6985443f8
geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents:
273
diff
changeset
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
this.setFranceAreas(); |
291
478cdcc56a63
Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents:
290
diff
changeset
|
42 |
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
|
43 |
'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
|
44 |
'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
|
45 |
'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
|
46 |
}); |
478cdcc56a63
Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents:
290
diff
changeset
|
47 |
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
|
48 |
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
|
49 |
} |
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 |
} 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
|
51 |
this.setCountriesAreas(); |
291
478cdcc56a63
Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents:
290
diff
changeset
|
52 |
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
|
53 |
'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
|
54 |
'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
|
55 |
'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
|
56 |
'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
|
57 |
'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
|
58 |
'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
|
59 |
}); |
478cdcc56a63
Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents:
290
diff
changeset
|
60 |
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
|
61 |
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
|
62 |
} |
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 |
} else { |
291
478cdcc56a63
Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents:
290
diff
changeset
|
64 |
this.setContinentsAreas(); |
478cdcc56a63
Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents:
290
diff
changeset
|
65 |
this.set('dataProvider', { |
478cdcc56a63
Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents:
290
diff
changeset
|
66 |
'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
|
67 |
'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
|
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 |
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
|
70 |
} |
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 |
} |
274
53a6985443f8
geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents:
273
diff
changeset
|
72 |
}), |
53a6985443f8
geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents:
273
diff
changeset
|
73 |
|
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
|
74 |
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
|
75 |
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
|
76 |
if (ENV.environment === 'development') { |
355
83f5247f3c7a
Fix carto counts and map colors
Chloe Laisne <chloe.laisne@gmail.com>
parents:
331
diff
changeset
|
77 |
this.set('color', '#f3f3f3'); |
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
|
78 |
} |
392
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
391
diff
changeset
|
79 |
this.get('service'); // gotcha cf: https://github.com/emberjs/ember.js/issues/10821 |
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
|
80 |
}, |
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 |
|
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 |
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
|
83 |
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
|
84 |
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
|
85 |
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
|
86 |
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
|
87 |
'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
|
88 |
'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
|
89 |
'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
|
90 |
}; |
281
618aec1734d5
Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents:
278
diff
changeset
|
91 |
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
|
92 |
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
|
93 |
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
|
94 |
object['color'] = self.get('color'); |
281
618aec1734d5
Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents:
278
diff
changeset
|
95 |
} else { |
618aec1734d5
Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents:
278
diff
changeset
|
96 |
object['value'] = departments.get('count'); |
391 | 97 |
object['title'] = area.title + " (" + 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
|
98 |
} |
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 |
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
|
100 |
}); |
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 |
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
|
102 |
}, |
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 |
|
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 |
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
|
105 |
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
|
106 |
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
|
107 |
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
|
108 |
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
|
109 |
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
|
110 |
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
|
111 |
'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
|
112 |
'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
|
113 |
'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
|
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 |
} 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
|
116 |
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
|
117 |
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
|
118 |
'id': area.id, |
281
618aec1734d5
Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents:
278
diff
changeset
|
119 |
'selectable': true, |
391 | 120 |
'value': countries.get('count'), |
121 |
'title': area.title + " (" + 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
|
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 |
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
|
124 |
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
|
125 |
} |
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 |
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
|
127 |
} |
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 |
} |
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 |
}); |
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 |
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
|
131 |
}, |
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 |
|
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 |
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
|
134 |
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
|
135 |
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
|
136 |
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
|
137 |
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
|
138 |
'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
|
139 |
'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
|
140 |
'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
|
141 |
'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
|
142 |
'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
|
143 |
}; |
281
618aec1734d5
Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents:
278
diff
changeset
|
144 |
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
|
145 |
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
|
146 |
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
|
147 |
object['color'] = self.get('color'); |
281
618aec1734d5
Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents:
278
diff
changeset
|
148 |
} else { |
618aec1734d5
Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents:
278
diff
changeset
|
149 |
object['value'] = continent.get('count'); |
391 | 150 |
object['title'] = area.title + " (" + 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
|
151 |
} |
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
|
152 |
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
|
153 |
}); |
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.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
|
155 |
}, |
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
|
156 |
|
273
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
157 |
didInsertElement: function(){ |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
158 |
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
|
159 |
this.createAmMap(); |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
160 |
}, |
34
78a7be2ea5db
create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
161 |
|
273
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
162 |
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
|
163 |
|
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
|
164 |
this.setContinentsAreas(); |
291
478cdcc56a63
Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents:
290
diff
changeset
|
165 |
this.set('dataProvider', { |
478cdcc56a63
Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents:
290
diff
changeset
|
166 |
'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
|
167 |
'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
|
168 |
}); |
273
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
169 |
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
|
170 |
'type': 'map', |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
171 |
'fontFamily': 'sans-serif', |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
172 |
'fontSize': '12px', |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
173 |
'dragMap': false, |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
174 |
'zoomOnDoubleClick': false, |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
175 |
'language': 'fr', |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
176 |
'areasSettings': { |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
177 |
'autoZoom': false, |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
178 |
'selectable': true, |
424
feb0d3e0fef9
add dynamic date range calculation for dates, and add color gradient component, add color gradient for language and chrono
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
179 |
'color': this.get('colors').LINEAR_COLOR_START, |
feb0d3e0fef9
add dynamic date range calculation for dates, and add color gradient component, add color gradient for language and chrono
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
180 |
'colorSolid': this.get('colors').LINEAR_COLOR_END, |
273
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
181 |
'colorOutline': '#253946', |
355
83f5247f3c7a
Fix carto counts and map colors
Chloe Laisne <chloe.laisne@gmail.com>
parents:
331
diff
changeset
|
182 |
'selectedColor': '#0085cb', |
83f5247f3c7a
Fix carto counts and map colors
Chloe Laisne <chloe.laisne@gmail.com>
parents:
331
diff
changeset
|
183 |
'rollOverColor': '#0085cb', |
83f5247f3c7a
Fix carto counts and map colors
Chloe Laisne <chloe.laisne@gmail.com>
parents:
331
diff
changeset
|
184 |
'rollOverOutlineColor': '#ffffff' |
273
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 |
'zoomControl': { |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
187 |
'zoomControlEnabled': false, |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
188 |
}, |
291
478cdcc56a63
Reset geonames model parameter when coming back to cartography tab
Chloe Laisne <chloe.laisne@gmail.com>
parents:
290
diff
changeset
|
189 |
'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
|
190 |
listeners: [{ |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
191 |
'event':'clickMapObject', |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
192 |
'method': Ember.run.bind(this, 'clickMapObject') |
281
618aec1734d5
Set step colors with geoname counts
Chloe Laisne <chloe.laisne@gmail.com>
parents:
278
diff
changeset
|
193 |
}, { |
273
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
194 |
'event':'homeButtonClicked', |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
195 |
'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
|
196 |
}] |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
197 |
})); |
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
198 |
}, |
34
78a7be2ea5db
create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
199 |
|
273
a719b2dcea34
Cartography on 3 levels (continents/countries/france) and backToContinents button
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
200 |
clickMapObject: function(event) { |
392
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
391
diff
changeset
|
201 |
this.get('filter').setFilter('location', commonConstants.GEONAMES_BASE_URL + 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
|
202 |
}, |
34
78a7be2ea5db
create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
203 |
|
392
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
391
diff
changeset
|
204 |
homeButtonClicked: function() { |
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
391
diff
changeset
|
205 |
this.get('filter').removeFilter('location', null); |
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
391
diff
changeset
|
206 |
this.sendAction('setLocation', this.get('constants').GEONAMES['world']); |
34
78a7be2ea5db
create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
207 |
} |
78a7be2ea5db
create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
208 |
|
78a7be2ea5db
create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
209 |
}); |