itsmo.vars.g_freeword_page = 0; itsmo.vars.g_freeword_mode = null; itsmo.vars.g_freeword_flg = '1'; // 全国 itsmo.freeword = {}; itsmo.vars.g_freeword_beforeMode = ''; itsmo.vars.g_freeword_beforeGenre = ''; itsmo.vars.g_free_word = ''; itsmo.vars.g_freeword_addr = false; itsmo.vars.g_free_word_bsFromDetail = ''; itsmo.vars.g_genre_bus_click = ''; /* freeword フリーワード検索 @param mode string 検索モード @param word string 検索ワード for public use */ itsmo.freeword.freeword = function( mode, word, other ) { itsmo.vars.g_genre_bus_click = ''; if (word == BUS_SEARCH_KEYWORD) { mode = 'bus'; //Bus around from detail if (other == itsmo.map.bus.genreSearchFlag){ itsmo.vars.g_genre_bus_click = '1'; } else if (typeof (other) != 'undefined' && other != '') { var parseLatLon = other.split('_'); if (parseLatLon.length == 2) { itsmo.vars.g_free_word_bsFromDetail = '1'; var lat = ZDC.msTodeg(parseLatLon[0]); var lon = ZDC.msTodeg(parseLatLon[1]); var center = new ZDC.LatLon(lat, lon); itsmo.vars.g_map_obj.moveLatLon(center); itsmo.vars.g_map_search_location = itsmo.lib.toMilliSec(center); } } itsmo.sub.map_tab_change('freeword', ['freeword', mode, word, other]); } else { itsmo.lib.document_setvalue('freewd', word); itsmo.sub.map_tab_change('freeword', ['freeword', mode, word]); } if (itsmo.vars.g_freeword_page != 0) itsmo.vars.g_freeword_page = 1; itsmo.vars.g_free_word = word; itsmo.vars.g_freeword_mode = mode; itsmo.vars.g_freeword_act = 'top'; itsmo.vars.g_freeword_addr = false; itsmo.freeword.freeword_search(); }; /* for public use map_top.tpl からコールされているようです。 */ itsmo.freeword.freeword_submit = function(url, key) { if (typeof itsmo.vars.addon === 'undefined' || typeof itsmo.vars.addon.onClickFreeword === 'undefined') { } else { var cancel = false; $.each(itsmo.vars.addon.onClickFreeword, function(i, v) { if (v()) { cancel = true; } }); if (cancel) { return false; } } itsmo.vars.g_freeword_page = 0; itsmo.vars.g_freeword_addr = false; if (itsmo.vars.g_freeword_beforeMode == '' || itsmo.vars.g_freeword_beforeMode != itsmo.vars.g_map_tab_mode) { itsmo.vars.g_freeword_beforeMode = itsmo.vars.g_map_tab_mode; } if (itsmo.vars.g_freeword_beforeGenre == '' || itsmo.vars.g_freeword_beforeGenre != itsmo.vars.g_range_genre) { itsmo.vars.g_freeword_beforeGenre = itsmo.vars.g_range_genre; } itsmo.freeword.freeword('', itsmo.lib.document_getvalue('freewd')); let data ={}; data.nm = itsmo.lib.document_getvalue('freewd'); itsmo.lib.localstorage_set(data); $('div form div.serch-box #freewd').blur(); itsmo.vars.g_range_spots_drawin = false; return false; }; /* for public use 地図を動かしたとき */ itsmo.freeword.freeword_submit_move = function() { itsmo.freeword.freeword('', itsmo.lib.document_getvalue('freewd')); return false; }; /* for public use 別の候補を選択した場合 */ itsmo.freeword.freeword_other = function(word) { $('#freewd').attr('value', word); itsmo.vars.g_free_word = word; itsmo.vars.g_freeword_mode = 'addr'; itsmo.vars.g_freeword_act = 'top'; if (itsmo.vars.g_freeword_page != 0) itsmo.vars.g_freeword_page = 1; itsmo.vars.g_freeword_addr = true; itsmo.sub.map_tab_change('freewordaddr', ['freewordaddr', '', word]); itsmo.freeword.freeword_search(); return false; }; /* for public use */ itsmo.freeword.freeword_move = function( lat, lon, cat, id, name ) { //if ( cat != null ) { itsmo.myspot.myspot_history_add( cat, id, name, lat, lon ); } itsmo.vars.g_map_obj.moveLatLon(itsmo.lib.toLatLon(lat, lon)); itsmo.map.map_search_timer(false); itsmo.sub.map_setcursor( lat, lon ); }; /* for public use */ itsmo.freeword.freeword_page = function( page,mode ) { itsmo.vars.g_freeword_page = page; if(mode){ itsmo.vars.g_freeword_mode = mode; } itsmo.vars.g_freeword_addr = false; itsmo.freeword.freeword_search(); }; /* freeword_search map/ajax_freeword.php にリクエストを投げ、 レスポンス時に、freeword_search_result 関数にコールバックさせます。 for private use */ itsmo.freeword.freeword_search = function() { var path = location.pathname; var paths = path.split('/'); if (paths[1] == 'c' || paths[1] == 'map') { path = '/'+paths[1]+'/'; } else { path = '/'+paths[1]+'/'+paths[2]+'/'; } // 2017/04/12 Phuoc Le - #8434 Add dataLayer dataLayer.push(['_trackEvent', 'フリーワード', path, itsmo.vars.g_free_word, , true]); if(itsmo.vars.g_free_word.length > 30){ alert('30文字以内で入力してください'); return false; } // ajax通信 var prm = itsmo.freeword.freeword_set_param(); itsmo.lib.map_waitopen(); if ( itsmo.vars.g_range_request != null ) { itsmo.lib.XMLHttpRequest2_abort( itsmo.vars.g_range_request ); } itsmo.vars.g_range_request = itsmo.lib.XMLHttpRequest2_send( '/map/ajax_freeword.php', itsmo.freeword.freeword_search_result, 'GET', prm, 'xml' ); }; /* freeword_set_param map/ajax_freeword.php にリクエストを投げる際のパラメータをセット for private use */ itsmo.freeword.freeword_set_param = function() { if(!itsmo.vars.g_freeword_mode){ var cnt = 5; }else{ var cnt = itsmo.vars.g_range_cnt; } if (itsmo.vars.g_home_p) { // 自宅~現在の地図中心との距離 itsmo.vars.g_dist = itsmo.lib.getDistance(itsmo.vars.g_home_p.lat, itsmo.vars.g_home_p.lon, itsmo.vars.g_map_search_location.lat, itsmo.vars.g_map_search_location.lon); } if(itsmo.vars.g_free_word == itsmo.vars.g_freeWordComment["df"]){ itsmo.vars.g_free_word = ''; } /* if(itsmo.vars.g_freeword_flg == '1'){//全国検索 var prm = '&word=' + encodeURIComponent(itsmo.vars.g_free_word) + '&mode=' + itsmo.vars.g_freeword_mode + '&page=' + itsmo.vars.g_freeword_page + '&cnt=' + cnt; }else{//周辺検索 itsmo.vars.g_freeword_mode = 'all';//施設検索のみ */ prm = itsmo.vars.g_map_search_location; var prm = '&word=' + encodeURIComponent(itsmo.vars.g_free_word) + '&mode=' + itsmo.vars.g_freeword_mode + '&lat=' + prm.lat + '&lon=' + prm.lon + '&minx=' + itsmo.vars.g_map_search_box.minx + '&miny=' + itsmo.vars.g_map_search_box.miny + '&maxx=' + itsmo.vars.g_map_search_box.maxx + '&maxy=' + itsmo.vars.g_map_search_box.maxy + '&page=' + itsmo.vars.g_freeword_page + '&cnt=' + itsmo.vars.g_range_cnt; if(itsmo.vars.g_free_word_bsFromDetail != ''){ prm += '&frDetail=' + itsmo.vars.g_free_word_bsFromDetail; } if(itsmo.vars.g_genre_bus_click != ''){ prm += '&busGenre=' + itsmo.vars.g_genre_bus_click; } if (itsmo.vars.g_freeword_act) prm += '&act=' + itsmo.vars.g_freeword_act; if (itsmo.vars.g_freeword_addr) prm += '&addron=1'; prm += '&dist=' + encodeURIComponent(itsmo.vars.g_dist); prm += '&byway=' + encodeURIComponent(itsmo.vars.g_byway); // 1:レコメンド経由 // } itsmo.vars.g_free_word_bsFromDetail = ''; return prm; }; itsmo.freeword.freewordMoveFirst = function (result) { var lat = null; var lon = null; if ($('status tpl', result) == 'ajax_freeword_list') { if ($('all items', result).length > 0) { lat = $($('all items', result)[0]).find('lat').text(); lon = $($('all items', result)[0]).find('lon').text(); if(lat != '' && lon != ''){ itsmo.vars.g_map_obj.moveLatLon(itsmo.lib.toLatLon(lat, lon)); return; } } if ($('phone items', result).length > 0) { lat = $($('phone items', result)[0]).find('lat').text(); lon = $($('phone items', result)[0]).find('lon').text(); if(lat != '' && lon != ''){ itsmo.vars.g_map_obj.moveLatLon(itsmo.lib.toLatLon(lat, lon)); return; } } } else if($('addr_only', result).text() != 1){ if ($('post items', result).length > 0) { lat = $($('post items', result)[0]).find('lat').text(); lon = $($('post items', result)[0]).find('lon').text(); if(lat != '' && lon != ''){ itsmo.vars.g_map_obj.moveLatLon(itsmo.lib.toLatLon(lat, lon)); return; } } if ($('station items', result).length > 0) { lat = $($('station items', result)[0]).find('lat').text(); lon = $($('station items', result)[0]).find('lon').text(); if(lat != '' && lon != ''){ itsmo.vars.g_map_obj.moveLatLon(itsmo.lib.toLatLon(lat, lon)); return; } } if ($('addr items', result).length > 0) { lat = $($('addr items', result)[0]).find('lat').text(); lon = $($('addr items', result)[0]).find('lon').text(); if(lat != '' && lon != ''){ itsmo.vars.g_map_obj.moveLatLon(itsmo.lib.toLatLon(lat, lon)); return; } } if ($('phone items', result).length > 0) { lat = $($('phone items', result)[0]).find('lat').text(); lon = $($('phone items', result)[0]).find('lon').text(); if(lat != '' && lon != ''){ itsmo.vars.g_map_obj.moveLatLon(itsmo.lib.toLatLon(lat, lon)); return; } } if ($('all items', result).length > 0) { lat = $($('all items', result)[0]).find('lat').text(); lon = $($('all items', result)[0]).find('lon').text(); if(lat != '' && lon != ''){ itsmo.vars.g_map_obj.moveLatLon(itsmo.lib.toLatLon(lat, lon)); return; } } } } /* freeword_search_result freeword_search 関数で投げられたリクエストが、 レスポンスされた時の処理です。 @param result object[xmldocument] レスポンスXML($.ajax の戻り) for private use (system use) */ itsmo.freeword.freeword_search_result = function( result ) { //if( typeof( result.responseXML.normalize ) != 'undefined') result.responseXML.normalize();// FFの4096byte制限対策 // result が XML などの場合 var err = $('err', result).text(); //var type = $('type', result).text(); if ( err != 0 ) { //alert( 'itsmo.freeword.freeword_search_result エラー ' + err ); //return; } itsmo.lib.map_waitclose(); itsmo.sub.map_tab_sethtml( $('left_html', result).text() ); itsmo.freeword.freewordMoveFirst(result); //チップクリア itsmo.sub.map_clickable_TipAllClear(1); var arrayExistID = []; if($('all', result)){ itsmo.freeword.set_tip($('all', result), arrayExistID); } if($('station', result)){ itsmo.freeword.set_tip($('station', result), arrayExistID); } if($('post', result)){ itsmo.freeword.set_tip($('post', result), arrayExistID); } if($('phone', result)){ itsmo.freeword.set_tip($('phone', result), arrayExistID); } if($('bus', result)){ itsmo.freeword.set_tip($('bus', result), arrayExistID); } arrayExistID = []; if($('addr', result)){ if ($('addr_only', result).text() == 1) { itsmo.sub.map_tab_change('addrlist', 1); // 最適化用変数初期化 itsmo.spot_range.spots_init(); itsmo.freeword.set_tip_range($('addr_data', result), true); itsmo.freeword.set_tip_range($('addr_list items', result), false); itsmo.vars.g_range_spots_uid = $(result).find('addr_data').find('uid').text(); // 住所周辺施設取得 itsmo.spot_range.detail_addr_range_top($('word', result).text()); // 中心に表示 prm = itsmo.vars.g_range_spots[itsmo.vars.g_range_spots_uid]; itsmo.spot_range.range_move(prm['lat'], prm['lon']); itsmo.spot_range.range_tipopen(prm['uid']); // フリーワード内容変更 $('#freewd').val(prm['nm']); // 絞込から検索時、絞込情報取得 if (itsmo.vars.g_range_spots_drawin) itsmo.spot_range.addr_list($(result).find('addr_data').find('adcd').text(), 0); } else { // ココ吹き出し itsmo.sub.map_maplink_tipallclear(); itsmo.freeword.set_maplink_data($('addr', result)); } } // ジャンル再検索リンク設定 itsmo.sub.set_genre_research(); //$('#ajax_leftmenu_result').html(result); /* // 動作分岐 switch ( type ) { case 'range': case 'wide': case 'all': itsmo.sub.map_tab_sethtml( $('html_list', result).text() ); itsmo.range.range_freeword( itsmo.vars.g_free_word, result ); break; case 'addr': case 'addrlist': itsmo.sub.map_tab_sethtml( $('html_list', result).text() ); break; } */ }; //全国?付近? itsmo.freeword.freewordSelectArea = function(id){ if(id == 'freewd_area'){ itsmo.vars.g_freeword_flg = 0; }else{ itsmo.vars.g_freeword_flg = 1; } var txt = $('#' + id + ' strong').html(); $('#freeword_flg span').html(txt); itsmo.lib.document_off('freeword_chg_window'); }; //ツールチップ作成 itsmo.freeword.set_tip = function(data, arrayExistID){ var set_tip = function(){ //param var prm = {}; prm['uid'] = $(this).find('uid').text(); //check id exist if($.inArray(prm.uid, arrayExistID) == -1) { prm['lat'] = $(this).find('lat').text(); prm['lon'] = $(this).find('lon').text(); prm['nm'] = $(this).find('nm').text(); prm['short_nm'] = $(this).find('short_nm').text(); prm['gnr_nm'] = $(this).find('gnr_nm').text(); prm['gnr_id'] = $(this).find('gnr_id').text(); prm['iconL'] = $(this).find('iconL').text(); prm['iconM'] = $(this).find('iconM').text(); prm['iconS'] = $(this).find('iconS').text(); if(prm['uid'].indexOf("bus") != -1){ prm['groupId'] = $(this).find('groupId').text(); prm['company'] = $(this).find('company').text(); } prm['tip_c'] = $(this).find('tip_c').text(); prm['tip_o'] = $(this).find('tip_o').text(); arrayExistID.push(prm.uid); //ツールチップ作成 var div_id = itsmo.sub.set_tooltip_s(prm['tip_c'],prm); //bind $('#' + div_id + ' a').click(function() { itsmo.freeword.set_tip_open(prm.uid); }); $('#' + div_id + ' .tipc_range_open1').click(function() { itsmo.freeword.set_tip_open(prm.uid); }); } } $(data).find('items').each(set_tip); }; //ツールチップOPEN itsmo.freeword.set_tip_open = function(uid){ var data = itsmo.vars.g_map_tipid_clickable_s[uid]; if(!data){ return false; } var div_id = itsmo.sub.map_clickable_tipopen(data.tip_o,data); }; //ココ吹き出しデータ作成 itsmo.freeword.set_maplink_data = function(data){ $(data).find('items').each(function(){ //param var prm = {}; prm['uid'] = $(this).find('uid').text(); prm['lat'] = $(this).find('lat').text(); prm['lon'] = $(this).find('lon').text(); prm['nm'] = $(this).find('nm').text(); prm['short_nm'] = $(this).find('short_nm').text(); prm['maplink_o'] = $(this).find('maplink_o').text(); itsmo.sub.map_getaddr({ lat: prm['lat'], lon: prm['lon'] }, function(result) { if(result.status == 0) { var addr = result.items[0].address; } else { var addr = ''; } prm['addr'] = addr; }, 6); itsmo.vars.g_map_tipid_clickable_s[prm['uid']] = prm; }); }; // ココ吹き出しオープン itsmo.freeword.set_maplink_open = function(uid) { var data = itsmo.vars.g_map_tipid_clickable_s[uid]; if(!data){ return false; } // IPリンク アイコン+吹き出し Allclear itsmo.sub.map_maplink_tipallclear(); // IPリンク吹き出し作成 itsmo.vars.g_map_link_html_o = data.maplink_o; itsmo.sub.maplink_set(data.lat, data.lon); }; //ツールチップ作成(地図最適化) itsmo.freeword.set_tip_range = function(data, flg){ var set_tip = function(){ //param var prm = {}; prm['uid'] = $(this).find('uid').text(); prm['lat'] = $(this).find('lat').text(); prm['lon'] = $(this).find('lon').text(); prm['nm'] = $(this).find('nm').text(); prm['short_nm'] = $(this).find('short_nm').text(); prm['adcd'] = $(this).find('adcd').text(); prm['adcdupp'] = $(this).find('adcdupp').text(); prm['gnr_nm'] = $(this).find('gnr_nm').text(); prm['gnr_id'] = $(this).find('gnr_id').text(); prm['iconL'] = $(this).find('iconL').text(); prm['iconM'] = $(this).find('iconM').text(); prm['iconS'] = $(this).find('iconS').text(); prm['tip_c'] = $(this).find('tip_c').text(); prm['tip_o'] = $(this).find('tip_o').text(); prm.tooltipOffsetBottomCenter = [ 14, 0 ]; if (flg) itsmo.vars.g_range_spots[prm['uid']] = prm; //ツールチップ作成 var div_id = itsmo.sub.set_tooltip_opt_s(prm['tip_c'],prm); //bind $('#' + div_id + ' a').click(function() { itsmo.spot_range.range_move(prm['lat'], prm['lon']); itsmo.spot_range.range_tipopen(prm['uid']); }); } data.each(set_tip); };