成都民宿

成都民宿

当前位置: 主页 > 成都民宿

附近的酒店住宿查询电话 (附近的酒店住宿查询)

作者:企业邮箱       发布于:2024-11-06        点击量: 874

附近酒店住宿查询

<script> // Google Maps API 加载完毕后的回调函数function initMap() {// 创建地图对象const map = new google.maps.Map(document.getElementById("map"), {center: { lat: 31.230416, lng: 121.473701 },zoom: 13,});// 创建信息窗口对象const infowindow = new google.maps.InfoWindow();// 获取表单元素const form = document.getElementById("form");const addressInput = document.getElementById("address");const radiusInput = document.getElementById("radius");const results = document.getElementById("results");// 添加表单提交事件监听器form.addEventListener("submit", (e) => {e.preventDefault();// 获取表单数据const address = addressInput.value;const radius = parseInt(radiusInput.value);// Geocode 地址const geocoder = new google.maps.Geocoder();geocoder.geocode({ address }, (results, status) => {if (status === "OK") {const location = results[0].geometry.location;// 在地图上显示标记const marker = new google.maps.Marker({ position: location,map: map,});// 设置信息窗口内容infowindow.setContent(`
地址:
${address}`);infowindow.open({anchor: marker,map,shouldFocus: false,});// 根据地址和半径搜索酒店const request = {location,radius,type: "lodging",};const service = new google.maps.places.PlacesService(map);service.nearbySearch(request, (results, status) => {if (status === "OK") {// 清除之前的查询结果results.innerHTML = "";// 遍历查询结果并创建酒店条目for (const result of results) {const item = document.createElement("div");item.classList.add("result-item");const name = document.createElement("h4");name.textContent = result.name;item.appendChild(name);const address = document.createElement("p");address.textContent = result.vicinity;item.appendChild(address);const rating = document.createElement("p");rating.textContent = `评分:${result.rating}`;item.appendChild(rating);// 添加到结果列表中results.appendChild(item);}} else {alert("查询酒店时出错:" + status);}});} else {alert("解析地址时出错:" + status);}});});}// 加载 Google Maps APIif (window.google) {initMap();}
    本文由:成都民宿于(2024-11-06)发表了关于附近的酒店住宿查询电话 (附近的酒店住宿查询)的文章 。如转载请注明出处:http://www.cdcy-mail.com

如果您对此感兴趣,可以通过以下联系方式与我们联系:

点击这里给我发消息成都区销售    点击这里给我发消息重庆区销售    点击这里给我发消息云贵区销售    点击这里给我发消息华南区销售 点击这里给我发消息华北区销售 点击这里给我发消息华东区销售

华为企业邮箱销售热线:400-0828-083

蜀ICP备11006316号-8

Copyright © 2025

版权所有 成都畅邮信息 xml txt html 成都民宿 知识园地 行业新闻 流量卡 成都民宿