map = {
container.innerHTML = '';
const mapContainer = html`<div style="width: 100%; height:800px; max-height: 100vmin; background: #666"></div>`;
container.appendChild(mapContainer);
let m = L.map(mapContainer, {
renderer: L.svg({padding: 0})
}).setView([41.08763212467916, -85.06439208984376], 9);
let osmLayer = L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}@2x.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(m);
var district_style = {
fillOpacity: 0.1,
weight: 1,
color: hslToHex(4, 75, 50),
opacity: 1,
fillOpacity: .5
}
// }
// },
// style: {
// fillOpacity: 0,
// weight: 2,
// color: hslToHex(4, 75, 65),
// opacity: 1,
// },
// smoothFactor: shape_smoothing,
// }).addTo(m);
let precincts_geojson2 = L.geoJson(precincts_indiana, {
onEachFeature: (feature, layer) => {
var poi = polylabel(layer.toGeoJSON().geometry.coordinates, 1.0)
if (poi[0]) {
L.marker([poi[1], poi[0]], {
icon: L.divIcon({
className: 'text-label-small',
html: feature.properties.Precinct
}),
zIndexOffset: 1000,
interactive: false
}).addTo(m);
}
},
style: {
fillOpacity: 0,
weight: 1,
color: hslToHex(228, 100, 0),
opacity: 0.5,
},
smoothFactor: shape_smoothing
}).addTo(m);
var center_precincts = [
"EEL RIVER B", // A
"MILAN", // B
"WASHINGTON E", // C
"310", // D
"185", // E
"469", // F
"490", // G
"461", // H
"203", // I
"151", // J
"692", // K
"665", // L
];
let precincts_geojson = L.geoJson(precincts_indiana, {
// filter: (feature) => {
// return demdel_precincts.indexOf(feature.properties.Precinct) > -1
// },
onEachFeature: (feature, layer) => {
if (center_precincts.indexOf(feature.properties.Precinct) > -1) {
var poi = polylabel(layer.toGeoJSON().geometry.coordinates, 1.0)
if (poi[0]) {
L.marker([poi[1], poi[0]+.001], {
icon: L.divIcon({
className: 'text-label',
html: demdel_precinct_to_letter[feature.properties.Precinct]
}),
zIndexOffset: 1000,
interactive: false
}).addTo(m);
}
}
layer.setStyle({
fillColor: letter_to_color[demdel_precinct_to_letter[feature.properties.Precinct]],
title: feature.properties.Precinct,
tooltip: feature.properties.Precinct
})
},
style: {
fillOpacity: 0.5,
weight: 1.0,
color: "black",
opacity: 0.1,
},
smoothFactor: shape_smoothing,
}).addTo(m);
// let precincts_geojson = L.geoJson(precincts_shapefile , {
// onEachFeature: (feature, layer) => {
// if (center_precincts.indexOf(feature.properties.Precinct) > -1) {
// var poi = polylabel(layer.toGeoJSON().geometry.coordinates, 1.0)
// if (poi[0]) {
// L.marker([poi[1], poi[0]+.001], {
// icon: L.divIcon({
// className: 'text-label',
// html: demdel_precinct_to_letter[feature.properties.Precinct]
// }),
// zIndexOffset: 1000,
// interactive: false
// }).addTo(m);
// }
// }
// layer.setStyle({
// fillColor: letter_to_color[demdel_precinct_to_letter[feature.properties.Precinct]],
// title: feature.properties.Precinct,
// tooltip: feature.properties.Precinct
// })
// },
// style: {
// fillOpacity: 0.5,
// weight: 1.0,
// color: "black",
// opacity: 0.1,
// },
// smoothFactor: shape_smoothing
// }).addTo(m);
// let ac_geojson = L.geoJson(allen_county, {
// interactive: false,
// smoothFactor: shape_smoothing,
// style: {
// fillOpacity: 0,
// weight: 2,
// color: hslToHex(4, 75, 65),
// opacity: 1,
// }
// }).addTo(m);
// L.geoJson(cities_towns, {
// interactive: false,
// smoothFactor: shape_smoothing,
// style: {
// fillOpacity: 0,
// weight: 2,
// color: hslToHex(4, 75, 65),
// opacity: 1
// }
// }).addTo(m);
m.fitBounds(precincts_geojson.getBounds());
return m
}