} busLineStr += ''; //map.closeInfoWindow(); $("#findDiv").hide(); $("#schoolLable").hide(); $("#busPointLable").show(); $("#search_list").html(""); $("#search_list").html(schoolInfo + busLineStr); } for (var i = 0; i < busIdArray.length; i++) { (function () { var tempindex = i; var lineId = busIdArray[tempindex]; $("#bus" + lineId).click(function () { ShowHtmlString('地图加载', '
  班车地图载入中...
', 400, 100); $("a.fstrong").attr("class", ""); $("#bus" + lineId).attr("class", "fstrong"); jQuery.post("/Search/getLineJson.html", {"lineId": lineId}, function (json) { if (json.error) { alert(json.error); return; } var busPointList = json.list; if (busPointList.length > 0) { clearAllOverlays(); var busPoints = new Array(); for (var i = 0; i < busPointList.length; i++) { (function () { var busPointIndex = i; var busPointObj = busPointList[busPointIndex]; var busPoint = new AMap.LngLat(busPointList[busPointIndex].x, busPointList[busPointIndex].y); var myIcon = new AMap.Icon({image:"/Application/Home/View/default/images/dt_xtd.png", size:new AMap.Size(22,55)}); busPoints[busPointIndex] = busPoint; var busPointMarker = new AMap.Marker({position:busPoint,icon: myIcon}); map.add(busPointMarker); /*if (i < busPointList.length - 1) { var busPoint2 = new BMap.Point(busPointList[busPointIndex + 1].x, busPointList[busPointIndex + 1].y); var polyline = new BMap.Polyline([busPoint, busPoint2], { strokeColor: "blue", strokeWeight: 6, strokeOpacity: 0.5 }); map.addOverlay(polyline); }*/ var marker = new AMap.Marker({position:new AMap.LngLat(schoolX, schoolY),icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_r.png"}); map.add(marker); /*map.setViewport(busPoints,{ padding: [50, 50, 50, 50], // 视野四周留边(上、右、下、左,单位px) animate: true // 是否开启动画过渡(默认true) });*/ busPointMarker.on("click", function () { var busPointInfoContent = ""; busPointInfoContent += '
'; busPointInfoContent += '

班车地址:' + busPointObj.name + '
班车时间:' + busPointObj.date + '

'; busPointInfoContent += '
'; busPointInfoContent += '
'; busPointInfoContent += ''; busPointInfoContent += '
'; busPointInfoContent += '
'; busPointInfoContent += '' + title + ''; busPointInfoContent += '
'; busPointInfoContent += '评分:' + score + '
'; busPointInfoContent += '地址:' + address + '
'; busPointInfoContent += '
'; busPointInfoContent += '
'; var busPointInfoWindow = new AMap.InfoWindow({content:busPointInfoContent,size:new AMap.Size(0, -25),title:""}); busPointInfoWindow.open(map, busPoint); }); ClosePop(); })(); } } }, "json"); }); })(); } var lineId = $("#busLineId").val(); if (lineId != null && lineId != "") { $("#bus" + lineId).trigger("click"); } } else { $("#map_right").hide(); } var point = new AMap.LngLat(schoolX, schoolY); var showType = $("#showType").val(); var innerContent = "1"; var marker = new AMap.Marker({position:point,icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_r.png"}); map.add(marker); var infocontent = ""; var isjzkey = 0; marker.on("mouseover", function () { jQuery.post("/Search/getKechengJson.html", {"schoolId": schoolId}, function (json) { infocontent = ''; var messageList = json.list; infocontent += '
' + title + ' ' + score + '分
'; infocontent += '
'; infocontent += '
'; infocontent += '
'; infocontent += '
' + title + '
'; infocontent += '评分:' + score + '分    电话:' + tel + '
'; infocontent += '地址:' + address + '
'; infocontent += '
'; if (messageList.length > 0) { infocontent += ''; } infocontent += "
"; var infoWindow = new AMap.InfoWindow({content:infocontent,size:new AMap.Size(0, -25),title:""}); infoWindow.open(map, point); }, "json"); }); }); } function addressSearch(){ var searchType = 2; var city = $("#cityname").val(); var inputAddress = document.getElementById("address").value; if(inputAddress==null||inputAddress=="")return; AMap.plugin('AMap.PlaceSearch', function(){ var autoOptions = { city: city, // 兴趣点城市 } var placeSearch = new AMap.PlaceSearch(autoOptions); placeSearch.search(inputAddress, function(status, result) { if (status === 'error') { //console.log('错误信息:', result); // 打印具体错误原因 } else if (status === 'complete') { //console.log('搜索成功:', result); } if (result.info === "OK"){ // 获取POI列表 var pois = result.poiList.pois; if (!pois || pois.length === 0) { return; } var s = []; s.push('
'); s.push('
'); s.push('
    '); for (var i = 0; i < pois.length; i ++){ // 默认打开第一标注的信息窗口 var selected = ""; s.push('
  1. '); s.push(' '); s.push('' + pois[i].name + ''); s.push(' - ' + pois[i].address + ''); s.push('
  2. '); s.push(''); } s.push('
