static/scripts.js
// Add marker for place to map
Add marker for place to map
Add marker for place to map
function addConnectingMarker(place) {
    console.log("adding a connecting marker")
    var connectingmarker = new google.maps.Marker({
        position: {
            lat: parseFloat(place.latitude_val),
            lng: parseFloat(place.longitude_val)
        },
        map: map,
        icon: 'http://maps.google.com/mapfiles/ms/micons/plane.png',
        labelOrigin: new google.maps.Point(16, 64),
        label: {
            text: place.connairportiata
        }
    });
    connectingmarker.addListener('click', function() {
        info.setContent("Loading..."); 
        var e = document.getElementById("directionality");
        var directionalitystring = e.options[e.selectedIndex].text;
        var f = document.getElementById("class");
        var classstring = f.options[f.selectedIndex].text;
        var contentString = '<b>' + place.airport_name + '</b>';
        contentString = contentString + '<br><b>IATA Code:</b> ' + place.connairportiata  + '';
        contentString = contentString + '<br><b>Serves:</b> ' + place.serves + '';
        contentString = contentString + '<br><b>Location:</b> ' + place.location + '';
        contentString = contentString + '<br>';
        contentString = contentString + '<br><b>Connecting Airlines: <a class="nav-link" href="/calcmiles?airportid1=' + place.originairportid + '&airportid2=' + place.connairportid + '&airlineid=' + 0 + '&directionality=' + directionalitystring + '&travelclass=' + classstring + '&traveldate=' + document.getElementById("traveldate").value + '" target="_blank">(Load All)</a></b>';
        let parameters = {
            airport1: place.originairportid,
            airport2: place.connairportid,
            star: document.getElementById("star").checked,
            ow: document.getElementById("ow").checked,
            sky: document.getElementById("sky").checked
        };
        $.getJSON("/connectingairlines", parameters, function(data, textStatus, jqXHR) {
            console.log('Before' + contentString);
            for (let i = 0; i < data.length; i++) {
                contentString = contentString + '<br><a class="nav-link" href="/calcmiles?airportid1=' + place.originairportid + '&airportid2=' + place.connairportid + '&airlineid=' + data[i].airlineid + '&directionality=' + directionalitystring + '&travelclass=' + classstring + '&traveldate=' + document.getElementById("traveldate").value + '" target="_blank">' + data[i].airline_brand + ' (' + data[i].iata_designator + ')</a>';
            }
            contentString = contentString + '<br><br>';
            contentString = contentString + '<i>Click on airlines above to see mileage requirements</i>';
            console.log("After" + contentString);
            info.setContent(contentString);
        });
        info.open(map, connectingmarker);
        showroutes(place);
    });
    connectingmarkers.push(connectingmarker);
    connectingmarker.setMap(map);
}
function addConnectingMarker ( place ) { console . log ( "adding a connecting marker" ) var connectingmarker = new google . maps . Marker ( { position : { lat : parseFloat ( place . latitude_val ) , lng : parseFloat ( place . longitude_val ) } , map : map , icon : 'http://maps.google.com/mapfiles/ms/micons/plane.png' , labelOrigin : new google . maps . Point ( 16 , 64 ) , label : { text : place . connairportiata } } ) ; connectingmarker . addListener ( 'click' , function ( ) { info . setContent ( "Loading..." ) ; var e = document . getElementById ( "directionality" ) ; var directionalitystring = e . options [ e . selectedIndex ] . text ; var f = document . getElementById ( "class" ) ; var classstring = f . options [ f . selectedIndex ] . text ; var contentString = '<b>' + place . airport_name + '</b>' ; contentString = contentString + '<br><b>IATA Code:</b> ' + place . connairportiata + '' ; contentString = contentString + '<br><b>Serves:</b> ' + place . serves + '' ; contentString = contentString + '<br><b>Location:</b> ' + place . location + '' ; contentString = contentString + '<br>' ; contentString = contentString + '<br><b>Connecting Airlines: <a class="nav-link" href="/calcmiles?airportid1=' + place . originairportid + '&airportid2=' + place . connairportid + '&airlineid=' + 0 + '&directionality=' + directionalitystring + '&travelclass=' + classstring + '&traveldate=' + document . getElementById ( "traveldate" ) . value + '" target="_blank">(Load All)</a></b>' ; let parameters = { airport1 : place . originairportid , airport2 : place . connairportid , star : document . getElementById ( "star" ) . checked , ow : document . getElementById ( "ow" ) . checked , sky : document . getElementById ( "sky" ) . checked } ; $ . getJSON ( "/connectingairlines" , parameters , function ( data , textStatus , jqXHR ) { console . log ( 'Before' + contentString ) ; for ( let i = 0 ; i < data . length ; i ++ ) { contentString = contentString + '<br><a class="nav-link" href="/calcmiles?airportid1=' + place . originairportid + '&airportid2=' + place . connairportid + '&airlineid=' + data [ i ] . airlineid + '&directionality=' + directionalitystring + '&travelclass=' + classstring + '&traveldate=' + document . getElementById ( "traveldate" ) . value + '" target="_blank">' + data [ i ] . airline_brand + ' (' + data [ i ] . iata_designator + ')</a>' ; } contentString = contentString + '<br><br>' ; contentString = contentString + '<i>Click on airlines above to see mileage requirements</i>' ; console . log ( "After" + contentString ) ; info . setContent ( contentString ) ; } ) ; info . open ( map , connectingmarker ) ; showroutes ( place ) ; } ) ; connectingmarkers . push ( connectingmarker ) ; connectingmarker . setMap ( map ) ; }
Add marker for place to map
Add marker for place to map
//Declare and add a new marker //Listener that wait for the marker to be clicked //Temp message until the rest loads //For a connecting marker, we want to add details about the airlines that connect it to the origin marker //There is also the option to calculate the # of frequent flyer miles required to fly between the airports: either for a specific airline, or for ALL the airlines together // Add connecting markers to map