This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathcensomapa.js
77 lines (53 loc) · 2.1 KB
/
censomapa.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
var featureExtents = function(feature) {
var b = feature.data.properties.bounds;
return [{lon:b[0],lat:b[1]},{lon:b[2],lat:b[3]}];
};
var loadProvincias = function(e) {
for (var i = 0; i < e.features.length; i++) {
var feature = e.features[i];
jQuery.data(feature.element, 'originalClass', 'color' + ((i % 5) + 1));
feature.element.setAttribute('class', 'color' + ((i % 5) + 1));
var name = feature.data.properties.provincia;
jQuery.data($("#menu li a:contains('" + name.toUpperCase() + "')")[0], 'feature', feature);
}
};
var loadDepartamentos = function(e) {
for (var i = 0; i < e.features.length; i++) {
var feature = e.features[i];
feature.element.setAttribute('class', 'dpto');
}
};
var po = org.polymaps;
var map = po.map()
.container(document.getElementById("map").appendChild(po.svg("svg")))
.center({lat: -38, lon: -56})
.zoomRange([3, 12])
.zoom(4)
.add(po.interact());
map.add(po.image()
.url(po.url("http://{S}tile.openstreetmap.org/{Z}/{X}/{Y}.png")
.hosts(["a.", "b.", "c.", ""])));
map.add(po.geoJson()
.url("provincias.json")
.tile(false).on('load', loadProvincias));
map.add(po.compass()
.pan("none"));
$(document).ready(function() {
$('#menu li a').mouseover(function(e) {
var f = jQuery.data($(this)[0], 'feature').element;
f.setAttribute('class', 'provinciaFoco');
})
.mouseout(function(e) {
var f = jQuery.data($(this)[0], 'feature').element;
f.setAttribute('class', jQuery.data(f, 'originalClass'));
})
.click(function(e) {
var f = jQuery.data($(this)[0], 'feature');
map.extent(featureExtents(f));
// get json para los departamentos
map.add(po.geoJson()
.url("provincias/" + f.data.properties.provincia.toUpperCase() + ".json")
.tile(false)
.on('load', loadDepartamentos));
});
});