cms/app-client/app/components/visu-carto.js
author nowmad@23.1.168.192.in-addr.arpa
Thu, 21 Jan 2016 21:07:02 +0100
changeset 94 62984937a062
parent 92 3437f5191645
child 95 f7ab931581af
permissions -rw-r--r--
- add params when modal appear so we can come back right on this document modal - load the complete document info when modal is called or when played
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';
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     2
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     3
export default Ember.Component.extend({
45
b9adc23abd01 update visualisation with sample values
nowmad@nowmads-macbook-pro.local
parents: 38
diff changeset
     4
  // storage: Ember.inject.service(),
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     5
  didInsertElement: function(){
51
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents: 45
diff changeset
     6
    var _this = this;
45
b9adc23abd01 update visualisation with sample values
nowmad@nowmads-macbook-pro.local
parents: 38
diff changeset
     7
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
     8
    var franceDataProvider = {
84
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
     9
        mapVar: AmCharts.maps.france2016Low,
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    10
        getAreasFromMap:true,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    11
84
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
    12
        areas: this.initArea(AmCharts.maps.france2016Low)
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    13
    };
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    14
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    15
    var worldDataProvider = {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    16
        map: "worldLow",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    17
        getAreasFromMap: true,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    18
        images: [{
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    19
            id: "backButton",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    20
            label: "Back to continents map",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    21
            rollOverColor: "#CC0000",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    22
            labelRollOverColor: "#CC0000",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    23
            useTargetsZoomValues: true,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    24
            left: 30,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    25
            bottom: 30,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    26
            labelFontSize: 15,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    27
            selectable: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    28
        }],
62
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
    29
        areas: this.initArea(AmCharts.maps.worldLow, franceDataProvider)
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    30
    };
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    31
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    32
45
b9adc23abd01 update visualisation with sample values
nowmad@nowmads-macbook-pro.local
parents: 38
diff changeset
    33
    var continentsDataProvider = {
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    34
        map: "continentsLow",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    35
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    36
        areas: [{
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    37
            id: "africa",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    38
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    39
            color: "#7CACAE",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    40
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    41
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    42
            id: "asia",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    43
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    44
            color: "#E0EEEF",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    45
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    46
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    47
            id: "australia",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    48
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    49
            color: "#E0EEEF",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    50
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    51
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    52
            id: "europe",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    53
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    54
            color: "#2D7073",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    55
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    56
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    57
            id: "north_america",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    58
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    59
            color: "#B0D1D3",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    60
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    61
        }, {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    62
            id: "south_america",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    63
            linkToObject: worldDataProvider,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    64
            color: "#E0EEEF",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    65
            passZoomValuesToTarget: true
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    66
        }]
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    67
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    68
    };
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    69
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    70
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    71
    var map = AmCharts.makeChart("mapdiv", {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    72
        type: "map",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    73
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    74
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    75
        areasSettings: {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    76
            autoZoom: true,
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    77
            rollOverOutlineColor: "#000000",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    78
            selectedOutlineColor: "#CC0000",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    79
            selectedColor: "green",
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    80
            color: "#E0EEEF"
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    81
        },
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    82
84
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
    83
        dataProvider: continentsDataProvider,
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
    84
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
    85
        listeners: [{event:"clickMapObject", method:handleMapObjectClick}]
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    86
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    87
    });
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    88
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    89
    function handleGoHome() {
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    90
        map.dataProvider = continentsDataProvider;
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    91
        map.validateNow();
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    92
    }
45
b9adc23abd01 update visualisation with sample values
nowmad@nowmads-macbook-pro.local
parents: 38
diff changeset
    93
    function handleMapObjectClick (event) {
84
36f84e8f1ad5 add d3js for langue visu
nowmad@nowmads-macbook-pro.local
parents: 62
diff changeset
    94
      console.log("bbox: ", event.mapObject.displayObject.node.getBBox());
92
3437f5191645 fix warnings
nowmad@nowmads-macbook-pro.local
parents: 91
diff changeset
    95
        if (event.mapObject.id === "backButton") {
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    96
            handleGoHome();
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    97
        }
51
70dff07a76ff add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents: 45
diff changeset
    98
        _this.sendAction('action', event.mapObject.title);
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    99
    }
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   100
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   101
    // monitor when home icon was clicked and also go to continents map
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   102
    map.addListener("homeButtonClicked", handleGoHome);
62
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   103
  },
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   104
  initArea: function(area, dataProvider){
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   105
    var _this = this;
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   106
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   107
    var areaList = [];
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   108
    var count = {};
92
3437f5191645 fix warnings
nowmad@nowmads-macbook-pro.local
parents: 91
diff changeset
   109
    area.svg.g.path.map(function(elt){
91
acfeddc7821d rename "sound" to "document"
nowmad@nowmads-macbook-pro.local
parents: 84
diff changeset
   110
      var length = _this.get("documents").filterBy("spatial", elt.title).toArray().length;
92
3437f5191645 fix warnings
nowmad@nowmads-macbook-pro.local
parents: 91
diff changeset
   111
      if (length > 0){
62
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   112
        count[elt.id]= length;
92
3437f5191645 fix warnings
nowmad@nowmads-macbook-pro.local
parents: 91
diff changeset
   113
      }
62
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   114
    });
92
3437f5191645 fix warnings
nowmad@nowmads-macbook-pro.local
parents: 91
diff changeset
   115
    area.svg.g.path.map(function(elt){
62
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   116
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   117
      areaList.push({
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   118
        id: elt.id,
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   119
        linkToObject: (elt.id === "FR" ? dataProvider : ""),
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   120
        color: ((typeof(count[elt.id]) === "undefined") ? "#E0EEEF" : "#2D7073"),
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   121
        autoZoom: (elt.id === "FR" ? true : false),
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   122
        selectable: true,
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   123
        passZoomValuesToTarget: false
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   124
      });
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   125
    });
6fc7d50c6b5d remove unecessary svg icon and update the way we define the area to make it more automatic
nowmad@23.1.168.192.in-addr.arpa
parents: 51
diff changeset
   126
    return areaList;
34
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   127
  }
78a7be2ea5db create dumb template to wrap the map component visu-carto
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
   128
});