'); document.getElementById("searchbaidulist").innerHTML = s.join(""); dialog('请选择您的位置',"id:searchbaidulist",500+"px","auto",""); } }) }); } function newAddressSearch(){ var searchType = 2; var inputAddress = document.getElementById("newaddress").value; if(inputAddress==null||inputAddress=="")return; AMap.plugin('AMap.PlaceSearch', function(){ var autoOptions = { city: city, // 兴趣点城市 } var placeSearch = new AMap.PlaceSearch(autoOptions); placeSearch.search(inputAddress, function(status, result) { if (status === 'error') { //console.log('错误信息:', result); // 打印具体错误原因 } else if (status === 'complete') { //console.log('搜索成功:', result); } if (result.info === "OK"){ // 获取POI列表 var pois = result.poiList.pois; if (!pois || pois.length === 0) { return; } var s = []; s.push('
'); s.push('
'); s.push('
    '); for (var i = 0; i < pois.length; i ++){ // 默认打开第一标注的信息窗口 var selected = ""; s.push('
  1. '); s.push(' '); s.push('' + pois[i].name + ''); s.push(' - ' + pois[i].address + ''); s.push('
  2. '); s.push(''); } s.push('
'); document.getElementById("searchbaidulist").innerHTML = s.join(""); dialog('请选择您的位置',"id:searchbaidulist",500+"px","auto",""); } }) }); } function openWinFuns(x,y,type,str){ if(!schoolId){ schoolId = 0; } location.href="/Search/mapSearch.html?addressX="+x+"&addressY="+y+"&searchType="+type+"&sid="+schoolId+"&searchKey="+encodeURI(str); } function searchAreaMap(id){ location.href = "/Search/mapSearch.html?area="+id; } function searchBusinessAreaMap(id){ location.href = "/Search/mapSearch.html?businessArea="+id; } function mapShow(){ // 验证 AMap 是否存在 if (typeof AMap === 'undefined') { //console.error('高德地图 API 未加载成功,请检查网络和密钥'); return; } map = new AMap.Map("container", { center: [schoolX, schoolY], // 中心点坐标(经度,纬度) zoom: 15, // 缩放级别 resizeEnable: true }); map.addControl(new AMap.Scale({visible: true})); map.addControl(new AMap.OverView({ isOpen: false, // 初始是否展开,默认关闭 visible: true })); map.addControl(new AMap.ToolBar({visible: true})); map.setCity(city); } // 清除所有覆盖物 function clearAllOverlays() { // 1. 获取地图上所有覆盖物 var allOverlays = map.getAllOverlays(); // 2. 批量移除(核心方法:map.remove) map.remove(allOverlays); } ShowHtmlString('地图加载','
  地图载入中,如加载失败,请点击刷新
',400,100); if (window.AMap) { // 若 API 已提前加载完成,直接初始化 mapShow(); mapload(); if(keyword!="" && typeof(keyword)!="undefined" && keyword!='您附近的街道/地标/建筑物'){ addressSearch(); } } else { // 等待 API 加载完成后触发(高德 API 自带事件) window.onLoad = window.onLoad || function() {}; const originalOnLoad = window.onLoad; window.onLoad = function() { originalOnLoad(); mapShow(); mapload(); if(keyword!="" && typeof(keyword)!="undefined" && keyword!='您附近的街道/地标/建筑物'){ addressSearch(); } }; } $(function(){ $('#address').bind('keyup', function(event){ if (event.keyCode=="13"){ addressSearch(); } }); $('#newaddress').bind('keyup', function(event){ if (event.keyCode=="13"){ newAddressSearch(); } }); $("#jx").click(function(){ $("#jx").attr("class","search_jx"); $("#bc").attr("class",""); $("input[type=radio][value=1]").attr("checked",'checked'); $("#searchType2").removeAttr("checked"); $("#searchType").val(1); $("#addressSubmit").val("附近驾校"); }); $("#bc").click(function(){ $("#bc").attr("class","search_jx"); $("#jx").attr("class",""); $("#searchType1").removeAttr("checked"); $("input[type=radio][value=2]").attr("checked",'checked'); $("#searchType").val(2); $("#addressSubmit").val("附近班车"); }); });