Permalink
Browse files

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

…urn on wax info windows..
  • Loading branch information...
1 parent c056faf commit 18ec3179dc599f5a13e17c48ed4abe506db23043 @jmalczyk jmalczyk committed Apr 13, 2012
Showing with 73 additions and 7 deletions.
  1. +46 −2 app/js/lib/cartodb-gmapsv3.js
  2. +21 −0 app/js/mol.map.layers.js
  3. +6 −4 app/js/mol.map.tiles.js
  4. +0 −1 app/templates/map-index-template.html
@@ -432,7 +432,7 @@ var CartoDB = CartoDB || {};
if (this.params_.table_name == 'gbif_import') {
infowindow_sql = "SELECT " +
"'Point' AS \"Type\", " +
- "'GBIF' AS \"Source\", " +
+ "'GBIF' AS \"Provider\", " +
"scientificname AS \"Species name\", " +
"CollectionID AS \"Collection\", " +
"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 || {};
if(this.params_.mol_layer.type == 'ecoregion') {
infowindow_sql = "SELECT " +
"'Ecoregion' AS \"Type\", " +
- "upper(p.provider) AS \"Source\", " +
+ "'<a href=\" http://www.worldwildlife.org/science/wildfinder/\">World Wildlife Fund' AS \"Provider\", " +
"p.scientificname AS \"Species name\", " +
"regionname AS \"Region\", " +
"e.ecoregion_code AS \"Ecoregion Code\", " +
@@ -451,6 +451,50 @@ var CartoDB = CartoDB || {};
"LEFT JOIN ecoregion_species e " +
"ON p.ecoregion_list_id = e.id WHERE p.cartodb_id={0}".format(feature);
}
+ if(this.params_.mol_layer.type == 'protectedarea') {
+ infowindow_sql = "SELECT " +
+ "'Local inventory' AS \"Type\", " +
+ "'Scientist provided' AS \"Provider\", " +
+ "scientificname AS \"Species name\", " +
+ "regionname AS \"Region\", " +
+ "'ca. 1980-2005' as \"Date\", " +
+ "seasonality AS \"Seasonality\" " +
+ "FROM polygons " +
+ "WHERE cartodb_id={0}".format(feature);
+ }
+ if(this.params_.mol_layer.type == 'range' && this.params_.mol_layer.source == 'fishes') {
+ infowindow_sql = "SELECT " +
+ "'Expert range map' AS \"Type\", " +
+ "'Page & Burr 2011' AS \"Provider\", " +
+ "scientificname AS \"Species name\", " +
+ "'ca. 1980-2010' as \"Date\", " +
+ "seasonality as \"Seasonality\" " +
+ "FROM polygons " +
+ "WHERE cartodb_id={0}".format(feature);
+ }
+ if(this.params_.mol_layer.type == 'range' && this.params_.mol_layer.source.toLowerCase() == 'jetz') {
+ infowindow_sql = "SELECT " +
+ "'Expert range map' AS \"Type\", " +
+ "'Jetz et al 2012' AS \"Provider\", " +
+ "scientificname AS \"Species name\", " +
+ "'ca. 1980-2010' as \"Date\", " +
+ "seasonality as \"Seasonality\" " +
+ "FROM polygons " +
+ "WHERE cartodb_id={0}".format(feature);
+ }
+ if(this.params_.mol_layer.type == 'range' && this.params_.mol_layer.source.toLowerCase() == 'iucn') {
+ infowindow_sql = "SELECT " +
+ "'Expert range map' AS \"Type\", " +
+ "'IUCN' AS \"Provider\", " +
+ "scientificname AS \"Species name\", " +
+ "'ca. 1980-2010' as \"Date\", " +
+ "seasonality as \"Seasonality\", " +
+ "establishmentmeans as \"Origin\" " +
+ "FROM polygons " +
+ "WHERE cartodb_id={0}".format(feature);
+ }
+
+
}
// If the table is private, you can't run any api methods
@@ -202,6 +202,14 @@ mol.modules.map.layers = function(mol) {
break;
}
+ //disable interactivity to start
+ self.map.overlayMapTypes.forEach(
+ function(mt) {
+ mt.interaction.remove();
+ mt.interaction.clickAction = "";
+ }
+ );
+
// Hack so that at the end we can fire opacity event with all layers.
all.push({layer:layer, l:l, opacity:opacity});
@@ -244,13 +252,26 @@ mol.modules.map.layers = function(mol) {
);
l.layer.dblclick(
function(event) {
+
if($(this).hasClass('selected')) {
$(this).removeClass('selected');
} else {
$(self.display).find('.selected').removeClass('selected');
$(this).addClass('selected');
}
+ self.map.overlayMapTypes.forEach(
+ function(mt) {
+ if(mt.name == layer.id && $(l.layer).hasClass('selected')) {
+ mt.interaction.add();
+ mt.interaction.clickAction = "full"
+ } else {
+ mt.interaction.remove();
+ mt.interaction.clickAction = "";
+ }
+ }
+ )
+
}
)
// Click handler for info button fires 'layer-info'
@@ -49,9 +49,10 @@ mol.modules.map.tiles = function(mol) {
};
e = new mol.bus.Event('layer-opacity', params);
self.bus.fireEvent(e);
- if(maptype.interaction != undefined) {
- maptype.interaction.add();
- }
+ //if(maptype.interaction != undefined) {
+ // maptype.interaction.add();
+ // maptype.interaction.clickAction="full"
+ //}
return;
}
}
@@ -69,6 +70,7 @@ mol.modules.map.tiles = function(mol) {
self.bus.fireEvent(e);
if(maptype.interaction != undefined) {
maptype.interaction.remove();
+ maptype.interaction.clickAction="";
}
//self.map.overlayMapTypes.removeAt(index);
}
@@ -302,7 +304,7 @@ mol.modules.map.tiles = function(mol) {
mol.map.tiles.CartoDbTile = Class.extend(
{
init: function(layer, table, map) {
- var sql = "SELECT * FROM {0} where scientificname='{1}' and type='{2}' and provider ='{3}'",
+ var sql = "SELECT * FROM {0} where scientificname = '{1}' and type = '{2}' and provider = '{3}'",
opacity = layer.opacity && table !== 'points' ? layer.opacity : null,
tile_style = opacity ? "#{0}{polygon-fill:#99cc00;}".format(table, opacity) : null,
hostname = window.location.hostname,
@@ -25,7 +25,6 @@
<script type="text/javascript" src="../../../js/lib/cartodb-gmapsv3.js?v=1"></script>
<script type="text/javascript" src="../../../js/lib/wax.g.js"></script>
- <script type="text/javascript" src="../../../js/lib/customcheck.js"></script>
{% if prod %}
<script type="text/javascript" src="../../../static/js/mol.js?r={{ r }}"></script>

0 comments on commit 18ec317

Please sign in to comment.