-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
102 lines (95 loc) · 3.35 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
function init() {
// Parses URL parameters:
var e;
var a = /\+/g; // Regex for replacing addition symbol with a space
var r = /([^&=]+)=?([^&]*)/g;
var urlParams = {};
var d = function (s) { return decodeURIComponent(s.replace(a, " ")); };
var q = window.location.search.substring(1);
while ((e = r.exec(q))) {
urlParams[d(e[1])] = d(e[2]);
};
var myOptions = {
background: null,
viewMode: "circular cladogram",
threeD: true,
htuLabels: true,
leafLabels: true,
branchColor: "white",
branchWidth: 0.2,
nodeRadius: 6,
title: "PhyloXML.org: Hominidae",
tools: true,
taxalist: false,
cladeinfo: false,
treeinfo: false,
feedback: false,
shadow: true
};
var myPhylobox = new PhyBox("phylo_div", myOptions);
var treeUrl = urlParams['tree'] ? urlParams['tree'] : "http://www.phylosoft.org/archaeopteryx/examples/data/multiple_supports.xml";
myPhylobox.drawTree("url", treeUrl);
//
function myF( e, data ) {
// do something...
if (data.node.name) {
console.log( "You clicked " + data.node.name + "!" );
if (cartodb1_gmapsv3 !== null) {
cartodb1_gmapsv3.setMap(null);
}
if (cartodb2_gmapsv3 !== null) {
cartodb2_gmapsv3.setMap(null);
}
addLayer(data.node.name.toLowerCase(), 'points');
addLayer(data.node.name, 'range');
} else {
console.log( "You clicked " + data.node.id + "!" );
}
}
// bind custom event handler to the phylobox "pb-nodeclick" event for this instance
PbEvent.addListener( myPhylobox, "pb-nodeclick", myF );
var map = new google.maps.Map(
document.getElementById('map'),
{
center: new google.maps.LatLng(40, -98),
zoom: 3,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false
}
);
var cartodb1_gmapsv3 = null;
var cartodb2_gmapsv3 = null;
var addLayer = function(name, type) {
if (type === 'points') {
cartodb1_gmapsv3 = new CartoDBLayer(
{
map: map,
user_name:"mol",
table_name: 'gbif_import',
query: "SELECT cartodb_id, the_geom, st_transform(the_geom, 3785) AS the_geom_webmercator, identifier FROM {{table_name}} WHERE lower(scientificname)='" + name + "'",
layer_order: "top",
interactivity: "cartodb_id",
opacity: 1,
map_style: false,
auto_bound: false,
debug: false
}
);
} else {
cartodb2_gmapsv3 = new CartoDBLayer(
{
map: map,
user_name:"mol",
table_name: 'polygons',
query: "SELECT * FROM {{table_name}} where scientificname = '" + name + "' and type = 'range' and provider = 'iucn'",
layer_order: "bottom",
interactivity: "cartodb_id",
opacity: 1,
map_style: false,
auto_bound: true,
debug: false
}
);
}
};
}