My problem is with the function addMarker in scripts.js

This is what I have:

    function addMarker(place)
var myLatLng = {lat: place.latitude, lng: place.longitude};
var geo = place.postal_code
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: place.place_name

//Event listener
google.maps.event.addListener(marker, 'click', function(){
var content = $.getJSON("/articles", {geo: place.postal_code})
showInfo(marker, content);

What I'm getting back is a map that the markers show up but when clicked the markers don't have articles the text is just: [object Object]

Doesn't make much sense. I barely understand the javascript, I'm not sure exactly what I'm doing with the $.getJSON other than the fact that I'm somehow doing the opposite of the articles(): function in application.py.

Am I supposed to somehow modify what I'm getting back as content from $.getJSON? If so how?

Is my js syntactically correct?

How can I fix this?

1 Answer 1


I was given some help on facebook. The advice was to Look at how search is implemented in scripts.js.

This was enough to get me part way. First I did the equivalent to what was in search in my addMarker, and then I got [object][object][object][object][object][object][object][object][object][object]....

Which was an improvement and made me realize that perhaps there was something wrong on the other end with my python application.py... so I had a look and a look in helpers.py and this is what I changed:

news = lookup(geo)
ul_news = []
for item in news[:4]:
return jsonify(ul_news)

Essentially I made a new list to jsonify because what I was originally sending was an unmodified list of dictionaries of some sort.

This mostly fixed it... it's still not beautiful. :( What I have is a long rambling line of text of titles and links... not on separate lines or hyperlinked... but acceptable I think.

You must log in to answer this question.

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