static/scripts.js
/**
 * Adds marker for place to map.
 */
Adds marker for place to map.
Adds marker for place to map .
function addMarker(place)
{
    var myLatLng = {lat: place.latitude, lng: place.longitude};
    var picture = 'http://maps.google.com/mapfiles/ms/micons/red-dot.png';
    var marker = new google.maps.Marker({
        position: myLatLng,
        label: place.place_name + ", " + place.admin_name1, 
        map: map,
        title: place.place_name,
        icon: {url: picture, labelOrigin: new google.maps.Point(20, 40)}
    });
    markers.push(marker);
    google.maps.event.addListener(marker, 'click', function()
    {
        var parameters = 
        {
            geo: place.postal_code
        };
        $.getJSON(Flask.url_for("articles"), parameters).done(function(data, textStatus, jqXHR)
        {
            var content = "<ul>";
            for (var i = 0; i < 5; i++)
            {
                content += "<li> <a href='" + data[i].link + "'>" + data[i].title + "</a></li>";
            }
            content += "</ul>";
            showInfo(marker, content)
            asyncResults(data);
        })
        .fail(function(jqXHR, textStatus, errorThrown)
        {
            console.log(errorThrown.toString());
        });
    })
}
function addMarker ( place ) { var myLatLng = { lat : place . latitude , lng : place . longitude } ; var picture = 'http://maps.google.com/mapfiles/ms/micons/red-dot.png' ; var marker = new google . maps . Marker ( { position : myLatLng , label : place . place_name + ", " + place . admin_name1 , map : map , title : place . place_name , icon : { url : picture , labelOrigin : new google . maps . Point ( 20 , 40 ) } } ) ; markers . push ( marker ) ; google . maps . event . addListener ( marker , 'click' , function ( ) { var parameters = { geo : place . postal_code } ; $ . getJSON ( Flask . url_for ( "articles" ) , parameters ) . done ( function ( data , textStatus , jqXHR ) { var content = "<ul>" ; for ( var i = 0 ; i < 5 ; i ++ ) { content += "<li> <a href='" + data [ i ] . link + "'>" + data [ i ] . title + "</a></li>" ; } content += "</ul>" ; showInfo ( marker , content ) asyncResults ( data ) ; } ) . fail ( function ( jqXHR , textStatus , errorThrown ) { console . log ( errorThrown . toString ( ) ) ; } ) ; } ) }
Adds marker for place to map.
Adds marker for place to map .
// store the location's coordinates // store the customized icon // create the new marker to be added and store the place's details inside it // add the marker to the marker list // upon the click of the icon, open up the info window // set the geo to the given location // get articles from the given location and add them to the info window throuogh HTML // create an unordered list // show only 5 articles and get the link to each article // end the unordered list // show the info window with the added content // wraps result of the method call as a Future object, keeping compatability with the business interface // ^^^^^ catch the error thrown if the articles aren't received ^^^^^