Estoy tratando de poner dos archivos json diferentes sobre un mismo mapa. Uno está dibujado por límites de código postal, el otro es de condado. Por alguna razón, no consigo que el folleto funcione. Si alguien puede ayudarme a señalar dónde está el problema, ¡sería genial!
<script>
//ingest and congiure zip file
zipjson = L.geoJson("zip-file.json", {
style: style,
onEachFeature: function(feature, layer){
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
})
layer.bindPopup('<b>Zip Code: </b>' + feature.properties.ZIPCODE + '<br>' +
"<b> Data Attribute #1: </b> " + feature.properties.attr1 + '<br>' +
"<b> Data Attribute #2: </b> " + feature.properties.attr2 + '<br>' +
)
}
}).addTo(map);
//ingest and configure county level layer
countyjson = L.geoJson("county-file.json", {
style: style,
onEachFeature: function(feature, layer){
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
})
layer.bindPopup('<b>County: </b>' + feature.properties.COUNTY + '<br>' +
"<b> Data Attribute #1: </b> " + feature.properties.attr1 + '<br>' +
"<b> Data Attribute #2: </b> " + feature.properties.attr2 + '<br>' +
)
}
}).addTo(map);
// set map layer
var usmap = L.tileLayer('mapbox.streets', {
maxZoom: 18,
minZoom: 1,
attribution: '<font size = "2"><b> Target Universe: Voters who voted in the last two caucus plus the top 100k modeled voters</b></font><br>'
}).
L.mapbox.accessToken = 'fake-token-name';
//initalize map
var map = L.mapbox.map('map',{
center: [41.9, -91.5],
zoom: 7,
layers: [usmap]
});
//set parameters to color map
var max_num = 2000;
var color = d3.scale.linear()
.domain([0, max_num])
.range(['#F0F0D0', '#930F16']);
function style(feature) {
return {
fillColor: color(feature.properties.targetnum), // fill depending on value
weight: 1,
opacity: 0.5,
color: 'black',
fillOpacity: 0.9
};
}
// configuration to fix map
var baseMaps = {
"US" : usmap,
};
var overlayMap = {
"Counties" : countyjson,
"Zip Codes" : zipjson
};
L.control.layers(baseMaps, overlayMap).addTo(map);
</script>