The geojson file with points has integer values that needs to be converted to string values in the popup window to be readable for users. Tried using function but can't get it to work properly. Any suggestion to correct this code or other way to solve this?
function weekday(feature, layer){
switch (feature.properties.ID){
case 1: return 'Monday';
case 2: return 'Tuesday';
case 3: return 'Wednesday';
case 4: return 'Thursday';
case 5: return 'Friday';
}
}
$.getJSON("../data/abc123/data.geojson", function(json) {
geoLayer = L.geoJson(json, {
onEachFeature: function(feature, layer) {
var popupText =
"Data: <b>GPS log</b>" +
"<br><b>Startingpoint</b>: " + feature.properties.X +
"<br><b>Endpoint</b>: " + feature.properties.Y +
"<br><b>Weekday</b>: " + (feature.properties.ID, weekday)
layer.bindPopup(popupText, {
closeButton: true,
offset: L.point(0, -20)
});
layer.on('click', function() {
layer.openPopup();
});
},
Part of the geojson file
{ "type":"FeatureCollection", "name":"data", "crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}}, "features":[ {"type":"Feature","properties":{"X":"NORRKOPING","B":60208,"Y":"NORRKOPING","CODE":"60208A","ID":2,"NAME":"OSCAR","LOAD_1":0,"LOAD_2":4},"geometry":{"type":"Point","coordinates":[16.150801,58.608192]}},
When click on the cirlceMarker the popup window should show the weekday in string value instead of weekday in numbers. But with this example I get the complete function weekday code showing up in the popup.