1 gomNs.countryLabels = { |
|
2 AFG: 'Afghanistan', |
|
3 AGO: 'Angola', |
|
4 ALB: 'Albanie', |
|
5 ARG: 'Argentine', |
|
6 ARM: 'Arménie', |
|
7 ATA: 'Antarctique', |
|
8 AUS: 'Australie', |
|
9 AUT: 'Autriche', |
|
10 AZE: 'Azerbaïdjan', |
|
11 BDI: 'Burundi', |
|
12 BEL: 'Belgique', |
|
13 BEN: 'Bénin', |
|
14 BGR: 'Bulgarie', |
|
15 BIH: 'Bosnie-Herzégovine', |
|
16 BOL: 'Bolivie', |
|
17 BRA: 'Brésil', |
|
18 BRN: 'Brunei', |
|
19 CAF: 'République centrafricaine', |
|
20 CAN: 'Canada', |
|
21 CHE: 'Suisse', |
|
22 CHL: 'Chili', |
|
23 CHN: 'Chine', |
|
24 CIV: 'Côte d\'Ivoire', |
|
25 CMR: 'Cameroun', |
|
26 COD: 'République démocratique du Congo', |
|
27 CZE: 'République tchèque', |
|
28 DEU: 'Allemagne', |
|
29 DNK: 'Danemark', |
|
30 DZA: 'Algérie', |
|
31 EGY: 'Égypte', |
|
32 ESP: 'Espagne', |
|
33 EST: 'Estonie', |
|
34 ETH: 'Éthiopie', |
|
35 FIN: 'Finlande', |
|
36 FRA: 'France', |
|
37 GAB: 'Gabon', |
|
38 GBR: 'Royaume-Uni', |
|
39 GGY: 'Guernesey', |
|
40 GHA: 'Ghana', |
|
41 GLP: 'Guadeloupe', |
|
42 GRC: 'Grèce', |
|
43 GUF: 'Guyane', |
|
44 HTI: 'Haïti', |
|
45 HUN: 'Hongrie', |
|
46 IDN: 'Indonésie', |
|
47 IND: 'Inde', |
|
48 IRL: 'Irlande', |
|
49 IRN: 'Iran', |
|
50 ISL: 'Islande', |
|
51 ISR: 'Israël', |
|
52 ITA: 'Italie', |
|
53 JAM: 'Jamaïque', |
|
54 JEY: 'Jersey', |
|
55 JPN: 'Japon', |
|
56 KAZ: 'Kazakhstan', |
|
57 KGZ: 'Kirghizistan', |
|
58 KHM: 'Cambodge', |
|
59 LBN: 'Liban', |
|
60 LTU: 'Lituanie', |
|
61 LVA: 'Lettonie', |
|
62 MAR: 'Maroc', |
|
63 MDA: 'Moldavie', |
|
64 MEX: 'Mexique', |
|
65 MLI: 'Mali', |
|
66 MLT: 'Malte', |
|
67 MMR: 'Birmanie', |
|
68 MNG: 'Mongolie', |
|
69 MOZ: 'Mozambique', |
|
70 MTQ: 'Martinique', |
|
71 NCL: 'Nouvelle-Calédonie', |
|
72 NER: 'Niger', |
|
73 NGA: 'Nigeria', |
|
74 NLD: 'Pays-Bas', |
|
75 NOR: 'Norvège', |
|
76 NPL: 'Népal', |
|
77 NZL: 'Nouvelle-Zélande', |
|
78 PAK: 'Pakistan', |
|
79 PHL: 'Philippines', |
|
80 PNG: 'Papouasie-Nouvelle-Guinée', |
|
81 POL: 'Pologne', |
|
82 PRT: 'Portugal', |
|
83 PSE: 'Palestine', |
|
84 PYF: 'Polynésie française', |
|
85 ROU: 'Roumanie', |
|
86 RUS: 'Russie', |
|
87 SDN: 'Soudan', |
|
88 SEN: 'Sénégal', |
|
89 SGP: 'Singapour', |
|
90 SLV: 'Salvador', |
|
91 SVK: 'Slovaquie', |
|
92 SVN: 'Slovénie', |
|
93 SWE: 'Suède', |
|
94 SYR: 'Syrie', |
|
95 TCD: 'Tchad', |
|
96 THA: 'Thaïlande', |
|
97 TJK: 'Tadjikistan', |
|
98 TTO: 'Trinité-et-Tobago', |
|
99 TUN: 'Tunisie', |
|
100 TUR: 'Turquie', |
|
101 UGA: 'Ouganda', |
|
102 UKR: 'Ukraine', |
|
103 USA: 'États-Unis', |
|
104 UZB: 'Ouzbékistan', |
|
105 VNM: 'Viêt Nam', |
|
106 ZAF: 'Afrique du Sud' |
|
107 } |
|
108 |
|
109 function polygon_to_gmap(polycoords, isocode) { |
|
110 var _opts = { |
|
111 strokeColor: "#000000", |
|
112 strokeWeight: .5, |
|
113 fillColor: "#7070a0", |
|
114 fillOpacity: .8, |
|
115 title: isocode |
|
116 } |
|
117 _opts.paths = polycoords.map(function(path) { |
|
118 return path.map(function(coord) { |
|
119 return new google.maps.LatLng(coord[1], coord[0]); |
|
120 }); |
|
121 }); |
|
122 var _polygon = new google.maps.Polygon(_opts); |
|
123 _polygon.setMap(gomNs.map); |
|
124 if (gomNs.countryLabels[isocode]) { |
|
125 google.maps.event.addListener(_polygon, 'click', function(a,b) { |
|
126 addFilter('country', isocode); |
|
127 }) |
|
128 } |
|
129 return _polygon; |
|
130 } |
|
131 |
|
132 function showCountriesGmap(geoJson) { |
|
133 gomNs.countries = {}; |
|
134 _(geoJson.features).each(function(feature) { |
|
135 var _el = { "label" : gomNs.countryLabels[feature.id] }; |
|
136 if (feature.id == 'ATA') { |
|
137 _el.gPolygons = []; |
|
138 } else { |
|
139 switch(feature.geometry.type) { |
|
140 case('Polygon'): |
|
141 _el.gPolygons = [ polygon_to_gmap(feature.geometry.coordinates, feature.id) ]; |
|
142 break; |
|
143 case('MultiPolygon'): |
|
144 _el.gPolygons = feature.geometry.coordinates.map(function(polygon) { |
|
145 return polygon_to_gmap(polygon, feature.id); |
|
146 }) |
|
147 break; |
|
148 } |
|
149 } |
|
150 gomNs.countries[feature.id] = _el; |
|
151 }); |
|
152 } |
|
153 |
|
154 function showCountriesLeaflet(geoJson) { |
|
155 gomNs.countries = {}; |
|
156 var gJ = new L.GeoJSON(); |
|
157 gJ.on('featureparse', function(_f) { |
|
158 var isocode = _f.id; |
|
159 _f.layer.setStyle({ |
|
160 color: "#000000", |
|
161 weight: .5, |
|
162 fillColor: "#7070a0", |
|
163 fillOpacity: .8 |
|
164 }); |
|
165 if (gomNs.countryLabels[isocode]) { |
|
166 _f.layer.on('click', function() { |
|
167 addFilter('country', isocode); |
|
168 }); |
|
169 } |
|
170 gomNs.countries[_f.id] = _f.layer; |
|
171 }); |
|
172 gJ.addGeoJSON(geoJson); |
|
173 gomNs.map.addLayer(gJ); |
|
174 } |
|