Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Enhanced interactivity layers -- doubleclick layer in layer list to t…

…urn on wax info windows..
  • Loading branch information...
commit 18ec3179dc599f5a13e17c48ed4abe506db23043 1 parent c056faf
Jeremy Malczyk authored April 13, 2012
48  app/js/lib/cartodb-gmapsv3.js
@@ -432,7 +432,7 @@ var CartoDB = CartoDB || {};
432 432
     if (this.params_.table_name == 'gbif_import') {
433 433
           infowindow_sql = "SELECT  " +
434 434
             "'Point' AS \"Type\", " +
435  
-            "'GBIF' AS \"Source\", " +
  435
+            "'GBIF' AS \"Provider\", " +
436 436
             "scientificname AS  \"Species name\", " +
437 437
             "CollectionID AS \"Collection\", " +
438 438
             "CONCAT('<a target=\"_gbif\" onclick=\"window.open(this.href)\" href=\"http://data.gbif.org/occurrences/',identifier,'\">',identifier, '</a>') as \"Source ID\", " +
@@ -442,7 +442,7 @@ var CartoDB = CartoDB || {};
442 442
         if(this.params_.mol_layer.type == 'ecoregion') {
443 443
             infowindow_sql = "SELECT  " +
444 444
             "'Ecoregion' AS \"Type\", " +
445  
-            "upper(p.provider) AS \"Source\", " +
  445
+            "'<a href=\" http://www.worldwildlife.org/science/wildfinder/\">World Wildlife Fund' AS \"Provider\", " +
446 446
             "p.scientificname AS  \"Species name\", " +
447 447
             "regionname AS \"Region\", " +
448 448
             "e.ecoregion_code AS \"Ecoregion Code\", " +
@@ -451,6 +451,50 @@ var CartoDB = CartoDB || {};
451 451
             "LEFT JOIN ecoregion_species e " +
452 452
             "ON p.ecoregion_list_id = e.id WHERE p.cartodb_id={0}".format(feature);
453 453
         }
  454
+        if(this.params_.mol_layer.type == 'protectedarea') {
  455
+            infowindow_sql = "SELECT  " +
  456
+            "'Local inventory' AS \"Type\", " +
  457
+            "'Scientist provided' AS \"Provider\", " +
  458
+            "scientificname AS  \"Species name\", " +
  459
+            "regionname AS \"Region\", " +
  460
+            "'ca. 1980-2005' as \"Date\", " +
  461
+            "seasonality AS \"Seasonality\" " +
  462
+            "FROM polygons " +
  463
+            "WHERE cartodb_id={0}".format(feature);
  464
+        }
  465
+        if(this.params_.mol_layer.type == 'range' && this.params_.mol_layer.source == 'fishes') {
  466
+            infowindow_sql = "SELECT  " +
  467
+            "'Expert range map' AS \"Type\", " +
  468
+            "'Page & Burr 2011' AS \"Provider\", " +
  469
+            "scientificname AS  \"Species name\", " +
  470
+            "'ca. 1980-2010' as \"Date\", " +
  471
+            "seasonality as \"Seasonality\" " +
  472
+            "FROM polygons " +
  473
+            "WHERE cartodb_id={0}".format(feature);
  474
+        }
  475
+        if(this.params_.mol_layer.type == 'range' && this.params_.mol_layer.source.toLowerCase() == 'jetz') {
  476
+            infowindow_sql = "SELECT  " +
  477
+            "'Expert range map' AS \"Type\", " +
  478
+            "'Jetz et al 2012' AS \"Provider\", " +
  479
+            "scientificname AS  \"Species name\", " +
  480
+            "'ca. 1980-2010' as \"Date\", " +
  481
+            "seasonality as \"Seasonality\" " +
  482
+            "FROM polygons " +
  483
+            "WHERE cartodb_id={0}".format(feature);
  484
+        }
  485
+        if(this.params_.mol_layer.type == 'range' && this.params_.mol_layer.source.toLowerCase() == 'iucn') {
  486
+            infowindow_sql = "SELECT  " +
  487
+            "'Expert range map' AS \"Type\", " +
  488
+            "'IUCN' AS \"Provider\", " +
  489
+            "scientificname AS  \"Species name\", " +
  490
+            "'ca. 1980-2010' as \"Date\", " +
  491
+            "seasonality as \"Seasonality\", " +
  492
+            "establishmentmeans as \"Origin\" " +
  493
+            "FROM polygons " +
  494
+            "WHERE cartodb_id={0}".format(feature);
  495
+        }
  496
+
  497
+
454 498
     }
