-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
221 lines (180 loc) · 7.65 KB
/
index.html
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!DOCTYPE html>
<html>
<meta charset="utf-8" />
<head>
<script type="text/javascript" src="paisesmundo.js"></script>
<script type="text/javascript" src="ciudadesmundo.js"></script>
<script type="text/javascript" src="Departamentos_Colombia.js"></script>
<script src=" https://unpkg.com/leaflet@1.6.0/dist/leaflet.js "></script>
<link rel="stylesheet" href=" https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet.vectorgrid@1.2.0"></script>
<!-- CLUSTER-->
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.3.0/dist/MarkerCluster.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.3.0/dist/MarkerCluster.Default.css" />
<script src="https://unpkg.com/leaflet.markercluster@1.3.0/dist/leaflet.markercluster.js"></script>
<!--MINIMAPA-->
<link rel="stylesheet" href="Leaflet-MiniMap-master/src/Control.MiniMap.css" />
<script src="Leaflet-MiniMap-master/src/Control.MiniMap.js" type="text/javascript"></script>
<!-- CONTROL DE CAPAS NUEVO -->
<link rel="stylesheet" href="Leaflet.StyledLayerControl-master/css/styledLayerControl.css" />
<script src="Leaflet.StyledLayerControl-master/src/styledLayerControl.js"></script>
<style>
#map {
width: 100%;
height: 600px;
box-shadow: 5px 5px 5px #888;
}
</style>
</head>
<body>
<div id='map'> </div>
<script>
var markers = L.markerClusterGroup();
//------------------------------------------------------------------
var osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a>'
+ 'contributors', maxZoom: 18
});
var cartoUrl = L.tileLayer('http://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png', {
attribution:
'Map data © OpenStreetMap'
+ 'contributors', maxZoom: 18
});
var OSMMIN = new L.tileLayer(
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
{
attribution:
'© <a href="http://osm.org/copyright">OpenStreetMap</a>' +
"contributors", maxZoom: 13,
}
);
//-----------------------------------------estilo para xapa paises
//Estilo paises mundo
function getColor(d) {
return d > 100000000 ? '#800026' :
d > 50000000 ? '#BD0026' :
d > 20000000 ? '#E31A1C' :
d > 10000000 ? '#FC4E2A' :
d > 5000000 ? '#FD8D3C' :
d > 2000000 ? '#FEB24C' :
d > 1000000 ? '#FED976' :
'#FFEDA0';
};
function style(feature) {
return {
fillColor: getColor(feature.properties.pop_est),
weight: 2,
opacity: 1,
color: 'white',
dashArray: '3',
fillOpacity: 0.7
}
};
//Funciones
function popup(feature, layer) {
if (feature.properties && feature.properties.name) {
layer.bindPopup(feature.properties.name);
}
};
function popupdepart(feature, layer) {
if (feature.properties && feature.properties.NOM_DEPART) {
layer.bindPopup("Haz hecho click en el departamento "+feature.properties.NOM_DEPART);
}
};
//CAPA CIUDADES
function getColorCiudades(ciud) {
return ciud == "S" ? "#000FFF" : ciud == "N" ? "#FF0000" : "#FFFFFF";
};
function getColor_depar(d) {
return d > 100000000000 ? 'red' :
d > 50000000000 ? 'lime' :
d > 20000000000 ? 'yellow' :
'fuchsia';
};
//Estilo departamento
function estilodepar(feature) {
return {
fillColor: getColor_depar(feature.properties.SHAPE_AREA),
weight: 2,
opacity: 1,
color: 'black',
dashArray: '0',
fillOpacity: 0.9
};
};
var map = L.map("map", {
center: [1.6181058937930153, -75.6095327486994],
layers: osm,
zoom: 5,
scrollWheelZoom: true,
});
var miniMap = new L.Control.MiniMap(OSMMIN, {
toggleDisplay: true,
}).addTo(map);
var CapaCiudades = L.layerGroup();
var CapaDepartamento = L.layerGroup();
var CapaPaises = L.layerGroup();
CapaCiudades.addLayer(markers);
L.geoJson(paisesmundo, {
style: style,
onEachFeature: popup
}).addTo(CapaPaises);
L.geoJSON(ciudadesmundo, {
pointToLayer: function (feature, latlng) {
return markers.addLayer(
L.circleMarker(latlng, {
radius: 8,
fillColor: getColorCiudades(feature.properties.capital),
weight: 1,
opacity: 0,
color: "black",
fillOpacity: 1,
}).bindPopup(
"Pais: " +
feature.properties.pais +
"<br>" +
"Nombre: " +
feature.properties.ciudad +
"<br>" +
"Es capital: " +
feature.properties.capital
)
)
}
}).addTo(CapaCiudades);
L.geoJson(departamentos_colombia, {
style: estilodepar,
onEachFeature: popupdepart
}).addTo(CapaDepartamento);
//Control de Capas
var baseMaps = [
{
groupName: "Mapas base",
layers: {
"<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Openstreetmap_logo.svg/80px-Openstreetmap_logo.svg.png'height=15px, width=15px /> OpenStreetMap": osm,
"<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Openstreetmap_logo.svg/80px-Openstreetmap_logo.svg.png'height=15px, width=15px /> DarkMap": cartoUrl
}
}
];
var overlayMaps = [
{
groupName: "Capas",
expanded: false,
layers: {
"<img src = 'https://cdn-icons-png.flaticon.com/512/6699/6699815.png'height = 15px, width=15px/> Paises": CapaPaises,
"<img src = 'https://cdn-icons-png.flaticon.com/512/1842/1842150.png'height=15px, width=15px/> Departamento": CapaDepartamento,
"<img src = 'https://cdn-icons-png.flaticon.com/512/1721/1721773.png'height = 15px, width=15px/> Ciudades": CapaCiudades
}
}
];
var options = {
container_width: "300px",
container_maxHeight: "350px",
group_maxHeight: "80px",
exclusive: false
};
L.control.scale({ position: "bottomleft", imperial: false }).addTo(map);
L.Control.styledLayerControl(baseMaps, overlayMaps, options).addTo(map);
</script>
</body>
</html>