divid=' container '/divselectstyle=' display : none;' id=' identity2'/selectselectstyle=' display : none;' id=' identity1'/selectscriptsrc=' https://web API.AMAP.com/maps? v=1.4.0key=AMAP cn7 sglrmccallback=init '/script script $ (function () $.Ajax ) type:'post,URL 3: bast success3360function(data ) {console.log ) data.hotel $.each (data.hotel infolist,function ) index, item ) ) $ ) ) #identity2) ).append ) ' option'item.hotellat'/),即$('#identity1' ).append ' option ' item (); } ) function init () {var hotelLat=new Array ); //数组var hotelLng=new Array (定义的$('#identity2 option ' ).each(function ()//所有optionvartxt=$(this ).teach ) 获取选项的内容if (txt!='全部')//如果不是“全部”,则返回Hotellat.push(txt ); //添加到数组}; $('#identity1 option ' ).each(function ()//所有optionvartxt=$(this ).text ) ); 获取选项的内容if (txt!='全部')//如果不是“全部”,则返回hotellng.push(txt ); //添加到数组}; varmap=newamap.map(container ),{ resizeEnable: true,gddgz: 5 } ); var markers=[]; var positions=[]; for(varI=0; i hotelLat.length; I ) ) positions.push([HotelLNG[I],hotelLat[i]] ); (for ) varI=0,marker; i positions.length; I ) marker=new AMAP.marker (map : map,position: positions[i],image : ' http://vdata.AMAP.com/icons marker Markers.push(Marker ); }}/script后台代码
@Log ()网站搜索地址) ) responsebody@requestmapping ) value='/seladdress ',method=RequestMethod.POST ) public mast HttpServletResponse response ) throwsunsupportedencodingexception { mapstring,objectmmanagement} //此处与您的联系map.put(hotelInfoList )、hotelinfolist ); response.add header (' access-control-allow-origin ',' * ' ); response.add header (访问控制分配方法',GET,POST,PUT,DELETE,OPTIONS ' ); response.setheader (访问-控制-分配头(,x-requested-with ) ); response.add header (' access-control-max-age ',' 1800 ' ); //30 min返回地图; //返回页面映射中定义的XXX直接在页面上data.XX }