📍${city}
🍚 ${people.length} 位饭友
`;
people.forEach((person) => {
const eat = Math.max(
0,
Math.min(5, Number(person.eat) || 0)
);
html += `
👤 ${person.name}
🏫 ${person.school}
🍚 蹭饭指数:
${"⭐".repeat(eat)}
`;
});
html += "
";
const infoWindow = new AMap.InfoWindow({
content: html,
offset: new AMap.Pixel(0, -25)
});
infoWindow.open(map, [lng, lat]);
});
});
// 横幅和地图都完成后再适配视野,避免底图错位或空白
window.setTimeout(() => {
map.resize();
if (cityMarkers.length > 0) {
map.setFitView(cityMarkers, false, [40, 40, 40, 40]);
}
}, 350);
// ======================
// 同学列表
// ======================
const list = document.getElementById("list");
function renderList(data) {
list.innerHTML = "";
data.forEach((item) => {
const card = document.createElement("button");
card.type = "button";
card.className = "person";
card.innerHTML = `