var ZdcEmapNearShopReSearchDone = false; /** * Change status error */ if(typeof ZdcSetErrorStatus == 'undefined'){ ZdcSetErrorStatus = function (_165,st){var _167;if(st==undefined){var _168=_165.charAt(4);var _169=_165.slice(3,5);if(_168=="9"){_167=1;}else{if(_165.substr(4,4)=="1009"){_167=5;}else{if(_168=="2"){_167=6;}else{if(_168=="6"||_168=="7"||_168=="8"||_169=="15"){_167=2;}else{_167=9;}}}}}else{_167=st;}this.retCode=_165||"";this.type="";this.status=_167;this.recCount=0;this.hitCount=0;this.rest=false;this.items=[];} } /** * NearShop Object */ function ZdcNearShop2(){ this.type = 'ZdcNearShop2'; this.result = false; this.text_data = null; } /** * NearShop get result search */ ZdcNearShop2.prototype.getResult = function(){ return this.result; } /** * Destroy search */ ZdcNearShop2.prototype.abort = function(){ if( this.httpReq ){ this.httpReq.abort(); } } /** * Search near shop */ ZdcNearShop2.prototype.search = function(opts, callback){ var owner = this; var target_url = "http://aws-strnavi-jppweb-in-alb/cgi/store_nearsearch.cgi"; var prm = ''; var latlonPrm = ''; if(opts.latlon != ''){ var latlonPrms = opts.latlon.split(','); latlonPrm += '&nelat=' + latlonPrms[2]; latlonPrm += '&nelon=' + latlonPrms[3]; latlonPrm += '&swlat=' + latlonPrms[0]; latlonPrm += '&swlon=' + latlonPrms[1]; } prm += 'intid=EmapMlSsS'; prm += '&lang=th'; prm += '&exkid='+opts.exceptKid; prm += '&cid='+opts.cid; prm += '&opt='+opts.cid; prm += '&pos='+opts.startPos; prm += '&cnt='+opts.maxCount; prm += '&lat='+opts.lat; prm += '&lon='+opts.lon; prm += '&latlon='+latlonPrm; prm += '&filter='+opts.jkn; prm += '&ewdist='+opts.radius+'&sndist='+opts.radius; prm += '&knsu='+opts.limitCount; prm += '&exkid='+opts.exceptKid; prm += '&cols='+opts.cols; var request_url = target_url+'?'+prm; this.httpReq = new ZdcEmapHttpRequest('UTF8', 'UTF8'); this.httpReq.request(request_url, function(reference_text,status){ var result = new ZdcNearShopResult2(reference_text, status); result.type = owner.type; result.options = opts; owner.result = result; ZDC.trigger(owner, 'end', result) if( callback != null ){ if (result.hitCount == 0) { if (opts.researchCount != "") { var target_url = "http://aws-strnavi-jppweb-in-alb/cgi/store_nearsearch.cgi"; var prm = ''; prm += 'intid=EmapMlSsS'; prm += '&lang=th'; prm += '&cid='+opts.cid; prm += '&opt=search'; prm += '&pos='+opts.startPos; prm += '&cnt='+opts.researchCount; prm += '&lat='+opts.lat; prm += '&lon='+opts.lon; prm += '&latlon='+latlonPrm; prm += '&filter='+opts.jkn; prm += '&ewdist=1000000&sndist=1000000'; prm += '&knsu='+opts.researchCount; prm += '&exkid='+opts.exceptKid; // add 2009/10/13 Y.Matsukawa prm += '&cols='+opts.cols; var request_url = target_url+'?'+prm; this.httpReq = new ZdcEmapHttpRequest('UTF8', 'UTF8'); this.httpReq.request(request_url, function(reference_text,status){ var result = new ZdcNearShopResult2(reference_text, status); result.type = owner.type; result.options = opts; owner.result = result; ZDC.trigger(owner, 'end', result) ZdcEmapNearShopReSearchDone = true; if( callback != null ){ callback(result); } }, opts.timeout); } else { callback(result); } } else { callback(result); } } }, opts.timeout); // mod 2014/12/24 Truong Khuong] } function ZdcNearShopOptions2(frewd){ this.cid = '99999999'; this.startPos = 1; this.maxCount = 30; this.lat = ''; this.lon = ''; this.latlon = ''; this.jkn = ''; this.limitCount = 100; this.radius = 50000; this.timeout = 60000; this.pointFlg = '2'; this.exceptKid = ''; this.cust = ''; this.researchCount = ''; this.polycol = ''; this.exarea = ''; this.cols = ''; } function ZdcNearShopResult2(text_data, status){ var result = []; result = eval('(' + text_data + ')'); var returnCode = result['return_code']; var recCount = parseInt(result['rec_count']); var hitCount = parseInt(result['hit_count']); var rest = ( returnCode.charAt(3) == '0' && returnCode.charAt(7) == '1' )? true : false; if( returnCode.charAt(3) == '1' ){ ZdcSetErrorStatus.call(this, returnCode); return; } this.retCode = returnCode; this.type = ''; this.status = status; this.recCount = recCount; this.hitCount = hitCount; this.rest = rest; this.items = []; for(var i = 0; i < recCount; i++){ lvl = result['store_list'][i]['lvl_s']; this.items.push(ZdcNearShopItem2(result['store_list'][i], lvl)); } } function ZdcNearShopItem2(cols, lvl){ var item={}; item.id = cols['store_id']; item.lat = cols['lat']; item.lon = cols['lon']; var icons = cols['icon_url'].split('icon_id='); item.icon = icons[icons.length - 1]; item.dist = cols['distance']; item.nflg = cols['new']=='1'; item.name = cols['content'][0]['text']; item.addr = cols['content'][1]['text']; cols['content'].forEach(function(val, key){ eval("item."+val['col'].toLowerCase()+" = val['"+val['type'].toLowerCase()+"']"); }); item.lvl = lvl; if(item.col_184 && ZdcEmapIconImg[item.col_184]) item.icon = item.col_184; return item; } var ZdcEmapNearShop2 = new ZdcNearShop2(); // add 2014/10/13 Le Dang Son ]