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:
@app.route("/articles")
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])
@app.route("/search")
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"]
});
marker.setMap(map);
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"
}
}
});
update
function is not callingaddMarker
make surelatitude
andlongitude
are NUMERIC type in the database, not TEXT.