xxxxxxxxxx
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='COPAIBA | Sistema de informacion pasa la Amazonia Indigena' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.38.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.38.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
//Configurar menu
<style>
#menu {
background: #fff;
position: absolute;
z-index: 1;
top: 10px;
right: 10px;
border-radius: 3px;
width: 120px;
border: 1px solid rgba(0,0,0,0.4);
font-family: 'Open Sans', sans-serif;
}
#menu a {
font-size: 13px;
color: #404040;
display: block;
margin: 0;
padding: 0;
padding: 10px;
text-decoration: none;
border-bottom: 1px solid rgba(0,0,0,0.25);
text-align: center;
}
#menu a:last-child {
border: none;
}
#menu a:hover {
background-color: #f8f8f8;
color: #404040;
}
#menu a.active {
background-color: #3887be;
color: #ffffff;
}
#menu a.active:hover {
background: #3074a4;
}
</style>
<nav id="menu"></nav>
//agregar capas
<div id='map'></div>
<script>
mapboxgl.accessToken = 'pk.eyJ1IjoiZmFiaW9mejE5OTAiLCJhIjoiY2o0NmY0cmU2MjJhaTM5b2I4Nmgybm1nbCJ9.Y66nlqj71gB-hi-TVR0I2A'
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/fabiofz1990/cj46fjy4k02ri2rp86i11y064',
});
map.on('load', function () {
map.addSource("Resguardos", {
"type": "vector",
'url': 'mapbox://fabiofz1990.dkoiczal',
});
map.addLayer({
'id': 'Resguardos',
'type': 'fill',
"source": "Resguardos",
'source-layer': 'Resguardos_MAGNA-3gqaeh',
'layout' : {},
'paint': {
'fill-color': '#84b3ff',
'fill-opacity': 0.2
}
});
});
map.on('load', function () {
map.addSource("Conflictos", {
"type": "vector",
'url': 'mapbox://fabiofz1990.5cvgu26z',
cluster: true,
clusterMaxZoom: 14, // Max zoom to cluster points on
clusterRadius: 50 // Radius of each cluster when clustering points (defaults to 50)
});
map.addLayer({
id: "Conflictos-clusters",
type: "circle",
source: "Conflictos",
'source-layer': 'DA_COPAIBA-72jv2l',
filter: ["has", "point_count"],
paint: {
"circle-color": {
property: "point_count",
type: "interval",
stops: [
[0, "#51bbd6"],
[5, "#f1f075"],
[8, "#f28cb1"],
]
},
"circle-radius": {
property: "point_count",
type: "interval",
stops: [
[0, 10],
[5, 20],
[8, 40]
]
}
}
});
map.addLayer({
'id': 'Conflictos',
'type': 'circle',
"source": "Conflictos",
'source-layer': 'DA_COPAIBA-72jv2l',
'layout' : {},
'paint': {
'circle-color': '#fbb03b'
}
});
map.addLayer({
id: "Conflictos-count",
type: "symbol",
source: "Conflictos",
'source-layer': 'DA_COPAIBA-72jv2l',
filter: ["has", "point_count"],
layout: {
"text-field": "{point_count_abbreviated}",
"text-font": ["DIN Offc Pro Medium", "Arial Unicode MS Bold"],
"text-size": 6
}
});
});
// programas menu
var toggleableLayerIds = [ 'Resguardos', "Conflictos"];
for (var i = 0; i < toggleableLayerIds.length; i++) {
var id = toggleableLayerIds[i];
var link = document.createElement('a');
link.href = '#';
link.className = 'active';
link.textContent = id;
link.onclick = function (e) {
var clickedLayer = this.textContent;
e.preventDefault();
e.stopPropagation();
var visibility = map.getLayoutProperty(clickedLayer, 'visibility');
if (visibility === 'visible') {
map.setLayoutProperty(clickedLayer, 'visibility', 'none');
this.className = '';
} else {
this.className = 'active';
map.setLayoutProperty(clickedLayer, 'visibility', 'visible');
}
};
var layers = document.getElementById('menu');
layers.appendChild(link);
}
</script>
</body>
</html>
https://api.tiles.mapbox.com/mapbox-gl-js/v0.38.0/mapbox-gl.js