I have a query that retrieves location-based data from my database. After performing the query, I receive a collection of objects (which I consolidate into a single object and use console.log() to inspect its contents).
Each object represents a user's entry that includes notes about a specific location:
It includes: store name, address, userID, notes.
Multiple users can visit the same location and write different notes. My goal is to display these locations on a Google Map using the JavaScript API, grouping them by location so that when a marker is clicked, all notes for that specific location are displayed.
My approach involves grouping the objects based on address, then plotting the markers and iterating through each address as follows:
for (var i = 0; i < rowCountVisits; i++) {
var storelatlng = new google.maps.LatLng(
parseFloat(result[2].latVisit[i]),
parseFloat(result[2].lngVisit[i]));
locationsObjVisits.push({
storelatlng: storelatlng,
vName: result[2].vName[i],
address: result[2].locationVisit[i],
date: result[2].dateVisit[i],
notes: result[2].notes[i],
usersName: result[2].user.thisName[i],
thisColour: result[2].user.thisColour[i]
});
}
Regarding the locationsObjVisits... I'm unsure how to proceed with it. Any suggestions?