4
votes
pset8 infoWindow appearing with wrong marker
Had the same trouble. Fix it with 'var' before 'marker = new...'. Else you overwrite the same variable each time.
4
votes
Accepted
How to add labels to Markers?
There is an example of MarkerWithLabel here that should show you how to do that. It's the labelContent property. Transcript of an example from that link:
var latLng = new google.maps.LatLng(49.47805, ...
2
votes
Accepted
Pset8: How to set label position and font?
You can assign anchor value for label so it does not overlap with the icon, like this
var marker = new MarkerWithLabel({
position: latLng,
map: map,
labelContent: place["place_name"],
...
2
votes
pset8 addMarker click event opens info window on wrong marker
Man... you'll be so pissed off with this...
You should declare a NEW marker variable every time you call addMarker, but you don't do this here:
marker = new google.maps.Marker({......
When you do ...
2
votes
CS50 Mashup: addMarker clarification
You are always setting myLatLang here var myLatlng = new google.maps.LatLng(42.3770, -71.1256); // Cambridge, Massachussets, so all the markers will go "there". The argument place is the result of the ...
2
votes
Accepted
pset8- AddMarkers, not even working to for a simple console.log() test
You told the program to "get" info from "articles" here $.getJSON(Flask.url_for("articles")) but you didn't tell it what to GET. Assuming your articles function returns data as per the examples (eg ...
2
votes
Accepted
CS50 Pset8: Final Questions before Wrap-Up
How does the computer recognize that those few lines inside a JavaScript file is actually html and not JavaScript codes? It doesn't. It's not javascript or html to the function, it's data. When it is (...
2
votes
Accepted
CS50 Pset8: Info Window Not Showing
One problem is this syntax markers += marker;. That does not add an element to an array in js. The array method push adds elements to an array.
Another problem is here marker.addListener(map, "click"...
2
votes
Accepted
Mashup: removeMarkers not removing markers? PLEASE HELP
The removeMarkers will get rid of one marker, the last one added. The problem is in addMarker. addMarker will be called for each "place" and should add one marker to the map and one marker to the ...
1
vote
Mashup: javascript variable doesn't retain value
Some background, skip if you want:
JavaScript can only ever handle one piece of running code at a time. If you did the AJAX request in a synchronous way, waiting for it to complete before you continue,...
1
vote
Accepted
Mashup, how to add label outside the icons?
If you use a custom icon for your marker, you can set its labelOrigin to place it underneath. https://developers.google.com/maps/documentation/javascript/markers (and then look for custom icons)
1
vote
Accepted
Pset8: Please help, all my markers and news disappeared (Other peoples code don't work either)
Looks like you missed out at least one setting for your marker.
Be sure you have in your new Marker
map: map,
So that the markers will go on the map.
I added that one line and your markers ...
1
vote
pset8: javascript: addMarker clarification for showInfo function
This google.maps.event.addListener(marker, 'click', showInfo(marker, articlesContent); is sending the result of the showInfo function.
1
vote
Accepted
problems with markers on addmarkers pset8
I was able to reproduce the reported error
sqlalchemy.exc.ArgumentError: This text() construct doesn't define a bound parameter named 'ne_lng'
by modifying the (first) SELECT sql in the update ...
1
vote
Accepted
Pset8: add marker, article links not clickable
Review the MDN doc on anchor tag and then verify that your add marker uses valid attributes. (Hint typo!). Perhaps clicking on the red do in the top right of the inspector will give more info. IMO ...
1
vote
Where to start in addMarker() function?
Observe the function signature: function addMarker(place). place is received as an argument. addMarker is called in a loop from the update function.
You only need to add a marker for the place ...
1
vote
Accepted
pset8 mashup - markers not showing up in map
This can happen if latitude and/or longitude are TEXT columns. They need to be NUMERIC columns, otherwise the select SQL in the update route returns no rows and addMarker doesn't get called.
1
vote
Accepted
pset8 addMarker undefined in info window
I incorporated this addMarker function into my app and it showed the list of articles in the info window (though the articles don't have "links"). So I "tweaked" articles; changed
return jsonify(...
1
vote
Accepted
pset8,MarkerWithLabel
MarkerWithLabel is not part of Google maps APIs, it is a third party product. Here's the doc for Google Marker Labels. IMO don't let this detail distract from completing the pset.
1
vote
Pset8: How to set label position and font?
Yes you can, as suggested here Google Maps API page
var image = {
url: "https://maps.google.com/mapfiles/kml/pal2/icon31.png",
labelOrigin: new google.maps.Point(15,40)
}
var ...
1
vote
pset8 addmarker info window
Here's a problem:
marker.addListener("click",function(){
$.ajax({url:"../articles.php",
type:"GET",
data:{geo:place.place_name},
success:function(response){
...
1
vote
Accepted
trouble with addMarker in pset8. getJSON seems to work but I'm not getting results
When you first click the marker, the .done() function hasn't delivered your JSON data yet, thus content will still be "" when you call showInfo(marker, content); at the very end.
Try to move showInfo(...
1
vote
pset8 infowindow shows up only after click twice
After discussing with my friends, we found the problem is due to the order of the code (although I am still not very clear why this old order would be buggy): instead of including getJSON function in ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
addmarker × 54pset8 × 52
mashup × 19
javascript × 7
showinfo × 6
google-maps-markers × 5
json × 4
infowindow × 4
getjson × 4
cs50x × 2
python × 2
maps × 2
articles.php × 2
removemarker × 2
pset × 1
cs50x2017 × 1
articles × 1
jquery × 1
map × 1
undefined × 1
2017 × 1
console × 1
script.js × 1