Rename index.html to index2.html
Browse files- index.html → index2.html +66 -40
index.html → index2.html
RENAMED
|
@@ -1005,30 +1005,30 @@
|
|
| 1005 |
});
|
| 1006 |
}
|
| 1007 |
|
| 1008 |
-
|
| 1009 |
-
|
| 1010 |
-
|
| 1011 |
-
|
| 1012 |
-
|
| 1013 |
-
|
| 1014 |
-
|
| 1015 |
-
|
| 1016 |
-
|
| 1017 |
-
|
| 1018 |
-
|
| 1019 |
-
|
| 1020 |
-
|
| 1021 |
-
|
| 1022 |
-
|
| 1023 |
-
|
| 1024 |
-
|
| 1025 |
-
|
| 1026 |
-
|
| 1027 |
-
|
| 1028 |
-
|
| 1029 |
-
|
| 1030 |
-
|
| 1031 |
-
|
| 1032 |
|
| 1033 |
// 搜索POI
|
| 1034 |
function searchPOI() {
|
|
@@ -1671,24 +1671,50 @@
|
|
| 1671 |
openModal('city-modal');
|
| 1672 |
});
|
| 1673 |
|
| 1674 |
-
|
| 1675 |
-
|
| 1676 |
-
|
| 1677 |
-
|
| 1678 |
-
|
| 1679 |
-
|
| 1680 |
-
|
| 1681 |
-
|
| 1682 |
-
|
| 1683 |
-
|
| 1684 |
-
|
| 1685 |
-
|
| 1686 |
-
|
| 1687 |
-
|
| 1688 |
-
|
| 1689 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1690 |
});
|
|
|
|
|
|
|
| 1691 |
});
|
|
|
|
| 1692 |
|
| 1693 |
// 收藏按钮点击事件
|
| 1694 |
document.getElementById('favorites-btn').addEventListener('click', function() {
|
|
|
|
| 1005 |
});
|
| 1006 |
}
|
| 1007 |
|
| 1008 |
+
// 初始化POI搜索
|
| 1009 |
+
function initPlaceSearch() {
|
| 1010 |
+
placeSearch = new AMap.PlaceSearch({
|
| 1011 |
+
pageSize: 10,
|
| 1012 |
+
pageIndex: 1,
|
| 1013 |
+
city: currentCity.adcode,
|
| 1014 |
+
citylimit: true,
|
| 1015 |
+
autoFitView: true
|
| 1016 |
+
});
|
| 1017 |
+
|
| 1018 |
+
// 自定义结果列表 - 使用正确的事件绑定语法
|
| 1019 |
+
placeSearch.on('complete', function(results) {
|
| 1020 |
+
document.querySelector('.loading').style.display = 'none';
|
| 1021 |
+
if (results.info === 'OK') {
|
| 1022 |
+
customizeResultList(results.poiList.pois);
|
| 1023 |
+
addMarkersToMap(results.poiList.pois);
|
| 1024 |
+
} else {
|
| 1025 |
+
document.getElementById('results-content').innerHTML = '<div class="no-results">没有找到相关结果</div>';
|
| 1026 |
+
}
|
| 1027 |
+
});
|
| 1028 |
+
|
| 1029 |
+
// 初始搜索
|
| 1030 |
+
searchPOI();
|
| 1031 |
+
}
|
| 1032 |
|
| 1033 |
// 搜索POI
|
| 1034 |
function searchPOI() {
|
|
|
|
| 1671 |
openModal('city-modal');
|
| 1672 |
});
|
| 1673 |
|
| 1674 |
+
// 城市项点击事件
|
| 1675 |
+
document.querySelectorAll('.city-item').forEach(function(cityItem) {
|
| 1676 |
+
cityItem.addEventListener('click', function() {
|
| 1677 |
+
var cityName = this.getAttribute('data-city');
|
| 1678 |
+
var cityAdcode = this.getAttribute('data-adcode');
|
| 1679 |
+
|
| 1680 |
+
currentCity = {
|
| 1681 |
+
name: cityName,
|
| 1682 |
+
adcode: cityAdcode
|
| 1683 |
+
};
|
| 1684 |
+
|
| 1685 |
+
updateCityText();
|
| 1686 |
+
|
| 1687 |
+
// 使用地理编码服务获取城市中心点
|
| 1688 |
+
var geocoder = new AMap.Geocoder();
|
| 1689 |
+
geocoder.getLocation(cityName, function(status, result) {
|
| 1690 |
+
if (status === 'complete' && result.info === 'OK') {
|
| 1691 |
+
// 获取城市中心点
|
| 1692 |
+
var location = result.geocodes[0].location;
|
| 1693 |
+
|
| 1694 |
+
// 设置地图中心点
|
| 1695 |
+
map.setCenter(location);
|
| 1696 |
+
|
| 1697 |
+
// 设置适当的缩放级别
|
| 1698 |
+
map.setZoom(11);
|
| 1699 |
+
|
| 1700 |
+
// 清除原有标记点
|
| 1701 |
+
clearMarkers();
|
| 1702 |
+
|
| 1703 |
+
// 执行新的搜索
|
| 1704 |
+
searchPOI();
|
| 1705 |
+
|
| 1706 |
+
// 更新社区内容
|
| 1707 |
+
loadCommunityContent();
|
| 1708 |
+
} else {
|
| 1709 |
+
// 如果地理编码失败,仍然执行搜索
|
| 1710 |
+
searchPOI();
|
| 1711 |
+
loadCommunityContent();
|
| 1712 |
+
}
|
| 1713 |
});
|
| 1714 |
+
|
| 1715 |
+
closeModal('city-modal');
|
| 1716 |
});
|
| 1717 |
+
});
|
| 1718 |
|
| 1719 |
// 收藏按钮点击事件
|
| 1720 |
document.getElementById('favorites-btn').addEventListener('click', function() {
|