static/scripts.js
// Add marker for place to map
Add marker for place to map
Add marker for place to map
function addMarker(place)
{
    let myLatLng = {lat: place.latitude, lng: place.longitude};
    let marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        title: place.place_name + ', ' + place.admin_name1,
        label: {
            text: place.place_name + ', ' + place.admin_name1,
            color: "black",
            fontWeight: "bold",
            fontSize: "12px",
            align: 'right'
        },
        icon: {
            url: 'http://maps.google.com/mapfiles/ms/micons/red-dot.png',
            labelOrigin: new google.maps.Point(11,40)
        }
    });
    geo = place.postal_code;
    var parameters = {
        geo
    };
    marker.addListener('click', function(){
        $.getJSON("/articles", parameters, function(data) {
            showInfo(marker, data);
        });
    });
    markers.push(marker)
}
function addMarker ( place ) { let myLatLng = { lat : place . latitude , lng : place . longitude } ; let marker = new google . maps . Marker ( { position : myLatLng , map : map , title : place . place_name + ', ' + place . admin_name1 , label : { text : place . place_name + ', ' + place . admin_name1 , color : "black" , fontWeight : "bold" , fontSize : "12px" , align : 'right' } , icon : { url : 'http://maps.google.com/mapfiles/ms/micons/red-dot.png' , labelOrigin : new google . maps . Point ( 11 , 40 ) } } ) ; geo = place . postal_code ; var parameters = { geo } ; marker . addListener ( 'click' , function ( ) { $ . getJSON ( "/articles" , parameters , function ( data ) { showInfo ( marker , data ) ; } ) ; } ) ; markers . push ( marker ) }
Add marker for place to map
Add marker for place to map
// instantiates a marker // Custom image for the marker // Makes a postal code object named parameters with geo as the only key so /articles can fetch that postal code through request.args.get("geo") // adds event listener to the marker that listens for clicks and opens info window // generates a GET request to route articles, which then fetches articles via postal code of place // generates a window complete with articles // remembers the markers in an array by appending to the markers array