function addMarker(place) { // TODO: Add a marker on the place at map. markers = place; var myLatLng = new google.maps.LatLng (parseFloat(markers.latitude), parseFloat(markers.longitude)); var articles; // contents for info window. var parameters = { geo: markers.postal_code };
// add label
var marker = new MarkerWithLabel({
position: myLatLng,
draggable: true,
raiseOnDrag: true,
map: map,
labelContent: markers.place_name,
labelAnchor: google.maps.Point(25, 0),
labelClass: "labels", // the CSS class for the label
});
$.getJSON("articles.php", parameters)
.done(function(data, textStatus, jqXHR) {
// call typeahead's callback with search results (i.e., places)
articles = "<ul>";
var len = data.length;
for (var i = 0; i < len; i++) {
articles += "<div><li> <a href=\"" + data[i].link + "\" target=\"_blank\">" + data[i].title + "</li></div>";
}
articles += "</ul>";
if(articles.length === 0){
articles = "Slow News Day!";
}
})
google.maps.event.addListener(marker, 'click', function() {
showInfo(marker, articles);
}); }