From e48882bf4929632739b6ae7454756e542f0eb51c Mon Sep 17 00:00:00 2001 From: Louis Date: Fri, 19 Apr 2024 12:05:40 +0200 Subject: [PATCH] show local flights (departure == arrival) as points --- index.html | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index f48d2aa..c0a65f5 100644 --- a/index.html +++ b/index.html @@ -96,19 +96,31 @@ const toLongitude = parseFloat(toAirport.longitude); const toLatitude = parseFloat(toAirport.latitude); + // if from == to, draw a point + var geometry; + if(fromAirport == toAirport) { + geometry = { + type: 'Point', + coordinates: [fromLongitude, fromLatitude] + }; + } + else { + geometry = { + type: 'LineString', + coordinates: [ + [fromLongitude, fromLatitude], + [toLongitude, toLatitude] + ] + }; + } + return { type: 'Feature', properties: { from, to }, - geometry: { - type: 'LineString', - coordinates: [ - [fromLongitude, fromLatitude], - [toLongitude, toLatitude] - ] - } + geometry: geometry }; }); @@ -129,10 +141,21 @@ 'line-cap': 'round' }, paint: { - 'line-color': '#bd34eb', - 'line-width': 4 + 'line-color': '#ce42f5', + 'line-width': 2 } }); + + map.addLayer({ + id: 'points', + type: 'circle', + source: 'routes', + paint: { + 'circle-radius': 5, + 'circle-color': '#f00' + }, + filter: ['==', '$type', 'Point'] + }); } function updateMap(csvData) {