1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191 |
- define([
- 'html!templates/tools/toolPlaceSearch',
- 'modDir/service/addressSearch',
- 'modDir/service/poiSearch',
- 'modDir/service/regionSearch',
- 'modDir/service/routeSearch',
- 'text!data/address_baike/db.json',
- 'css!styles/tools/toolPlaceSearch'
- ], function(tpcLayout, addressSearchF, poiSearchF, regionSearchF, routeSearchF, addressBaikeDb) {
- /**
- * 索引函数
- */
- if (!Array.prototype.indexOf) {
- Array.prototype.indexOf = function(elt, from) {
- var len = this.length;
- var from = Number(arguments[1]) || 0;
- from = (from < 0) ? Math.ceil(from) : Math.floor(from);
- if (from < 0) {
- from += len;
- }
- for (; from < len; from++) {
- if (from in this && this[from] === elt) {
- return from;
- }
- return -1;
- }
- }
- }
- /**
- * 模块数据 用于数据存储和外部调用
- * @type {Object}
- * 数据存放
- */
- var modValue = {
- markers: {},
- options: {
- page: 1,
- bounds: null,
- pageSize: 10,
- keyWord: '',
- type: 'bounds', // bounds/dis
- center: null, //中心点
- dis: 0, //圆范围
- themeId: null, //类型
- pac: 0, //区域pac
- init_query_key: '' //原始查询关键字
- },
- initialized: false, //是否初始化
- placeDataResult: null, //查询数据集合
- fitBounds: true, //最优显示
- circleGroup: null, //圆容器
- searchCircle: null,
- searchPoup: null,
- markerGroup: null, //标记容器
- areaGroup: [], //区域容器
- searchArea:null,//当前选择的区域信息
- hotPoint: [{
- "name": "热门",
- "id": "0",
- "sons": [
- { "name": "交通枢纽", "id": "11" },
- { "name": "加油站", "id": "14" },
- { "name": "停车场", "id": "16" },
- { "name": "桥梁", "id": "12" },
- { "name": "城镇居民点", "id": "51" },
- { "name": "机关团体", "id": "42" },
- { "name": "企事业单位", "id": "43" },
- { "name": "风景区", "id": "63" }
- ]
- }, {
- "name": "交通",
- "id": "1",
- "sons": [{
- "name": "交通枢纽",
- "id": "11",
- "sons": [
- { "name": "山口、关隘", "id": "1341", "sons": "" },
- { "name": "锚地", "id": "2311", "sons": "" },
- { "name": "海港", "id": "2312", "sons": "" },
- { "name": "河港", "id": "2313", "sons": "" },
- { "name": "船闸、升船机战", "id": "2314", "sons": "" },
- { "name": "渡口", "id": "2315", "sons": "" },
- { "name": "长途汽车站", "id": "2322", "sons": "" },
- { "name": "火车站", "id": "1232", "sons": "" },
- { "name": "航空港", "id": "2341", "sons": "" }
- ]
- }, {
- "name": "桥梁",
- "id": "12",
- "sons": [
- { "name": "桥梁", "id": "2361", "sons": "" }
- ]
- }, {
- "name": "隧道",
- "id": "13",
- "sons": [
- { "name": "隧道", "id": "2362", "sons": "" }
- ]
- }, {
- "name": "加油站",
- "id": "14",
- "sons": [
- { "name": "加油站", "id": "2366", "sons": "" }
- ]
- }, {
- "name": "导航站",
- "id": "15",
- "sons": [
- { "name": "灯塔、导航站", "id": "2367", "sons": "" }
- ]
- }, {
- "name": "停车场",
- "id": "16",
- "sons": [
- { "name": "停车场", "id": "2354", "sons": "" }
- ]
- }]
- }, {
- "name": "设施",
- "id": "2",
- "sons": [{
- "name": "电力",
- "id": "21",
- "sons": [
- { "name": "电力设施", "id": "246", "sons": "" }
- ]
- }, {
- "name": "通信",
- "id": "22",
- "sons": [
- { "name": "通信设施", "id": "247", "sons": "" }
- ]
- }, {
- "name": "水利",
- "id": "23",
- "sons": [
- { "name": "井", "id": "241", "sons": "" },
- { "name": "蓄水区", "id": "242", "sons": "" },
- { "name": "排灌设施", "id": "243", "sons": "" },
- { "name": "堤堰", "id": "244", "sons": "" },
- { "name": "运河", "id": "245", "sons": "" }
- ]
- }, {
- "name": "其他",
- "id": "29",
- "sons": [
- { "name": "场", "id": "263", "sons": "" }
- ]
- }]
- }, {
- "name": "水系",
- "id": "3",
- "sons": [{
- "name": "海岛",
- "id": "31",
- "sons": [
- { "name": "海洋岛屿", "id": "115", "sons": "" }
- ]
- }, {
- "name": "河流",
- "id": "32",
- "sons": [
- { "name": "河流", "id": "121", "sons": "" }
- ]
- }, {
- "name": "池塘水库",
- "id": "33",
- "sons": [
- { "name": "湖泊", "id": "122", "sons": "" },
- { "name": "池塘", "id": "2421", "sons": "" },
- { "name": "水库", "id": "2423", "sons": "" }
- ]
- }]
- }, {
- "name": "单位",
- "id": "4",
- "sons": [{
- "name": "军事单位",
- "id": "41",
- "sons": [
- { "name": "军事区", "id": "2175", "sons": "" },
- { "name": "军事单位", "id": "275", "sons": "" }
- ]
- }, {
- "name": "机关团体",
- "id": "42",
- "sons": [
- { "name": "党政机关", "id": "271", "sons": "" },
- { "name": "民间组织", "id": "272", "sons": "" }
- ]
- }, {
- "name": "企事业单位",
- "id": "43",
- "sons": [
- { "name": "事业单位", "id": "273", "sons": "" },
- { "name": "企业", "id": "274", "sons": "" }
- ]
- }, {
- "name": "开发区",
- "id": "44",
- "sons": [
- { "name": "工业区、开发区", "id": "2173", "sons": "" }
- ]
- }, {
- "name": "边贸口岸",
- "id": "45",
- "sons": [
- { "name": "边贸区、口岸", "id": "2174", "sons": "" }
- ]
- }]
- }, {
- "name": "居民点",
- "id": "5",
- "sons": [{
- "name": "城镇",
- "id": "51",
- "sons": [
- { "name": "城镇居民点", "id": "221", "sons": "" }
- ]
- }, {
- "name": "农村",
- "id": "52",
- "sons": [
- { "name": "农村居民点", "id": "222", "sons": "" }
- ]
- }, {
- "name": "其他",
- "id": "59",
- "sons": [
- { "name": "工矿点", "id": "223", "sons": "" },
- { "name": "农、林、牧场等", "id": "224", "sons": "" },
- { "name": "其他", "id": "229", "sons": "" }
- ]
- }]
- }, {
- "name": "旅游",
- "id": "6",
- "sons": [{
- "name": "纪念地",
- "id": "61",
- "sons": [
- { "name": "纪念地", "id": "251", "sons": "" }
- ]
- }, {
- "name": "公园",
- "id": "62",
- "sons": [
- { "name": "公园", "id": "252", "sons": "" }
- ]
- }, {
- "name": "风景区",
- "id": "63",
- "sons": [
- { "name": "风景名胜区(点)", "id": "253", "sons": "" }
- ]
- }, {
- "name": "山地",
- "id": "64",
- "sons": [
- { "name": "山地", "id": "134", "sons": "" }
- ]
- }]
- }] //常用热点关键字
- };
- /**
- * 初始化
- * @type {Function}
- * @param options {Object}
- */
- function init() {
- if (!modValue.initialized) {
- setLayout();
- bindEvent();
- subscribe();
- modValue.initialized = true;
- modValue.markerGroup = map23DControl.group({
- action: 'add'
- });
- addressBaikeDb = JSON.parse(addressBaikeDb);
- }
- if($(".tools-painting").hasClass('cur')){
- // var r = confirm("是否离开标注并保存当前标注?");
- // if(r){
- // $(".tsAct li.save").click();
- // $(".modal .modal-header .close,#userDrawAddModal .form .sure").bind("click",function(){
- afac()
- // })
- // }
- } else{
- afac()
- }
-
- };
- function afac(){
- ONEMAP.C.publisher.publish({
- modName: 'placeSearch',
- }, 'tools:active');
- ONEMAP.D.panelMore = false;
- }
- /**
- * 数据合并
- */
- function initData(options) {
- if (typeof(options) != "undefined") {
- modValue.options.bounds = options.bounds || map2DViewer.map.getBounds();
- modValue.options.keyWord = options.keyWord || '';
- modValue.options.type = options.type || 'bounds';
- modValue.options.center = options.center || map23DData.view.center;
- modValue.options.dis = options.dis || null;
- modValue.options.pac = options.pac || 0;
- modValue.options.themeId = options.themeId || null;
- return modValue.options;
- }
- };
- /**
- * 监听事件
- */
- function subscribe() {
- //ONEMAP.C.publisher.subscribe(rePlaceSearch,'add3d');
- ONEMAP.C.publisher.subscribe(clearMarker, 'cleanMap');
- //ONEMAP.C.publisher.subscribe(remove, 'tools:active');
- };
- function unSubscribe() {
- ONEMAP.C.publisher.unSubscribe(clearMarker, 'cleanMap');
- //ONEMAP.C.publisher.unSubscribe(remove, 'tools:active');
- };
- function clearMarker() {
- map23DControl.group({
- action: 'cleanAll',
- guid: modValue.markerGroup
- })
- removeShowArea();
- map2DViewer.map.off('dragend zoomend', searchInViewFire);
- $(".category-list-wrap").empty();
- $(".place-list").empty();
- $(".page-wrap").empty();
- $("#searchInViewFrom").hide();
- $("#searchresult").hide();
- }
- function remove(options) {
- if (options.modName === 'placeSearch') {
- // if (modValue.options.type === 'pac') {
- // if ($(".tools-search").hasClass('cur')) {
- // $(".tools-search").removeClass('cur');
- // $("#searchInViewFrom").hide();
- // $("#searchresult").hide();
- // //clearMarker();
- // } else {
- // $(".tools-search").addClass('cur');
- // $("#searchInViewKey").val('关键字');
- // $("#searchInViewFrom").show();
- // $("#searchInViewFrom").css({
- // top:1,
- // })
- // $("#searchresult").css({
- // top:39
- // })
- // //$("#searchresult").show();
- // }
- // $(".tools-serchView").removeClass('cur');
- // } else if (modValue.options.type === 'bounds') {
- // if ($(".tools-serchView").hasClass('cur')) {
- // $(".tools-serchView").removeClass('cur');
- // $("#searchInViewFrom").hide();
- // $("#searchresult").hide();
- // $("#searchInViewFrom").css({
- // top:1,
- // })
- // $("#searchresult").css({
- // top:39
- // })
- // //clearMarker();
- // } else {
- // $(".tools-serchView").addClass('cur');
- // $("#searchInViewFrom").show();
- // $("#searchInViewKey").val('关键字');
- // $("#searchInViewFrom").css({
- // top:95,
- // })
- // $("#searchresult").css({
- // top:134
- // })
- // //$("#searchresult").show();
- // }
- // $(".tools-search").removeClass('cur');
- // }
- } else {
- // $(".tools-search").removeClass('cur');
- // $(".tools-serchView").removeClass('cur')
- // $("#searchInViewFrom").hide();
- // $("#searchresult").hide();
- cleanMarkerGroup();
- removeShowArea();
- //clearMarker();
- }
- };
- function setLayout() {
- $("#searchresult .cover-content").empty().html(tpcLayout);
- $("#placePanel .place-list-wrap").mCustomScrollbar({
- scrollInertia: 1000
- });
- // 海量地图库搜索结果滚动条
- // $("#placePanel .thematic-content").mCustomScrollbar({
- // scrollInertia: 1000
- // });
- };
- function changSearchType(type) {
- clearMarker();
- switch (type) {
- case 'pac':
- modValue.options.type = 'pac';
- map2DViewer.map.off('dragend zoomend', searchInViewFire);
- break;
- case 'bounds':
- modValue.options.type = 'bounds';
- //map2DViewer.map.on('dragend zoomend', searchInViewFire);
- }
- };
- function searchInViewFire() {
- setTimeout(function() {
- changeToBoundsSearch({
- keyWord: modValue.options.keyWord
- })
- // var keyWord = $('#searchInViewKey').val();
- // if (keyWord != '' && keyWord != '关键字') {
- // ONEMAP.D.user.searchKeyWord = keyWord;
- // changeToBoundsSearch({
- // keyWord: keyWord
- // });
- // }
- }, 600)
- };
- function globalSearchFire() {
- var qkeyWord = $("#searchInViewKey").val();
- $(".placeOther").show();
- modValue.options.keyWord = qkeyWord;
- modValue.options.type = 'pac';
- if (qkeyWord != '' && qkeyWord != '请输入地名关键字') {
- // 引入海量地图库搜索
- require(['modDir/atlas/atlasSearch'], function(atlasSearch) {
- atlasSearch.init();
- });
- // // 天气搜索结果
- // meteo.c.http.httpFunction(meteo.c.http.station, qkeyWord, null, function(json) {
- // showList(json);
- // })
- if (modValue.options.type === 'pac') {
- ONEMAP.D.user.searchKeyWord = qkeyWord;
- globalSearch({
- keyWord: qkeyWord
- });
- map2DViewer.map.off('dragend zoomend', searchInViewFire);
- } else {
- ONEMAP.D.user.searchKeyWord = qkeyWord;
- changeToBoundsSearch({ keyWord: qkeyWord });
- map2DViewer.map.on('dragend zoomend', searchInViewFire);
- }
- var sUrl = onemapUrlConfig.gcmsServiceUrl + '/search/global?query=' + qkeyWord + '&page=1&size=100&order=desc&sort=gcms_id';
- sUrl = encodeURI(sUrl);
- $(".gcms-search").hide();
- //gcms搜索
- $.ajax({
- url: sUrl,
- type: 'GET',
- dataType: 'json',
- success: function(data) {
- // console.log(data)
- $(".gcms-search-result-list").html("");
- if (data.total > 0) {
- $(".gcms-search").show();
- if ($("#gcms-search-result-list")) {
- $("#gcms-search-result-list").remove();
- }
- var ul = $('<ul id="gcms-search-result-list" class="panel"><h3>资源搜索结果列表</h3></ul>');
- $(data.data).each(function(i, el) {
- if (el.record) {
- var li = $('<li onclick="ONEMAP.M.gcmsEvents.showDetailDiy(\'' + el.record.gcms_id + '\',\'' + el.table + '\')">' + el.record.gcms_title + '</li>');
- li.appendTo(ul);
- if ($(".gcms-search-result-list li").length < 3) {
- li.clone().appendTo($(".gcms-search-result-list"));
- }
- }
- })
- ul.appendTo($("#sideBarBody"))
- } else {
- $(".gcms-search").hide();
- }
- }
- })
- }
- };
- // function showList(json) {
- // // console.log(json)
- // $('.meteo-search-result-list').html('');
- // for (var key in json) {
- // var name = json[key].cname ? json[key].cname : json[key].ename;
- // var html = "<li id='meteo-station-" + json[key].station + "'>" + name + "</li>";
- // $(".meteo-search-result-list").append(html);
- // $('#meteo-station-' + json[key].station).click(function(e) {
- // //if(map23DConfig.netType == 2){
- // meteo.c.popup.showPopup("" + e.currentTarget.id.split("-")[2], e.currentTarget.innerHTML, 0);
- // //}else if(map23DConfig.netType == 1){
- // //meteo.c.popup.showPopup("" + e.currentTarget.id.split("-")[2], e.currentTarget.innerHTML, 0,'2017-12-25 20:00:00', '2017-12-25 08:00:00');
- // //}
- // });
- // }
- // $('.meteo-search-result-list').show();
- // // meteo.c.popup.showPopup("station" , 'name', 0,'2017-12-25 20:00:00', '2017-12-25 08:00:00');
- // }
- function globalSearch(options) {
- modValue.fitBounds = true;
- //判断输入
- if (options.keyWord == '') {
- alert('查询关键字不能为空');
- return false;
- }
- if (options.keyWord.length < 2) {
- alert('查询关键字不允许输入单字');
- $('#header .h-center .close').click();
- return false;
- }
- if ((/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\s\"]/g).test(options.keyWord)) {
- alert('查询关键字只能包含英文、数字、中文');
- return false;
- }
- modValue.options.init_query_key = options.keyWord;
- getAreaInfo({ keywords: options.keyWord }, function(data) {
- if (data.residue_addr_name.length > 0 && (data.address[0]['area_name'].length > 0 || data.address[0]['name'].length > 0)) {
- //即包含匹配的区域列表又包含二次查询关键字
- createNameListForSearchResultHtml(data);
- initData({ type: 'pac', pac:'', keyWord: data.residue_addr_name });
- getPageResult({ page: 1,wrap:$('#searchresult .place-list') });
- } else if (data.residue_addr_name.length == 0 && (data.address[0]['area_name'].length > 0 || data.address[0]['name'].length > 0)) {
- //只包含匹配的区域列表
- createNameListResultHtml(data);
- getPageResult({ page: 1,wrap:$('#searchresult .place-list') });
- } else {
- //只包含二次查询关键字(原始关键字查询)
- initData({ type: 'pac', pac:'', keyWord: modValue.options.init_query_key });
- getPageResult({ page: 1 });
- }
- //return false;
- // if (data.residue_addr_name.length > 0) {
- // if (initData({ type: 'pac', keyWord: data.residue_addr_name })) {
- // //如果只返回一个参考地址
- // if (data.address.length == 1) {
- // //如果有pac 按pac查
- // //if(data.address[0].area_pac>0){
- // modValue.options.type = 'pac';
- // modValue.options.pac = (data.address[0].area_pac.toString()).length > 2 ? (data.address[0].area_pac.toString().substr(2, data.address[0].area_pac.toString().length - 1)) : data.address[0].area_pac;
- // if (modValue.options.pac.length > 7) {
- // modValue.options.pac = modValue.options.pac.substr(0, 7);
- // }
- // if (data.address[0].area_lat != 0 && data.address[0].area_lon != 0) {
- // addShowArea({
- // lat: data.address[0].area_lat,
- // lng: data.address[0].area_lon,
- // demand: pac2Demand(pac)
- // })
- // if (map23DData.display.map2D) {
- // map2DViewer.map.setView([data.address[0].area_lat, data.address[0].area_lon], getZoom({ 'pac': modValue.options.pac }));
- // setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- // } else if (map23DData.display.map3D) {
- // fly3DInView(data.address[0].area_lat, data.address[0].area_lon, getZoom({ 'pac': modValue.options.pac }));
- // }
- // }
- // getPageResult({ page: 1 });
- // //如果返回多个参考地址,列出参考地址
- // } else {
- // createNameListForSearchResultHtml(data);
- // }
- // }
- // } else {
- // if (data.address[0].pac > 0) {
- // if (initData({ keyWord: data.name })) {
- // if (map23DData.display.map2D) {
- // map2DViewer.map.setView([data.address[0].lat, data.address[0].lon], getZoom({ 'pac': data.address[0].pac.toString().substr(2, data.address[0].pac.toString().length - 1) }));
- // setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- // } else if (map23DData.display.map3D) {
- // fly3DInView(data.address[0].lat, data.address[0].lon, getZoom({ 'pac': data.address[0].pac.toString().substr(2, data.address[0].pac.toString().length - 1) }))
- // }
- // //ONEMAP.M.toolsBar.setSystemNote({type:'success',message:'已切换至 '+data.address[0].name+' 区域'});
- // modValue.placeDataResult = {
- // list: [{
- // cn: data.address[0].name,
- // lon: data.address[0].lon,
- // tc: 0,
- // tid: 0,
- // pac: 0,
- // lat: data.address[0].lat,
- // id: 0
- // }],
- // num_pages: 1,
- // page: 1,
- // per_page: 10,
- // total: 10,
- // type: 1
- // };
- // createResultHtml({ fitBounds: false });
- // setPlaceResultHtml();
- // setTimeout(function() {
- // modValue.markers[0].openPopup();
- // }, 300);
- // }
- // } else {
- // modValue.fitBounds = true;
- // if (initData({})) {
- // createNameListResultHtml(data);
- // }
- // return false;
- // }
- // }
- });
- };
- //区域尺度(scale)取值: 1: 全球、2: 大洲/大洋、3: 国家、4: 省、5: 市、6: 县
- function pac2Demand(pac) {
- switch (pac.toString().length) {
- case 11:
- return 6;
- break;
- case 9:
- return 5;
- break;
- case 7:
- return 4;
- break;
- case 5:
- return 3;
- break;
- case 3:
- return 2;
- break;
- case 0:
- return 1;
- break;
- }
- }
- function removeShowArea() {
- //移除之前的
- if (modValue.areaGroup.length > 0) {
- $.each(modValue.areaGroup, function(index, el) {
- map23DControl.polygon({
- action: 'remove',
- guid: el
- })
- });
- }
- modValue.areaGroup = [];
- }
- function addShowArea(options) {
- //移除之前的
- if (modValue.areaGroup.length > 0) {
- $.each(modValue.areaGroup, function(index, el) {
- map23DControl.polygon({
- action: 'remove',
- guid: el
- })
- });
- }
- //添加新的
- modValue.areaGroup = [];
- getRegionBoundary({ lat: options.lat, lng: options.lng, demand: options.demand }, function(data) {
- if (data) {
- if (data['type'] == 'Polygon') {
- //var altitude = [];
- //for(var i=0;i<data['coordinates'][0].length;i++){
- // altitude.push(10)
- //}
- modValue.areaGroup.push(map23DControl.polygon({
- action: 'add',
- geojson: {
- "type": "Feature",
- "properties": {
- title: data['name'],
- color: '#ff0000',
- weight: 1,
- fillColor: '#ff6600',
- opacity: 0.5,
- fillOpacity: 0.3,
- popupContent: '',
- altitudeMode:0,
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": data['coordinates']
- }
- }
- }))
- }
- if (data['type'] == 'MultiPolygon') {
- $.each(data['coordinates'], function(index, el) {
- //var altitude = [];
- //for(var i=0;i<el[0].length;i++){
- // altitude.push(10);
- //}
- modValue.areaGroup.push(map23DControl.polygon({
- action: 'add',
- geojson: {
- "type": "Feature",
- "properties": {
- title: data['name'],
- color: '#ff0000',
- weight: 1,
- fillColor: '#ff6600',
- opacity: 0.5,
- fillOpacity: 0.3,
- popupContent: '',
- altitudeMode:0,
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": el
- }
- }
- }))
- });
- }
- }
- })
- }
- function getPageResult(options) {
- cleanMarkerGroup();
- modValue.options.page = options.page;
- var poiSearch = new poiSearchF({
- page: modValue.options.page,
- pageSize: modValue.options.pageSize
- });
- ONEMAP.V.loading.load();
- if (modValue.options.type === 'bounds') {
- var min_lng = modValue.options.bounds.getSouthWest().lng;
- var max_lng = modValue.options.bounds.getNorthEast().lng;
- if (min_lng < -180) {
- min_lng = -180;
- }
- if (max_lng > 180) {
- max_lng = 180;
- }
- var bounds = {
- southWest: [modValue.options.bounds.getSouthWest().lat, min_lng],
- northEast: [modValue.options.bounds.getNorthEast().lat, max_lng]
- };
- poiSearch.getPoiByOptions({ bounds: bounds, keywords: modValue.options.keyWord },
- function(data) {
- ONEMAP.V.loading.loaded();
- if (data.hasOwnProperty('type')) {
- if (data.type == 1) {
- if (data.hasOwnProperty('data') && data['data'].length > 0) {
- data.page = data.page * 1;
- modValue.placeDataResult = data;
- createResultHtml(options);
- //setPlaceResultHtml();
- } else {
- if(modValue.options.type == "pac"){
- setNotResultHtml('没有搜索到 ' + modValue.options.keyWord + ' 的信息,请修改搜索条件。');
- }
- if(modValue.options.type == 'bounds'){
- setNotResultHtml('当前视野内没有搜索到 ' + modValue.options.keyWord + ' 的信息,请移动或缩放地图进行搜索。');
- }
- }
- } else if (data.type == 2) {
- data.page = data.page * 1;
- modValue.placeDataResult = data;
- createResultHtml(options);
- //setPlaceResultHtml();
- }
- } else {
- if(modValue.options.type == "pac"){
- setNotResultHtml('没有搜索到 ' + modValue.options.keyWord + ' 的信息,请修改搜索条件。');
- }
- if(modValue.options.type == 'bounds'){
- setNotResultHtml('当前视野内没有搜索到 ' + modValue.options.keyWord + ' 的信息,请移动或缩放地图进行搜索。');
- }
- }
- });
- } else if (modValue.options.type === 'theme') {
- var themeOptions = {
- rangeCenter: [modValue.options.center.lat, modValue.options.center.lng],
- range: modValue.options.dis
- };
- if (modValue.options.themeId || modValue.options.keyWord) {
- if (modValue.options.themeId) {
- themeOptions.themeId = modValue.options.themeId;
- }
- if (modValue.options.keyWord) {
- themeOptions.keywords = modValue.options.keyWord;
- }
- }
- poiSearch.getPoiByOptions(themeOptions, function(data) {
- ONEMAP.V.loading.loaded();
- if (data.hasOwnProperty('data') && data['data'].length > 0) {
- data.page = data.page * 1;
- modValue.placeDataResult = data;
- createResultHtml(options);
- //setPlaceResultHtml();
- } else {
- setNotResultHtml('没有搜索到相关的信息,请修改搜索条件。');
- }
- });
- } else if (modValue.options.type === 'pac') {
- var _searchKeyWord = options.hasOwnProperty('wrap')?modValue.options.init_query_key:modValue.options.keyWord;
- poiSearch.getPoiByOptions({ pac: modValue.options.pac, keywords: _searchKeyWord,center:map2DViewer.map.getCenter()}, function(data) {
- ONEMAP.V.loading.loaded();
- if (data.hasOwnProperty('type')) {
- if (data.type == 1) {
- if (data.hasOwnProperty('data') && data['data'].length > 0) {
- data.page = data.page * 1;
- modValue.placeDataResult = data;
- createResultHtml(options);
- //setPlaceResultHtml();
- } else {
- if(options.hasOwnProperty('wrap')){
- return false;
- }
- if(modValue.options.type == "pac"){
- setNotResultHtml('没有搜索到 ' + modValue.options.init_query_key + ' 的信息,请修改搜索条件。');
- }
- if(modValue.options.type == 'bounds'){
- setNotResultHtml('当前视野内没有搜索到 ' + modValue.options.init_query_key + ' 的信息,请移动或缩放地图进行搜索。');
- }
- }
- } else if (data.type == 2) {
- if(options.hasOwnProperty('wrap')){
- return false;
- }
- data.page = data.page * 1;
- modValue.placeDataResult = data;
- createResultHtml(options);
- //setPlaceResultHtml();
- }
- } else {
- if(options.hasOwnProperty('wrap')){
- return false;
- }
- if(modValue.options.type == "pac"){
- setNotResultHtml('没有搜索到 ' + modValue.options.init_query_key + ' 的信息,请修改搜索条件。');
- }
- if(modValue.options.type == 'bounds'){
- setNotResultHtml('当前视野内没有搜索到 ' + modValue.options.init_query_key + ' 的信息,请移动或缩放地图进行搜索。');
- }
- }
- });
- }
- };
- /**
- * 三维跳转
- */
- function fly3DInView(lat, lng, zoom) {
- map3DViewer.flyTo({
- center: {
- lat: lat,
- lng: lng
- },
- zoom: zoom,
- heading: 0, //摄像机平面角度 正北为0
- tilt: 0, //摄像机倾斜角
- });
- };
- /**
- * 构建分页数据
- * @type {Function}
- * @returns {*}
- * @private
- */
- function createResultHtml(options) {
- if(!options.hasOwnProperty('wrap')){
- $(".category-list-wrap").empty();
- }
- $(".place-list").empty();
- $(".page-wrap").empty();
- if (modValue.placeDataResult.type == 2) {
- $('<h3>查询到以下区域中包含 '+modValue.options.keyWord+'</h3>').appendTo($(".category-list-wrap"));
- //先判断数据到哪一个级别
-
- //列出一级
- var place_fi_length = 0;
- for (var place_fi in modValue.placeDataResult['data']) {
- if (ONEMAP.T.getObjNameAry(modValue.placeDataResult['data']).length > 1) {
- place_fi_length++;
- var _placeDl = $('<dl class="areaSelect fi" pid="' + modValue.placeDataResult['data'][place_fi]['pac'] + '"></dl>');
- var _placeDt = $('<dt><a href="javascript:void(0)">' + place_fi + '(' + modValue.placeDataResult['data'][place_fi]['count'] + ')</a></dt>');
- modValue.placeDataResult['data'][place_fi].area_name = place_fi;
- _placeDl.bind('click', { d: modValue.placeDataResult['data'][place_fi] }, function(e) {
- if (modValue.options.type == 'pac') {
- if (map23DData.display.map2D) {
- map2DViewer.map.setView([e.data.d.lat, e.data.d.lon], getZoom({ 'pac': e.data.d.pac }));
- setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- } else if (map23DData.display.map3D) {
- fly3DInView(e.data.d.lat, e.data.d.lon, getZoom({ 'pac': e.data.d.pac }));
- }
- addShowArea({
- lat: e.data.d.lat,
- lng: e.data.d.lon,
- demand: pac2Demand('00'+e.data.d.pac)
- })
- modValue.options.pac = e.data.d.pac;
- setTimeout(function() {
- modValue.options.type = 'pac';
- getPageResult({ page: 1 });
- }, 300);
- } else {
- if (map23DData.display.map2D) {
- map2DViewer.map.setView([e.data.d.lat, e.data.d.lon], map23DData.view.zoom + 2);
- setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- } else if (map23DData.display.map2D) {
- fly3DInView(e.data.d.lat, e.data.d.lon, map23DData.view.zoom + 2);
- }
- }
- $(".category-list-wrap").empty();
- });
- _placeDt.appendTo(_placeDl);
- _placeDl.appendTo($(".category-list-wrap"));
- }else {
- //列出二级
- var place_se_length = 0;
- for (var place_se in modValue.placeDataResult['data'][place_fi]['sub']) {
- if (ONEMAP.T.getObjNameAry(modValue.placeDataResult['data'][place_fi]['sub']).length > 1) {
- place_se_length++;
- var _placeDl_se = $('<dl class="areaSelect se" pid="' + modValue.placeDataResult['data'][place_fi]['sub'][place_se]['pac'] + '"></dl>');
- var _placeDt_se = $('<dt><a href="javascript:void(0)">'+place_fi + place_se + '(' + modValue.placeDataResult['data'][place_fi]['sub'][place_se]['count'] + ')</a></dt>');
- modValue.placeDataResult['data'][place_fi]['sub'][place_se].area_name = place_se;
- _placeDl_se.bind('click', { d: modValue.placeDataResult['data'][place_fi]['sub'][place_se] }, function(e) {
- if (modValue.options.type == 'pac') {
- if (map23DData.display.map2D) {
- map2DViewer.map.setView([e.data.d.lat, e.data.d.lon], getZoom({ 'pac': e.data.d.pac }));
- setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- } else if (map23DData.display.map2D) {
- fly3DInView(e.data.d.lat, e.data.d.lon, getZoom({ 'pac': e.data.d.pac }));
- }
- addShowArea({
- lat: e.data.d.lat,
- lng: e.data.d.lon,
- demand: pac2Demand('00'+e.data.d.pac)
- })
- modValue.options.pac = e.data.d.pac;
- setTimeout(function() {
- modValue.options.type = 'pac';
- getPageResult({ page: 1 });
- }, 300);
- } else {
- if (map23DData.display.map2D) {
- map2DViewer.map.setView([e.data.d.lat, e.data.d.lon], map23DData.view.zoom + 2);
- setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- } else if (map23DData.display.map3D) {
- fly3DInView(e.data.d.lat, e.data.d.lon, map23DData.view.zoom + 2);
- }
- }
- $(".category-list-wrap").empty();
- });
- _placeDt_se.appendTo(_placeDl_se);
- _placeDl_se.appendTo($(".category-list-wrap"));
- }else {
- //如果二级只有一个,列出三级
- if (ONEMAP.T.getObjNameAry(modValue.placeDataResult['data'][place_fi]['sub']).length == 1) {
- if(ONEMAP.T.getObjNameAry(modValue.placeDataResult['data'][place_fi]['sub'][place_se]['sub']).length > 0){
- for (var place_th in modValue.placeDataResult['data'][place_fi]['sub'][place_se]['sub']) {
- var _placeDl_th = $('<dl class="areaSelect th" pid="' + modValue.placeDataResult['data'][place_fi]['sub'][place_se]['sub'][place_th]['pac'] + '"></dl>');
- var _placeDt_th = $('<dt><a href="javascript:void(0)">'+place_fi+place_se + place_th + '(' + modValue.placeDataResult['data'][place_fi]['sub'][place_se]['sub'][place_th]['count'] + ')</a></dt>');
- modValue.placeDataResult['data'][place_fi]['sub'][place_se]['sub'][place_th].area_name = place_th;
- _placeDl_th.bind('click', { d: modValue.placeDataResult['data'][place_fi]['sub'][place_se]['sub'][place_th] }, function(e) {
- if (modValue.options.type == 'pac') {
- if (map23DData.display.map2D) {
- map2DViewer.map.setView([e.data.d.lat, e.data.d.lon], getZoom({ 'pac': e.data.d.pac }));
- setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- } else if (map23DData.display.map3D) {
- fly3DInView(e.data.d.lat, e.data.d.lon, getZoom({ 'pac': e.data.d.pac }));
- }
- addShowArea({
- lat: e.data.d.lat,
- lng: e.data.d.lon,
- demand: pac2Demand('00'+e.data.d.pac)
- })
- modValue.options.pac = e.data.d.pac;
- setTimeout(function() {
- modValue.options.type = 'pac';
- getPageResult({ page: 1 });
- }, 300);
- } else {
- if (map23DData.display.map2D) {
- map2DViewer.map.setView([e.data.d.lat, e.data.d.lon], map23DData.view.zoom + 2);
- setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- } else if (map23DData.display.map3D) {
- fly3DInView(e.data.d.lat, e.data.d.lon, map23DData.view.zoom + 2);
- }
- }
- $(".category-list-wrap").empty();
- //ONEMAP.M.toolsBar.setSystemNote({type:'success',message:'已切换至 '+e.data.d.area_name+' 区域'});
- });
- _placeDt_th.appendTo(_placeDl_th);
- _placeDl_th.appendTo($(".category-list-wrap"));
- }
- }else {
- if (ONEMAP.T.getObjNameAry(modValue.placeDataResult['data'][place_fi]['sub']).length == 1 &&
- ONEMAP.T.getObjNameAry(modValue.placeDataResult['data'][place_fi]['sub'][place_se]['sub']).length == 0){
- var goData = modValue.placeDataResult['data'][place_fi]['sub'][place_se];
- if (modValue.options.type == 'pac') {
- if (map23DData.display.map2D) {
- map2DViewer.map.setView([goData.lat, goData.lon], getZoom({ 'pac': goData.pac }));
- setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- } else if (map23DData.display.map2D) {
- fly3DInView(goData.lat, goData.lon, getZoom({ 'pac': goData.pac }));
- }
- addShowArea({
- lat: goData.lat,
- lng: goData.lon,
- demand: pac2Demand('00'+goData.pac)
- })
- if(modValue.options.pac.toString().length == goData.pac.toString().length){
- modValue.options.pac = goData.pac*100;
- }else {
- modValue.options.pac = goData.pac;
- }
-
- setTimeout(function() {
- modValue.options.type = 'pac';
- getPageResult({ page: 1 });
- }, 300);
- } else {
- if (map23DData.display.map2D) {
- map2DViewer.map.setView([goData.lat, goData.lon], map23DData.view.zoom + 2);
- setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- } else if (map23DData.display.map3D) {
- fly3DInView(goData.lat, goData.lon, map23DData.view.zoom + 2);
- }
- }
- $(".category-list-wrap").empty();
- }else {
- place_se_length++;
- var _placeDl_se = $('<dl class="areaSelect se" pid="' + modValue.placeDataResult['data'][place_fi]['sub'][place_se]['pac'] + '"></dl>');
- var _placeDt_se = $('<dt><a href="javascript:void(0)">'+place_fi + place_se + '(' + modValue.placeDataResult['data'][place_fi]['sub'][place_se]['count'] + ')</a></dt>');
- modValue.placeDataResult['data'][place_fi]['sub'][place_se].area_name = place_se;
- _placeDl_se.bind('click', { d: modValue.placeDataResult['data'][place_fi]['sub'][place_se] }, function(e) {
- if (modValue.options.type == 'pac') {
- if (map23DData.display.map2D) {
- map2DViewer.map.setView([e.data.d.lat, e.data.d.lon], getZoom({ 'pac': e.data.d.pac }));
- setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- } else if (map23DData.display.map2D) {
- fly3DInView(e.data.d.lat, e.data.d.lon, getZoom({ 'pac': e.data.d.pac }));
- }
- addShowArea({
- lat: e.data.d.lat,
- lng: e.data.d.lon,
- demand: pac2Demand('00'+e.data.d.pac)
- })
- if(modValue.options.pac.toString().length == e.data.d.pac.toString().length){
- modValue.options.pac = e.data.d.pac*100;
- }else {
- modValue.options.pac = e.data.d.pac;
- }
-
- setTimeout(function() {
- modValue.options.type = 'pac';
- getPageResult({ page: 1 });
- }, 300);
- } else {
- if (map23DData.display.map2D) {
- map2DViewer.map.setView([e.data.d.lat, e.data.d.lon], map23DData.view.zoom + 2);
- setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- } else if (map23DData.display.map3D) {
- fly3DInView(e.data.d.lat, e.data.d.lon, map23DData.view.zoom + 2);
- }
- }
- $(".category-list-wrap").empty();
- });
- _placeDt_se.appendTo(_placeDl_se);
- _placeDl_se.appendTo($(".category-list-wrap"));
- }
-
- }
-
- }
- }
-
- }
- }
-
- }
- } else {
- var _searchKeyWord = options.hasOwnProperty('wrap')?modValue.options.init_query_key:modValue.options.keyWord;
- if(modValue.options.type == 'bounds'){
- $('<h3>视野内查询到以下相关 '+_searchKeyWord+' 地名信息</h3>').appendTo($("#placePanel .place-list"));
- //根据视野内范围过滤视野外的数据
- for (var bi = 0, bl = modValue.placeDataResult.data.length; bi < bl; bi++) {
- var placeb = modValue.placeDataResult.data[bi];
- if(!modValue.options.bounds.contains(L.latLng(placeb.lat, placeb.lon))){
- delete modValue.placeDataResult.data[bi];
- }
- }
- }else if(modValue.options.type == 'pac'){
- $('<h3>查询到以下相关 '+_searchKeyWord+' 地名信息</h3>').appendTo($("#placePanel .place-list"));
- }
- for (var i = 0, l = modValue.placeDataResult.data.length; i < l; i++) {
- var place = modValue.placeDataResult.data[i];
- place.pnum = i;
- var nLatlng = L.Util.formatHMS([place.lat, place.lon]);
- var _placeDl = $('<dl id="plm' + place.id + '"></dl>');
- var _placeDt = $('<dt><i class="p' + (i + 1) + '"><img src="../images/layout/marker-icon' + (i + 1) + '.png" /></i><a href="javascript:void(0)">' + place.cn + '</a></dt>');
- var _placeDd = $('<dd><p class="area"></p>' +
- '<p class="latlng">' + nLatlng.lng + ' , ' + nLatlng.lat + '</p></dd>');
-
- fixAreaRegByPac(place.pac, _placeDd);
- _placeDl.bind('click', { d: place }, function(e) {
- if (map23DData.display.map2D) {
- modValue.markers[e.data.d.pnum].setZIndexOffset((new Date()).getTime());
- modValue.markers[e.data.d.pnum].openPopup();
- }
- //var zoomTo = ((map23DData.view.zoom>14)?map23DData.view.zoom:14);
- removeShowArea();
- if (map23DData.display.map2D) {
- map2DViewer.map.setView([e.data.d.lat, e.data.d.lon], e.data.d.l);
- setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- } else if (map23DData.display.map3D) {
- fly3DInView(e.data.d.lat, e.data.d.lon, e.data.d.l);
- }
- $("#placePanel .place-list .cur").removeClass("cur");
- $(this).addClass("cur");
- });
- _placeDt.appendTo(_placeDl);
- // if (place.pac) {
- // if (addressBaikeDb[place.pac]) {
- // var _bakeDd = $('<a class="baike" bid="' + place.pac + '">地名百科</a>');
- // _bakeDd.bind('click', function() {
- // var title = $(this).prev().html();
- // var bid = $(this).attr("bid");
- // require(['modDir/tools/toolAddressBaike'], function(toolAddressBaike) {
- // toolAddressBaike.init({
- // title: title,
- // bid: bid
- // });
- // });
- // })
- // _bakeDd.appendTo(_placeDt);
- // }
- // }
- _placeDd.appendTo(_placeDl);
- _placeDl.appendTo($(".place-list"));
- markerToMap(place);
- }
- if (modValue.fitBounds && modValue.placeDataResult.data.length > 1) {
- if (map23DData.display.map2D) {
- map2DViewer.map.fitBounds(map2DViewer.groups[modValue.markerGroup].getBounds(), { 'paddingTopLeft': [100, 100], 'paddingBottomRight': [100, 100],'maxZoom':15 });
- } else if (map23DData.display.map3D) {
- }
- }
- var countPages = modValue.placeDataResult.num_pages;
- if (countPages == 0) {
- countPages = 1;
- }
- modValue.pageJump = $('<div id="placeSearchPageJump" class="count"><span>第</span><input class="page_num input input-small" value="' + modValue.placeDataResult.page + '" type="text" /><span>/' + countPages + '页</span></div>');
- // modValue.pageJump.appendTo($(".page-wrap"));
- //$("#searchresult .page-wrap").show();
- modValue.pj = '<div id="placeSearchPageJump" class="count"><input class="page_num input input-small" value="' + modValue.placeDataResult.page + '" type="text" /><span>/' + countPages + '</span></div>'
-
- var pageHtmlBtnGroup = $('<div class="btn-group" style="width:315px"></div>').appendTo($(".page-wrap"));
- if (modValue.placeDataResult.per_page < modValue.placeDataResult.total) {
- if (modValue.placeDataResult.page == 1) {
- var abtnNext = $(modValue.pj + '<button type="button" title="下一页 >" class="btn btn2 btn-small next" pid=' + (modValue.placeDataResult.page + 1) + '>下一页 ></button>');
- pageHtmlBtnGroup.append(abtnNext);
- } else if (countPages == modValue.placeDataResult.page && modValue.placeDataResult.total > modValue.placeDataResult.per_page) {
- var abtnPrev = $('<button type="button" title="< 上一页" class="btn btn2 btn-small prev" pid=' + (modValue.placeDataResult.page - 1) + '>< 上一页</button>' + modValue.pj);
- pageHtmlBtnGroup.append(abtnPrev);
- } else {
- var abtnPrev = $('<button type="button" title="< 上一页" class="btn btn2 btn-small prev" pid=' + (modValue.placeDataResult.page - 1) + '>< 上一页</button>' + modValue.pj);
- var abtnNext = $('<button type="button" title="下一页 >" class="btn btn2 btn-small next" pid=' + (modValue.placeDataResult.page + 1) + '>下一页 ></button>');
- pageHtmlBtnGroup.append(abtnPrev).append(abtnNext);
- }
- $("#searchresult .page-wrap").show();
- } else {
- $("#searchresult .page-wrap").hide();
- }
- $("#placePanel .page-wrap .btn").bind('click', function() {
- if(options.hasOwnProperty('wrap')){
- getPageResult({ page: $(this).attr("pid"),wrap:options.wrap });
- }else {
- getPageResult({ page: $(this).attr("pid") });
- }
-
- });
- $("#placeSearchPageJump .page_num").bind('keydown', function(e) {
- if (e.keyCode === 13) {
- var pageJump = parseInt($("#placeSearchPageJump .page_num").val());
- if (!pageJump || pageJump > countPages) {
- return;
- } else {
- if(options.hasOwnProperty('wrap')){
- getPageResult({ page: parseInt(pageJump),wrap:options.wrap });
- }else {
- getPageResult({ page: parseInt(pageJump) });
- }
- }
- }
- });
- //结果数据大于20条 提示视野内搜索
- if (modValue.placeDataResult.total > 20) {
- if (!(modValue.options.type == 'bounds')) {
- $(".boundsSearchLink").empty();
- $("#placePanel .boundsSearchLink").show();
-
- $('<div>查询到的结果过多,您可以在当前视野内查询 <a> '+_searchKeyWord+' </a></div>').appendTo($(".boundsSearchLink"));
-
- $("#placePanel .boundsSearchLink a").bind('click', function() {
- $("#placePanel .boundsSearchLink").hide();
- fastBoundsSearch({
- keyWord:_searchKeyWord
- });
- });
- }
- } else {
- $("#placePanel .boundsSearchLink").hide();
- }
- }
- $("#placePanel .place-list-wrap").mCustomScrollbar('update');
- };
- /**
- * 无结果列表
- * @type {Function}
- * @param notText {String} 无结果说明文字
- * @returns {*}
- * @private
- */
- function setNotResultHtml(notText) {
- $(".category-list-wrap").empty();
- $(".place-list").empty();
- $(".page-wrap").empty();
- $('<p class="not-result">' + notText + '</p>').appendTo($(".place-list"));
- };
- /**
- * 快速当前区域查询
- */
- function fastBoundsSearch(options) {
- if(options.hasOwnProperty('keyWord')){
- var keyWord = options.keyWord;
- }else {
- var keyWord = $('#searchInViewKey').val();
- }
- ONEMAP.D.user.searchKeyWord = keyWord;
- changeToBoundsSearch({ keyWord: keyWord });
- map2DViewer.map.on('dragend zoomend', searchInViewFire);
- };
- /**
- * 快速搜索
- * [fastSearch description]
- * @return {[type]} [description]
- */
- function fastSearch() {
- var poiSearch = new poiSearchF({
- page: modValue.options.page,
- pageSize: modValue.options.pageSize
- });
- poiSearch.getPoiByOptions({ keywords: modValue.options.init_query_key },
- function(data) {
- ONEMAP.V.loading.loaded();
- if (data.hasOwnProperty('type')) {
- if (data.type == 1) {
- if (data.hasOwnProperty('data') && data['data'].length > 0) {
- data.page = data.page * 1;
- modValue.placeDataResult = data;
- createResultHtml({ page: 1 });
- //setPlaceResultHtml();
- } else {
- if(modValue.options.type == "pac"){
- setNotResultHtml('没有搜索到 ' + modValue.options.init_query_key + ' 的信息,请修改搜索条件。');
- }
- if(modValue.options.type == 'bounds'){
- setNotResultHtml('当前视野内没有搜索到 ' + modValue.options.init_query_key + ' 的信息,请移动或缩放地图进行搜索。');
- }
-
- }
- } else if (data.type == 2) {
- data.page = data.page * 1;
- modValue.placeDataResult = data;
- createResultHtml({ page: 1 });
- //setPlaceResultHtml();
- }
- } else {
- if(modValue.options.type == "pac"){
- setNotResultHtml('没有搜索到 ' + modValue.options.init_query_key + ' 的信息,请修改搜索条件。');
- }
- if(modValue.options.type == 'bounds'){
- setNotResultHtml('当前视野内没有搜索到 ' + modValue.options.init_query_key + ' 的信息,请移动或缩放地图进行搜索。');
- }
- }
- });
- };
- /**
- * 创建getAreaName结果二次查询列表数据
- * @param {[type]} options [description]
- * @return {[type]} [description]
- */
- function createNameListForSearchResultHtml(options) {
- $(".category-list-wrap").empty();
- $("#searchresult .page-wrap").hide();
- $(".place-list").empty();
- $(".page-wrap").empty();
- $(".fastSearchLink").empty();
- //$("#placePanel .fastSearchLink").show();
- // $('<div>您可以直接查询 <a>' + modValue.options.init_query_key + '</a></div>').appendTo($(".fastSearchLink"));
- // $("#placePanel .fastSearchLink a").bind('click', function() {
- // $("#placePanel .fastSearchLink").hide();
- // fastSearch();
- // });
- $('<h3>您可以选择以下区域进行查询:</h3>').appendTo($(".category-list-wrap"));
- for (var i = 0, l = options.address.length; i < l; i++) {
- var place = options.address[i];
- place.pnum = i;
- var nLatlng = L.Util.formatHMS([place.area_lat, place.area_lon]);
- var _placeDl = $('<dl class="areaSelect fi" id="plm' + place.pnum + '"></dl>');
- var _placeDt = $('<dt><a>' + place.area_name + '</a> <span class="area"></span></dt>');
- fixAreaRegByPac(place.area_pac, _placeDt)
- _placeDl.bind('click', { d: place }, function(e) {
- $("#placePanel .fastSearchLink").hide();
- $("#placePanel .place-list .cur").removeClass("cur");
- $(this).addClass("cur");
- addShowArea({
- lat: e.data.d.area_lat,
- lng: e.data.d.area_lon,
- demand: pac2Demand(e.data.d.area_pac)
- })
- modValue.options.type = 'pac';
- modValue.options.pac = (e.data.d.area_pac.toString()).length > 2 ? (e.data.d.area_pac.toString().substr(2, e.data.d.area_pac.toString().length - 1)) : e.data.d.area_pac;
- if (modValue.options.pac.length > 7) {
- modValue.options.pac = modValue.options.pac.substr(0, 7);
- }
- if (map23DData.display.map2D) {
- map2DViewer.map.setView([e.data.d.area_lat, e.data.d.area_lon], getZoom({ 'pac': modValue.options.pac }));
- setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- } else if (map23DData.display.map3D) {
- fly3DInView(e.data.d.area_lat, e.data.d.area_lon, getZoom({ 'pac': modValue.options.pac }));
- }
- getPageResult({ page: 1 });
- });
- _placeDt.appendTo(_placeDl);
- _placeDl.appendTo($(".category-list-wrap"));
- }
- };
- /**
- * 填充侧栏html列表
- * @type {Function}
- * @returns {*}
- * @private
- */
- function setPlaceResultHtml(options) {
- $("#placePanel .page-wrap .btn").bind('click', function() {
- if(options.hasOwnProperty('wrap')){
- getPageResult({ page: $(this).attr("pid"),wrap:options.wrap });
- }else {
- getPageResult({ page: $(this).attr("pid") });
- }
-
- });
- };
- function addPreZero(num) {
- var t = (num + '').length,
- s = '';
- for (var i = 0; i < 11 - t; i++) {
- s += '0';
- }
- return num + s;
- }
- /**
- * 构建分页数据 区域列表最终结果显示
- * @type {Function}
- * @returns {*}
- * @private
- */
- function createNameListResultHtml(options) {
- $(".category-list-wrap").empty();
- // $(".place-list").empty();
- // $(".page-wrap").empty();
- $('<h3>查询到以下相关区域信息</h3>').appendTo($(".category-list-wrap"));
- for (var i = 0, l = options.address.length; i < l; i++) {
- var place = options.address[i];
- place.pnum = i+100;
- var nLatlng = L.Util.formatHMS([place.area_lat, place.area_lon]);
- var _placeDl = $('<dl id="plm' + place.pnum + '"></dl>');
- var _placeDt = $('<dt><i class="p' + (i + 1) + '"><img src="../images/layout/marker-icon' + (i + 1) + '.png" /></i><a>' + place.area_name + '</a></dt>');
- var _placeDd = $('<dd><p class="area"></p>' +
- '<p class="latlng">' + nLatlng.lng + ' , ' + nLatlng.lat + '</p></dd>');
- fixAreaRegByPac(place.area_pac, _placeDd);
- _placeDl.bind('click', { d: place }, function(e) {
- addShowArea({
- lat: e.data.d.area_lat,
- lng: e.data.d.area_lon,
- demand: pac2Demand(e.data.d.area_pac)
- })
- $.each(map23DData.markers, function(i, t) {
- if (t.pnum === e.data.d.pnum) {
- map23DControl.marker({
- action: 'remove',
- guid: i
- })
- delete modValue.markers[e.data.d.pnum];
- }
- })
- markerToMap({
- lat: e.data.d.area_lat,
- lon: e.data.d.area_lon,
- id: e.data.d.pnum,
- cn: e.data.d.area_name,
- pnum: e.data.d.pnum
- });
- if (map23DData.display.map2D) {
- modValue.markers[e.data.d.pnum].setZIndexOffset((new Date()).getTime());
- modValue.markers[e.data.d.pnum].openPopup();
- }
- var pac = (e.data.d.area_pac.toString()).length > 2 ? (e.data.d.area_pac.toString().substr(2, e.data.d.area_pac.toString().length - 1)) : e.data.d.area_pac;
- // if (pac.length > 7) {
- // pac = pac.substr(0, 7);
- // }
- var zoomTo = getZoom({ 'pac': pac });
- if (map23DData.display.map2D) {
- map2DViewer.map.setView([e.data.d.area_lat, e.data.d.area_lon], zoomTo);
- setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- } else if (map23DData.display.map3D) {
- fly3DInView(e.data.d.area_lat, e.data.d.area_lon, zoomTo);
- }
- $("#placePanel .category-list-wrap .cur").removeClass("cur");
- $(this).addClass("cur");
- });
- _placeDt.appendTo(_placeDl);
- _placeDd.appendTo(_placeDl);
- var _area_pac = addPreZero(place.area_pac);
- if (_area_pac) {
- if (addressBaikeDb[_area_pac]) {
- var _bakeDd = $('<a class="baike" bid="' + _area_pac + '">地名百科</a>');
- _bakeDd.bind('click', function() {
- var title = $(this).prev().html();
- var bid = $(this).attr("bid");
- require(['modDir/tools/toolAddressBaike'], function(toolAddressBaike) {
- toolAddressBaike.init({
- title: title,
- bid: bid
- });
- });
- })
- //_bakeDd.appendTo(_placeDt);
- }
- }
- _placeDl.appendTo($(".category-list-wrap"));
- markerToMap({
- lat: place.area_lat,
- lon: place.area_lon,
- id: place.pnum,
- cn: place.area_name,
- pnum: place.pnum
- });
- }
- if (modValue.fitBounds && options.address.length > 1) {
- if (map23DData.display.map2D) {
- map2DViewer.map.fitBounds(map2DViewer.groups[modValue.markerGroup].getBounds(), { 'paddingTopLeft': [100, 100], 'paddingBottomRight': [100, 100],'maxZoom':15 });
- }
- } else {
- var pac = (options.address[0].area_pac.toString()).length > 2 ? (options.address[0].area_pac.toString().substr(2, options.address[0].area_pac.toString().length - 1)) : options.address[0].area_pac;
- if (pac.length > 7) {
- pac = pac.substr(0, 7);
- }
- var zoomTo = getZoom({ 'pac': pac });
- if (map23DData.display.map2D) {
- //map2DViewer.map.setView([options.address[0].area_lat, options.address[0].area_lon], zoomTo);
- setTimeout(function() { ONEMAP.C.publisher.publish('placeSearch', 'mapChange'); }, 200);
- } else if (map23DData.display.map3D) {
- fly3DInView(options.address[0].area_lat, options.address[0].area_lon, zoomTo);
- }
- }
- };
- /**
- * 添加标记到地图
- * @type {Function}
- * @param obj {Object} marker对象
- * @private
- */
- function markerToMap(obj) {
- var markerObj = {
- latlng: [obj.lat, obj.lon],
- name: obj.cn,
- pguid: obj.id,
- pnum: obj.pnum
- };
- createMarker(markerObj);
- };
- /**
- * 创建冒泡窗
- */
- function creatPopupHtml(options) {
- var popupHtml = '<div class="popup_html mini">' +
- ' <div class="popup-lt"></div>' +
- ' <div class="popup-lb"></div>' +
- ' <div class="popup-rt"></div>' +
- ' <div class="popup-rb"></div>' +
- ' <div class="popup-ct" style="text-indent:15px;line-height:48px">' + options.name +
- ' </div>' +
- ' <div class="popup-cb" style="padding-bottom:20px;color:#666666 !important">' + options.content + '</div>' +
- '</div>'
- return popupHtml;
- }
- /**
- * 创建地图标记
- * @type {Function}
- * @param obj {Object} marker
- * @returns {*}
- * @private
- */
- function createMarker(obj) {
- if (!modValue.initialized) {
- init();
- modValue.initialized = true;
- // ONEMAP.C.publisher.publish({
- // modName: 'userPoint',
- // }, 'tools:active');
- }
- var markerPoup = '<div class="placeInfo">' +
- '<div class="op text-right">设为:' +
- '<a id="placeSearchPointFrom" href="javascript:ONEMAP.M.placeSearch.setDirections(\'' + obj.pnum + '\',\'start\')">起点</a> | ' +
- '<a id="placeSearchPointFrom" href="javascript:ONEMAP.M.placeSearch.setDirections(\'' + obj.pnum + '\',\'across\')">途经点</a> | ' +
- //'<a id="placeSearchPointFrom" href="javascript:ONEMAP.M.placeSearch.setDirections(\''+obj.pnum+'\',\'avoid\')">规避点</a> | ' +
- '<a id="placeSearchPointGoTo" href="javascript:ONEMAP.M.placeSearch.setDirections(\'' + obj.pnum + '\',\'stop\')">终点</a></div>' +
- '</div>';
- var options_popup = {
- name: obj.name,
- content: markerPoup
- }
- markerPoup = creatPopupHtml(options_popup);
- var markerId = map23DControl.marker({
- action: 'add',
- groupId: modValue.markerGroup,
- pnum: obj.pnum,
- objData: obj,
- geojson: {
- "properties": {
- //iconUrl: map23DConfig.map23DAssetsUrl + '/images/layout/marker-icon.png', //+(obj.pnum+1)+'
- iconUrl:map23DConfig.map23DAssetsUrl+'/images/layout/marker-icon'+(obj.pnum+1)+'.png',
- iconSize: [25, 41],
- iconAnchor: [13, 41],
- popupAnchor: [0, -39]
- },
- "geometry": {
- "type": "Point",
- "coordinates": [obj.latlng[1], obj.latlng[0]]
- }
- }
- });
- modValue.markers[obj.pnum] = map2DViewer.markers[markerId];
- map2DViewer.markers[markerId].bindPopup(markerPoup, {
- closeButton: false,
- maxWidth: 200,
- minWidth: 200,
- title: obj.name
- });
- map2DViewer.markers[markerId].on("mouseover", function() {
- this.setZIndexOffset((new Date()).getTime());
- this.openPopup();
- $('#placePanel .place-list .cur').removeClass('cur');
- $('#plm' + this.pguid).addClass('cur');
- });
- // map3DViewer.label({
- // action: 'update',
- // guid: markerId,
- // featureType: 'marker',
- // label: {
- // text: obj.name, //标牌内容
- // textColor: '#ffffff', //标牌文字颜色
- // lineColor: '#ff0000', //标牌引线及边框颜色
- // background: '#FF0000', //标牌背景颜色
- // lineTop: 10, //标牌偏移值
- // lineLeft: 100 //标牌偏移值
- // }
- // })
- };
- function setFav(num) {
- //判断是否登录,没有登录进行提示
- if (!ONEMAP.D.isLoad) {
- ONEMAP.C.publisher.publish({
- type: 'warning',
- message: '请登录后使用!'
- }, 'noteBar::add');
- return false;
- }
- var marker = modValue.markers[num];
- var markerData = map23DData.markers[marker.guid]
- var objData = {
- latlng: [marker.getLatLng().lng, marker.getLatLng().lat],
- name: markerData.objData.name,
- obj: markerData.objData
- }
- require(['modDir/user/userPoint'], function(userPoint) {
- userPoint.addPoint(objData);
- })
- };
- function setDirections(pguid, type) {
- switch (type) {
- case 'start':
- var marker = modValue.markers[pguid];
- setDirectionsPoint(marker.getLatLng().lat, marker.getLatLng().lng, 'start', marker.dirName);
- break;
- case 'across':
- var marker = modValue.markers[pguid];
- setDirectionsPoint(marker.getLatLng().lat, marker.getLatLng().lng, 'across', marker.dirName);
- break;
- case 'avoid':
- var marker = modValue.markers[pguid];
- setDirectionsPoint(marker.getLatLng().lat, marker.getLatLng().lng, 'avoid', marker.dirName);
- break;
- case 'stop':
- var marker = modValue.markers[pguid];
- setDirectionsPoint(marker.getLatLng().lat, marker.getLatLng().lng, 'stop', marker.dirName);
- break;
- }
- };
- /**
- * 设置起始点
- * @type {Function}
- * @param _lat {String} 纬度
- * @param _lng {String} 经度
- * @param _type {String} 类型
- * @private
- */
- function setDirectionsPoint(_lat, _lng, _type, _name) {
- switch (_type) {
- case "start":
- require(['modDir/tools/toolRouteSearch'], function(toolRouteSearch) {
- toolRouteSearch.setStartPoint(new L.LatLng(_lat, _lng), _name);
- });
- break;
- case "across":
- require(['modDir/tools/toolRouteSearch'], function(toolRouteSearch) {
- toolRouteSearch.setAcrossPoint(new L.LatLng(_lat, _lng), _name);
- });
- break;
- case "avoid":
- require(['modDir/tools/toolRouteSearch'], function(toolRouteSearch) {
- toolRouteSearch.setAvoidPoint(new L.LatLng(_lat, _lng), _name);
- });
- break;
- case "stop":
- require(['modDir/tools/toolRouteSearch'], function(toolRouteSearch) {
- toolRouteSearch.setStopPoint(new L.LatLng(_lat, _lng), _name);
- });
- break;
- }
- };
- /**
- * 清除搜索结果
- * @return {[type]} [description]
- */
- function clearSearch() {
- cleanMarkerGroup();
- try {
- $(".category-list-wrap").empty();
- $(".place-list").empty();
- $(".page-wrap").empty();
- } catch (e) {}
- };
- /**
- * 根据pac的长度返回对应zoom 不包含大洋、大洲
- * @param {[type]} options [description]
- * @return {[type]} [description]
- */
- function getZoom(options) {
- var zhixiashi = [15611, 15612, 15631, 15650, 15681, 15682];
- //直辖市判断
- if (zhixiashi.indexOf(parseInt(options.pac)) != -1) {
- return 8;
- }
- switch (options.pac.toString().length) {
- case 3: //国家
- return 4;
- case 5: //省
- return 6;
- case 7: //市
- return 8;
- case 9: //县
- return 10;
- }
- return 12;
- };
- /**
- * 菜单 获取地名
- * @type {Function}
- * @param latlng {Object} 坐标
- * @param abc {Object} 容器
- * @param zoom {Int} 缩放等级
- * @private
- */
- function getPlaceName(latlng, abc, zoom) {
- var addressSearch = new addressSearchF();
- addressSearch.getAddressInfo({ zoom: (zoom ? zoom : 8), latLng: [latlng.lat, latlng.lng] }, function(data) {
- ONEMAP.V.loading.loaded();
- abc.find('.address').empty().append(data.data.region);
- $("#placePanel .place-list-wrap").mCustomScrollbar('update');
- });
- };
- /**
- * 菜单 获取pac所属区域
- * @type {Function}
- * @private
- */
- function fixAreaRegByPac(pac, wrap) {
- getPacRegionInfo({ pac: pac }, function(data) {
- ONEMAP.V.loading.loaded();
- wrap.find('.area').empty().append(data.name_continent + data.name_country + data.name_province + data.name_prefecture + data.name_county);
- })
- };
- function clearContextMenuMarker() {
- $.each(map2DViewer.markers, function(i, t) {
- map2DViewer.marker({
- action: 'remove',
- guid: i
- })
- });
- };
- /**
- * 地图周边搜索
- */
- function rightClickPopup(center) {
- if (modValue.searchCircle) {
- cleanCricle();
- }
- if (!modValue.initialized) {
- setLayout();
- }
- cleanMarkerGroup();
- // ONEMAP.C.publisher.publish({modName: 'clickPlaceSearch',
- // }, 'tools:active');
- ONEMAP.C.publisher.subscribe(clearContextMenuMarker, 'cleanMap');
- modValue.fitBounds = false;
- modValue.options.center = center;
- if (typeof(modValue.searchPoup) != 'null' || typeof(modValue.searchCircle) != 'null') {
- cleanRightClickPopup();
- }
- //dis是范围等级,对应的公里数:(dis*2+1)*5
- var form = '<div id="rightClickSearchForm">' +
- '<div class="s-form"><input type="text" class="input" id="rightClickSearchForm-keyWord"><button class="btn btn2" type="button">搜索</button></div>' +
- '<div class="s-select"><span>范围选择:</span><select class="select" id="rightClickSearchForm-select">' +
- '<option selected value="0">5公里内</option>' +
- '<option value="1">15公里内</option>' +
- '<option value="2">25公里内</option>' +
- '<option value="3">35公里内</option>' +
- '<option value="4">45公里内</option>' +
- '<option value="5">55公里内</option>' +
- '<option value="6">65公里内</option>' +
- '<option value="7">75公里内</option>' +
- '<option value="8">85公里内</option>' +
- '</select></div>' +
- '<div class="s-hot-point">' +
- '<div class="s-hot-point-select">' +
- '</div>' +
- '<ul id="placeSearchRoundThemeList">' +
- '<li><a href="javascript:ONEMAP.M.placeSearch.findSurround(11)" hid="11">交通枢纽</a></li>' +
- '<li><a href="javascript:ONEMAP.M.placeSearch.findSurround(14)" hid="14">加油站</a></li>' +
- '<li><a href="javascript:ONEMAP.M.placeSearch.findSurround(16)" hid="16">停车场</a></li>' +
- '<li><a href="javascript:ONEMAP.M.placeSearch.findSurround(12)" hid="12">桥梁</a></li>' +
- '<li><a href="javascript:ONEMAP.M.placeSearch.findSurround(51)" hid="51">城镇</a></li>' +
- '<li><a href="javascript:ONEMAP.M.placeSearch.findSurround(42)" hid="42">机关团体</a></li>' +
- '<li><a href="javascript:ONEMAP.M.placeSearch.findSurround(43)" hid="43">企事业单位</a></li>' +
- '<li><a href="javascript:ONEMAP.M.placeSearch.findSurround(63)" hid="63">风景区</a></li>' +
- '</ul>' +
- '</div>' +
- '</div>';
- var options_popup = {
- name: '周边搜索',
- content: form
- }
- form = creatPopupHtml(options_popup);
- modValue.searchPoup = new L.Popup({ maxWidth: 300 });
- modValue.searchPoup.setLatLng(center)
- .setContent(form)
- .openOn(map2DViewer.map);
- drawCircle(center, 5000);
- setMoreSurround();
- modValue.options.themeId = null;
- modValue.options.keyWord = '';
- bingClickEvents();
- map2DViewer.map.on('click', cleanRightClickPopup);
- };
- function bingClickEvents() {
- $("#rightClickSearchForm-select").bind('change', function() {
- var val = (parseInt($(this).val()) * 2 + 1) * 5000;
- map2DViewer.circle({
- action: 'update',
- geojson: {
- "properties": {
- radius: val
- }
- },
- guid: modValue.searchCircle
- })
- //searchCircle.setRadius(val);
- map2DViewer.map.fitBounds(map2DViewer.circles[modValue.searchCircle].getBounds());
- });
- $("#rightClickSearchForm .s-form .btn").bind('click', function() {
- var keyWord = $("#rightClickSearchForm .s-form .input").val();
- var dis = $("#rightClickSearchForm .select").val();
- if (keyWord.length == 0) {
- return false;
- }
- cleanRightClickPopup();
- if (initData({ 'keyWord': keyWord, 'dis': dis, 'type': "theme", center: modValue.options.center })) {
- $(".category-list-wrap").empty();
- $(".place-list").empty();
- $(".page-wrap").empty();
- /*$("#searchresult").css("top","0px")*/
- $("#searchresult").show();
- $("#userContent .userInfo").removeClass("active");
- getPageResult({ 'page': 1 });
- }
- });
- $('#rightClickSearchForm .s-form .input').on('keydown', function(e) {
- if (e.keyCode === 13) {
- var keyWord = $("#rightClickSearchForm .s-form .input").val();
- var dis = $("#rightClickSearchForm .select").val();
- if (keyWord.length == 0) {
- return false;
- }
- cleanRightClickPopup();
- if (initData({ 'keyWord': keyWord, 'dis': dis, 'type': "theme", center: modValue.options.center })) {
- $(".category-list-wrap").empty();
- $(".place-list").empty();
- $(".page-wrap").empty();
- /*$("#searchresult").css("top","0px")*/
- $("#searchresult").show();
- $("#userContent .userInfo").removeClass("active");
- getPageResult({ 'page': 1 });
- }
- }
- });
- };
- /**
- * 设置分类
- */
- function setMoreSurround() {
- $('#rightClickSearchForm .s-hot-point-select')
- .empty()
- .append($('<div class="list"><span>地名分类:</span><select class="select first">' +
- '<option value="0">常用</option>' +
- '<option value="1">交通</option>' +
- '<option value="2">设施</option>' +
- '<option value="3">水系</option>' +
- '<option value="4">单位</option>' +
- '<option value="5">居民点</option>' +
- '<option value="6">旅游</option>' +
- '</select>' +
- '</div>'));
- $('#rightClickSearchForm .s-hot-point-select .first').bind('change', function() {
- $('#placeSearchRoundThemeList').empty();
- for (var i = 0, l = modValue.hotPoint.length; i < l; i++) {
- if (modValue.hotPoint[i].id === $(this).val()) {
- for (var ii = 0, ll = modValue.hotPoint[i].sons.length; ii < ll; ii++) {
- var item = $('<li><a href="javascript:ONEMAP.M.placeSearch.findSurround(' + modValue.hotPoint[i].sons[ii].id + ')" hid="' + modValue.hotPoint[i].sons[ii].id + '">' + modValue.hotPoint[i].sons[ii].name + '</a></li>');
- item.appendTo($('#placeSearchRoundThemeList'));
- }
- }
- }
- });
- };
- /**
- * 根据半径画圆
- */
- function drawCircle(center, dis) {
- modValue.searchCircle = map2DViewer.circle({
- action: 'add',
- geojson: {
- "properties": {
- color: '#ff6600',
- weight: 1,
- fillColor: '#ff6600',
- opacity: 1,
- fillOpacity: 0.5,
- radius: dis //半径米
- },
- "geometry": {
- "type": "Circle",
- "coordinates": [center.lng, center.lat]
- }
- }
- });
- map2DViewer.map.fitBounds(map2DViewer.circles[modValue.searchCircle].getBounds());
- map2DViewer.circles[modValue.searchCircle].on('click', function() {
- cleanCricle();
- })
- };
- function findSurround(hid) {
- var keyWord = $("#rightClickSearchForm .s-form .input").val();
- if (keyWord.length == 0) {
- keyWord = 'temp';
- }
- $(".placeOther").hide();
- if (initData({ 'keyWord': keyWord, 'themeId': hid, 'dis': $("#rightClickSearchForm .select").val(), 'type': "theme", 'center': modValue.options.center })) {
- if (keyWord == 'temp') {
- modValue.options.keyWord = '';
- }
- /*$("#searchresult").css("top","0px")*/
- $("#searchresult").show();
- $("#userContent .userInfo").removeClass("active");
- getPageResult({ 'page': 1 });
- cleanRightClickPopup();
- }
- };
- /**
- * 清除右键弹出popup和圆
- * @type {Function}
- * @private
- */
- function cleanRightClickPopup() {
- if (map2DViewer.map.hasLayer(modValue.searchPoup)) {
- map2DViewer.map.removeLayer(modValue.searchPoup)
- }
- map2DViewer.map.on('click', cleanCricle);
- map2DViewer.map.off('click', cleanRightClickPopup);
- };
- function cleanCricle() {
- map2DViewer.circle({
- action: 'remove',
- guid: modValue.searchCircle
- })
- $("#searchresult").hide();
- /*$("#searchresult").css("top","39px");*/
- map2DViewer.map.off('click', cleanCricle);
- };
- /**
- * 清除标记
- * [cleanMarkerGroup description]
- * @return {[type]} [description]
- */
- function cleanMarkerGroup() {
- if (map23DData.display.map3D) {
- $.each(map3DViewer.markers, function(value, key) {
- // map3DViewer.label({
- // action: 'remove',
- // guid: value,
- // featureType: 'marker'
- // })
- })
- }
- map23DControl.group({
- action: 'cleanAll',
- guid: modValue.markerGroup
- })
- };
- function getAreaInfo(options, callback_func) {
- var poiSearch = new poiSearchF();
- poiSearch.getAreaInfo({ keywords: options.keywords }, function(data) {
- callback_func(data.data);
- });
- };
- function getPacRegionInfo(options, callback_func) {
- var regionSearch = new regionSearchF();
- regionSearch.getPacRegionInfo({ pac: options.pac }, function(data) {
- callback_func(data.data);
- });
- };
- function getRegionBoundary(options, callback_func) {
- var regionSearch = new regionSearchF();
- regionSearch.getRegionBoundary({ latLng: [options.lat, options.lng], demand: options.demand }, function(data) {
- callback_func(data.data);
- });
- };
- function changeToBoundsSearch(options) {
- modValue.fitBounds = false;
- //changSearchType({'type':'bounds'});
- modValue.options.init_query_key = options.keyWord;
- if (initData({ type: 'bounds', keyWord: options.keyWord })) {
- getPageResult({ page: 1 });
- }
- };
- function bindEvent() {
- // $('#searchInViewKey').bind('focusout', function() {
- // if ($(this).val() == '') {
- // $(this).val('关键字');
- // };
- // });
- $('#btnSearchInView').bind('click', function() {
- $("#placePanel .fastSearchLink").hide();
- $("#placePanel .boundsSearchLink").hide();
- ONEMAP.D.searchFirstResult = false;
- // if($(".tools-search").hasClass('cur')){
- modValue.options.type = 'pac'
- // }else if($('.tools-serchView').hasClass('cur')){
- // modValue.options.type = 'bounds'
- // }
- $("#searchresult").show();
- $("#userContent .userInfo").removeClass("active");
- map23DControl.group({
- action: 'cleanAll',
- guid: modValue.markerGroup
- })
- globalSearchFire();
- if ($("#searchInViewKey").val() == "") {
- $("#searchresult").hide();
- }
- });
- $('#searchInViewKey').bind('keydown', function(e) {
- $("#placePanel .fastSearchLink").hide();
- $("#placePanel .boundsSearchLink").hide();
- $('#header .h-center .close').show();
- $(".userInfo").removeClass("active");
- ONEMAP.D.searchFirstResult = false;
- if ($("#searchInViewKey").val() != "") {
- $('#header .h-center .close').show();
- }
- if (e.keyCode === 13) {
- if ($("#searchInViewKey").val() != "") {
- // if($(".tools-search").hasClass('cur')){
- modValue.options.type = 'pac'
- // }else if($('.tools-serchView').hasClass('cur')){
- // modValue.options.type = 'bounds'
- // }
- $("#searchresult").show();
- $("#userContent .userInfo").removeClass("active");
- map23DControl.group({
- action: 'cleanAll',
- guid: modValue.markerGroup
- })
- globalSearchFire();
- }
- }
- if ($("#searchInViewKey").val() == "") {
- $("#searchresult").hide();
- $('#header .h-center .close').hide();
- clearMarker();
- $("#placePanel .thematic-search-list").empty();
- ONEMAP.D.user.searchKeyWord = "";
- modValue.options.keyWord = "";
- //$(".meteo-search-result-list").html("");
- $("#placePanel .thematic-content").hide();
- ONEMAP.D.panelMore = false;
- // $(".abtn-mini-side-bar").removeClass("close");
- ONEMAP.C.publisher.publish('handHide', 'layout::sideBar');
- }
- });
- // $('#searchInViewKey').bind('focus', function() {
- // $(this).val('');
- // clearMarker();
- // });
- $('#header .h-center .close').unbind('click').bind('click', function() {
- $("#gcms-search-result-list").remove(); //移除右侧栏搜索结果
- $('#searchInViewKey').val('');
- clearMarker();
- $(this).hide();
- $("#placePanel .thematic-search-list").empty();
- ONEMAP.D.user.searchKeyWord = "";
- modValue.options.keyWord = "";
- //$(".meteo-search-result-list").html("");
- $("#thematicSearchKey").val("");
- $("#placePanel .thematic-content").hide();
- ONEMAP.D.panelMore = false;
- // $(".abtn-mini-side-bar").removeClass("close");
- ONEMAP.C.publisher.publish('handHide', 'layout::sideBar');
- });
- //gcms搜索列表
- $(".gcms-search .moreLi .fr").unbind('click').bind("click", function() {
- //设置zIndex 为最高
- var zIndex = ONEMAP.M.sideBar.getZIndex();
- $('#gcms-search-result-list').css({ zIndex: zIndex });
- $(".gcms-search-result-list").show();
- ONEMAP.D.currentSideBarMod = 'gcms-search-result-list';
- //开启侧栏
- ONEMAP.C.publisher.publish('handShow', 'layout::sideBar');
- })
- };
- return ONEMAP.M.placeSearch = {
- init: init,
- setFav: setFav,
- changSearchType: changSearchType,
- modValue: modValue,
- rightClickPopup: rightClickPopup,
- findSurround: findSurround,
- getAreaInfo: getAreaInfo,
- setDirections: setDirections,
- createMarker: createMarker
- }
- })
|