From c850c725656d43389975923f00dc56c42a069b83 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Sun, 24 Dec 2017 11:50:03 +0100 Subject: [PATCH] Reuse airport intoWindow object --- assets/client.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/assets/client.js b/assets/client.js index a402abe..b50fbb0 100644 --- a/assets/client.js +++ b/assets/client.js @@ -122,19 +122,16 @@ function plotAirports (airports) { marker.IATA = airport.IATA marker.addListener('click', function () { if (openInfoWindow) openInfoWindow.close() - // eslint-disable-next-line no-undef - const infoWindow = new google.maps.InfoWindow({ - content: ` -

${airport.name}

- - - - -
IATA${airport.IATA || 'n/a'}
ICAO${airport.ICAO || 'n/a'}
Altitude${airport.altitude === null ? 'n/a' : airport.altitude + ' ft'}
- ` - }) - infoWindow.open(map, marker) - openInfoWindow = infoWindow + else openInfoWindow = new google.maps.InfoWindow() // eslint-disable-line no-undef + openInfoWindow.setContent(` +

${airport.name}

+ + + + +
IATA${airport.IATA || 'n/a'}
ICAO${airport.ICAO || 'n/a'}
Altitude${airport.altitude === null ? 'n/a' : airport.altitude + ' ft'}
+ `) + openInfoWindow.open(map, marker) }) airportMarkers.push(marker) })