In scripts.js, the only way addMarker is being called is if $.getJSON(Flask.url_for("update"), parameters) is "done". Only then will // remove old markers from map removeMarkers();

// add new markers to map for (var i = 0; i < data.length; i++) { addMarker(data[i]); } happen. If it "fail"s, // log error to browser's console console.log(errorThrown.toString()); Will happen.

Someone said this might be related to application.py, so here it is:

def articles():
    """Look up articles for geo."""
    if not request.args.get("geo"):
        raise RuntimeError("Specify location")
    geo = request.args.get("geo")
    articles = lookup(geo)
    return jsonify(articles[1:6])
def search():
    """Search for places that match query."""
    if not request.args.get("q"):
        raise RuntimeError("Specify location")
    q = request.args.get("q") + "%"
    place = db.execute("SELECT * FROM places WHERE postal_code LIKE :q OR place_name LIKE :q OR admin_name1 LIKE :q", q=q)
    return jsonify(place)
    # TODO

And, just in case it has to do with scripts.js,

here is addMarker:

var myLatLng = new google.maps.LatLng(place["latitude"], place["longitude"]);

var mapOptions = {
    zoom: 8,
    center: myLatLng

var map = new google.maps.Map(document.getElementById("map"), mapOptions);

//instantiate marker
var marker = new google.maps.Marker({
    position: myLatLng,
    title: place["place_name"] +", "+ place["admin_name1"],
    label: place["place_name"] +", "+ place["admin_name1"]


google.maps.event.addListener(marker, 'click', function() {
    showInfo(marker, content);   

$.getJSON(Flask.url_for("articles"), {geo: place.postal_code}, function(articles) {

    if (!$.isEmptyObject(articles))
        var content ="<ul>";
        for (var i =0; i < data.length; i++)
            content += "<li><a href=\"" + data[i].link + "\">" + data[i].title + "</a></li>";
        content += "</ul>";
        if (data.length == 0)
            content = "Not available"
  • If update function is not calling addMarker make sure latitude and longitude are NUMERIC type in the database, not TEXT. Commented Apr 14, 2017 at 10:37
  • 3
    Possible duplicate of PSET8: addMarker not getting called Commented Apr 14, 2017 at 10:41
  • Update function is being called, and lat and long are numeric.
    – Ianardo
    Commented Apr 14, 2017 at 11:05

1 Answer 1


At least one problem is here var map = new google.maps.Map(document.getElementById("map"), mapOptions);. There should be one map, it is declared globally at the the beginning of script.js. You should not instantiate a new local map.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .