I'm somewhat stuck at pset 8... not really "stuck" stuck as so far my code is working the way it should, but seeing how I am a bit confused in how objects work, I guess I must have been lucky (or ofc I am a wunderkind ;) )
Anyway: In scripts.js the function addMarker is declared and afterwards called in the function update.
for (var i = 0; i < data.length; i++)
{
addMarker(data[i]);
}
In this for loop a number of objects are created by passing in the return value data[i] (which are the objects returned in json by $.getJSON("update.php", parameters)
function addMarker(place)
{
// GPS coordinates for marker
var latLng = new google.maps.LatLng(place.latitude, place.longitude);
// Create marker
var marker = new google.maps.Marker({
position: latLng,
map: map,
title: place.place_name,
text: place.place_name,
});
}
In addMarker objects are created (in the markers global?) which have as properties: latLng and marker, the latter which is an object as well and has the keys: position, map, title, text
My questions are
- Is my reasoning correct?
- In the specification, it is said that maximum 10 locations will be mapped, where is this indicated in the code?
- Where is the global var markers used?
- Good design aside, the info window can potentially be a property in marker or an object in itself?