hdalab/js/geojson_quickconv.js
changeset 112 e7086d345a7c
parent 110 6455b65fa3b7
child 115 46c0f7a935d1
equal deleted inserted replaced
111:ceb381f5b0c7 112:e7086d345a7c
       
     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     "GHA" :"Ghana",
       
    40     "GRC" :"Grèce",
       
    41     "HTI" :"Haïti",
       
    42     "HUN" :"Hongrie",
       
    43     "IDN" :"Indonésie",
       
    44     "IND" :"Inde",
       
    45     "IRL" :"Irlande",
       
    46     "IRN" :"Iran",
       
    47     "ISL" :"Islande",
       
    48     "ISR" :"Israël",
       
    49     "ITA" :"Italie",
       
    50     "JAM" :"Jamaïque",
       
    51     "JPN" :"Japon",
       
    52     "KAZ" :"Kazakhstan",
       
    53     "KGZ" :"Kirghizistan",
       
    54     "KHM" :"Cambodge",
       
    55     "LBN" :"Liban",
       
    56     "LTU" :"Lituanie",
       
    57     "LVA" :"Lettonie",
       
    58     "MAR" :"Maroc",
       
    59     "MDA" :"Moldavie",
       
    60     "MEX" :"Mexique",
       
    61     "MLI" :"Mali",
       
    62     "MMR" :"Birmanie",
       
    63     "MNG" :"Mongolie",
       
    64     "MOZ" :"Mozambique",
       
    65     "NCL" :"Nouvelle-Calédonie",
       
    66     "NER" :"Niger",
       
    67     "NGA" :"Nigeria",
       
    68     "NLD" :"Pays-Bas",
       
    69     "NOR" :"Norvège",
       
    70     "NPL" :"Népal",
       
    71     "NZL" :"Nouvelle-Zélande",
       
    72     "PAK" :"Pakistan",
       
    73     "PHL" :"Philippines",
       
    74     "PNG" :"Papouasie-Nouvelle-Guinée",
       
    75     "POL" :"Pologne",
       
    76     "PRT" :"Portugal",
       
    77     "PSE" :"Palestine",
       
    78     "ROU" :"Roumanie",
       
    79     "RUS" :"Russie",
       
    80     "SDN" :"Soudan",
       
    81     "SEN" :"Sénégal",
       
    82     "SLV" :"Salvador",
       
    83     "SVK" :"Slovaquie",
       
    84     "SVN" :"Slovénie",
       
    85     "SWE" :"Suède",
       
    86     "SYR" :"Syrie",
       
    87     "TCD" :"Tchad",
       
    88     "THA" :"Thaïlande",
       
    89     "TJK" :"Tadjikistan",
       
    90     "TTO" :"Trinité-et-Tobago",
       
    91     "TUN" :"Tunisie",
       
    92     "TUR" :"Turquie",
       
    93     "UGA" :"Ouganda",
       
    94     "UKR" :"Ukraine",
       
    95     "USA" :"États-Unis",
       
    96     "UZB" :"Ouzbékistan",
       
    97     "VNM" :"Viêt Nam",
       
    98     "ZAF" :"Afrique du Sud",
       
    99 }
       
   100 
       
   101 function polygon_to_gmap(polycoords, label) {
       
   102     var _opts =  {
       
   103         strokeColor: "#000000",
       
   104         strokeWeight: .5,
       
   105         fillColor: "#000080",
       
   106         fillOpacity: .8,
       
   107     }
       
   108     _opts.paths = polycoords.map(function(path) {
       
   109         return path.map(function(coord) {
       
   110             return new google.maps.LatLng(coord[1], coord[0]);
       
   111         });
       
   112     });
       
   113     var _polygon = new google.maps.Polygon(_opts);
       
   114     _polygon.setMap(gomNs.map);
       
   115     google.maps.event.addListener(_polygon, 'click', function(a,b) {
       
   116         tagInfo(label);
       
   117     })
       
   118     return _polygon;
       
   119 }
       
   120 
       
   121 function showCountries(geoJson) {
       
   122     gomNs.countries = {};
       
   123     _(geoJson.features).each(function(feature) {
       
   124         var _el = { "label" : gomNs.countryLabels[feature.id] };
       
   125         if (feature.id == 'ATA') {
       
   126             _el.gPolygons = [];
       
   127         } else {
       
   128             switch(feature.geometry.type) {
       
   129                 case('Polygon'):
       
   130                     _el.gPolygons = [ polygon_to_gmap(feature.geometry.coordinates, _el.label) ];
       
   131                 break;
       
   132                 case('MultiPolygon'):
       
   133                     _el.gPolygons = feature.geometry.coordinates.map(function(polygon) {
       
   134                         return polygon_to_gmap(polygon, _el.label);
       
   135                     })
       
   136                 break;
       
   137             }
       
   138         }
       
   139         gomNs.countries[feature.id] = _el;
       
   140     });
       
   141 }