455 499
 
456 500
     // If the table is private, you can't run any api methods
21  app/js/mol.map.layers.js
@@ -202,6 +202,14 @@ mol.modules.map.layers = function(mol) {
202 202
                             break;
203 203
                         }
204 204
 
  205
+                        //disable interactivity to start
  206
+                        self.map.overlayMapTypes.forEach(
  207
+                                    function(mt) {
  208
+                                        mt.interaction.remove();
  209
+                                        mt.interaction.clickAction = "";
  210
+                                    }
  211
+                        );
  212
+
205 213
                         // Hack so that at the end we can fire opacity event with all layers.
206 214
                         all.push({layer:layer, l:l, opacity:opacity});
207 215
 
@@ -244,6 +252,7 @@ mol.modules.map.layers = function(mol) {
244 252
                         );
245 253
                         l.layer.dblclick(
246 254
                             function(event) {
  255
+
247 256
                                 if($(this).hasClass('selected')) {
248 257
                                     $(this).removeClass('selected');
249 258
                                 } else {
@@ -251,6 +260,18 @@ mol.modules.map.layers = function(mol) {
251 260
                                     $(this).addClass('selected');
252 261
                                 }
253 262
 
  263
+                                self.map.overlayMapTypes.forEach(
  264
+                                    function(mt) {
  265
+                                        if(mt.name == layer.id && $(l.layer).hasClass('selected')) {
  266
+                                            mt.interaction.add();
  267
+                                            mt.interaction.clickAction = "full"
  268
+                                        } else {
  269
+                                            mt.interaction.remove();
  270
+                                            mt.interaction.clickAction = "";
  271
+                                        }
  272
+                                    }
  273
+                                )
  274
+
254 275
                             }
255 276
                         )
256 277
                         // Click handler for info button fires 'layer-info'
10  app/js/mol.map.tiles.js
@@ -49,9 +49,10 @@ mol.modules.map.tiles = function(mol) {
49 49
                                         };
50 50
                                         e = new mol.bus.Event('layer-opacity', params);
51 51
                                         self.bus.fireEvent(e);
52  
-                                        if(maptype.interaction != undefined) {
53  
-                                            maptype.interaction.add();
54  
-                                        }
  52
+                                        //if(maptype.interaction != undefined) {
  53
+                                        //    maptype.interaction.add();
  54
+                                        //    maptype.interaction.clickAction="full"
  55
+                                        //}
55 56
                                         return;
56 57
                                     }
57 58
                                 }
@@ -69,6 +70,7 @@ mol.modules.map.tiles = function(mol) {
69 70
                                         self.bus.fireEvent(e);
70 71
                                         if(maptype.interaction != undefined) {
71 72
                                             maptype.interaction.remove();
  73
+                                            maptype.interaction.clickAction="";
72 74
                                         }
73 75
                                         //self.map.overlayMapTypes.removeAt(index);
74 76
                                     }
@@ -302,7 +304,7 @@ mol.modules.map.tiles = function(mol) {
302 304
     mol.map.tiles.CartoDbTile = Class.extend(
303 305
         {
304 306
             init: function(layer, table, map) {
305  
-                var sql =  "SELECT * FROM {0} where scientificname='{1}' and type='{2}' and provider ='{3}'",
  307
+                var sql =  "SELECT * FROM {0} where scientificname = '{1}' and type = '{2}' and provider = '{3}'",
306 308
                     opacity = layer.opacity && table !== 'points' ? layer.opacity : null,
307 309
                     tile_style = opacity ? "#{0}{polygon-fill:#99cc00;}".format(table, opacity) : null,
308 310
                     hostname = window.location.hostname,
1  app/templates/map-index-template.html
@@ -25,7 +25,6 @@
25 25
 
26 26
     <script type="text/javascript" src="../../../js/lib/cartodb-gmapsv3.js?v=1"></script>
27 27
     <script type="text/javascript" src="../../../js/lib/wax.g.js"></script>
28  
-    <script type="text/javascript" src="../../../js/lib/customcheck.js"></script>
29 28
 
30 29
     {% if prod %}
31 30
     <script type="text/javascript" src="../../../static/js/mol.js?r={{ r }}"></script>

0 notes on commit 18ec317

Please sign in to comment.
Something went wrong with that request. Please try again.