So i want to make simple html webpage with my analytical data on it. I gather all of my data inside of valid geoJSON. I used this for HTML part:
<!DOCTYPE html>
<html>
<head>
<title>GeoJSON + Flask + MongoDB</title>
<meta charset="utf-8">
<link href="https://unpkg.com/[email protected]/dist/leaflet.css" rel="stylesheet"/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<h1>
Let's display some nice maps here!
</h1>
<div id="map" style="height: 80vh;"></div>
<script>
const map = L.map('map').setView([55.73135, 37.59104], 10);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: 'Open street map',
}).addTo(map);
axios.get('http://127.0.0.1:5000/points')
.then((response) => {
L.geoJSON(response.data, {
style(feature) {
console.log(feature);
if (feature.properties.count < 5) {
return { color: '#3cb043' };
}
if (feature.properties.count < 8) {
return { color: '#fad201' };
}
return { color: '#ff0033' };
},
}).addTo(map);
});
</script>
</body>
</html>
It shows markers on the map but doesn't really color them.
I tried to make it green for points where count less than 5, yellow for less than 8 and red for the other cases.
I feel like problem is about axios.get
but i'm not much of a front-end guy so I don't really know what's wrong.
Also I added console.log(feature)
just to see if the function is ever called and it doesn't seem like it.