//--------------------------------------------------------------------------------------------------
// 汎用 Google Maps API スクリプト“ KsGMap ” Ver1.20 β04
// http://www.ksgmap.jp/
// Copyright(c) 2005-2013 Ksc
//--------------------------------------------------------------------------------------------------
//グローバル変数として定義
var ksgmap_start_date , ksgmap_import_flag , ksgmap_import_count , ksgmap_focus_category , ksgmap_import_current_file , ksgmap_apiversion;
var ksgmap_category = {}; var ksgmap_item = {};
var ksgmap_narrowCondition = {}; var ksgmap_marker = {}; var ksgmap_current_marker = {}; var ksgmap_template = {};
//参照用変数
var ksgmap__version = 1.20; //KsGMapのバージョン
var ksgmap__ua = {}; //UserAgent(ex. ksgmap__ua.Firefox = [true|false] )
var ksgmap__title = "";
//設定値の初期値
var ksgmap_poweredByKsGMap_time = 10;
var ksgmap_import_file = "";
var ksgmap_import_path = "";
var ksgmap_import_cache = 1;
var ksgmap_import_maxItems = Infinity;
var ksgmap_import_maxCategorys = Infinity;
var ksgmap_image_path = "./image/";
var ksgmap_debug_mode = 0;
var ksgmap_default_lng = 0;
var ksgmap_default_lat = 0;
var ksgmap_default_zoom = 15;
var ksgmap_default_type = "map";
var ksgmap_default_category = "";
var ksgmap_default_item = "";
var ksgmap_default_sort = "";
var ksgmap_zmarking = 1;
var ksgmap_zmarking_separate = "
";
var ksgmap_control_zoom = 1;
var ksgmap_control_type = 1;
var ksgmap_control_scale = 1;
var ksgmap_control_overviewMap = 0;
var ksgmap_control_overviewMap_width = 125;
var ksgmap_control_overviewMap_height = 125;
var ksgmap_control_streetView = 0;
var ksgmap_item_name = "アイテム";
var ksgmap_itemNavi_page_items = 0;
var ksgmap_itemNavi_countColumn = 1;
var ksgmap_itemNavi_rowStrips = 0;
var ksgmap_itemNavi_thirdRow = "";
var ksgmap_category_name = "カテゴリ";
var ksgmap_category_autoCentering = 0;
var ksgmap_category_all = 1;
var ksgmap_category_all_label = "すべて表示 (若干時間がかかります) ";
var ksgmap_category_map = 0;
var ksgmap_category_map_label = "マップ内の%item_name%を表示";
var ksgmap_infoWindow_tab = "";
var ksgmap_infoWindow_tab_defaultVisible = 1;
var ksgmap_infoWindow_func_moveCenter = 0;
var ksgmap_infoWindow_func_zoomDetail = 0;
var ksgmap_html_categoryNavi = "";
var ksgmap_html_itemNavi = "";
var ksgmap_html_itemNavi_autoZoom = "";
var ksgmap_html_googleLocal = "";
var ksgmap_html_search_itemName_textField = "";
var ksgmap_html_search_message = "";
var ksgmap_html_mapInfo_url = "";
var ksgmap_html_mapInfo_point = "";
var ksgmap_html_googleMap = "map";
var ksgmap_html_debug = "";
var ksgmap_link_type = 1;
var ksgmap_marker_key = "";
var ksgmap_marker_center_adjust_x = 0;
var ksgmap_marker_center_adjust_y = 0;
var ksgmap_mapInfo_point_format = "%lat% / %lng%";
var ksgmap_mapInfo_point_base = 60;
var ksgmap_mapInfo_point_base10_decimalDigit = 5;
var ksgmap_mapInfo_point_base60_decimalDigit = 2;
var ksgmap_mapInfo_point_base60_language = "jp";
var ksgmap_mapInfo_point_enableType = "category,item,location";
var ksgmap_search_dic_synonym = "";
var ksgmap_search_narrow_message = 1;
var ksgmap_search_geocoding = 1;
var ksgmap_search_geocoding_joinPrefix = "";
var ksgmap_design_mapLiquidWidth = 0;
var ksgmap_design_mapLiquidHeight = 0;
var ksgmap_limit_dragging = 0;
var ksgmap_limit_zoomByMouseWheel = 0;
var ksgmap_limit_operateByKeyboard = 0;
var ksgmap_limit_zoom_max = 99;
var ksgmap_limit_zoom_min = 0;
var ksgmap_limit_lng_max = 180;
var ksgmap_limit_lng_min = -180;
var ksgmap_limit_lat_max = 90;
var ksgmap_limit_lat_min = -90;
var ksgmap_limit_urlArgument = 0;
var ksgmap_limit_userMessage = 0;
var _zMarker = "";
KsGMapDefine();
//--------------------------------------------------------------------------------------------------
//□定義
function KsGMapDefine(){
//ユーザーエージェントを設定
var ua = navigator.userAgent;
if( ua.match( /Opera[\/\s]([0-9]\.[0-9]+)/ ) ){ ksgmap__ua.Opera = parseFloat( RegExp.$1 ); } else { ksgmap__ua.Opera = 0; }
if( ua.match( /MSIE ([0-9]\.[0-9]+)/ ) && !ksgmap__ua.Opera ){ ksgmap__ua.MSIE = parseFloat( RegExp.$1 ); } else { ksgmap__ua.MSIE = 0; }
if( ua.match( /Firefox[\/\s]([0-9]\.[0-9]+)/ ) ){ ksgmap__ua.Firefox = parseFloat( RegExp.$1 ); } else { ksgmap__ua.Firefox = 0; }
if( ua.match( /Netscape[0-9]?[\/\s]([0-9]\.[0-9]+)/ ) ){ ksgmap__ua.Netscape = parseFloat( RegExp.$1 ); } else { ksgmap__ua.Netscape = 0; }
if( ua.match( /Safari/ ) ){ ksgmap__ua.Safari = 1; } else { ksgmap__ua.Safari = 0; }
ksgmap__ua.Gecko = ( ua.match( /Netscape|Firefox/ ) ? true : false );
window.onload = KsGMapInit; //マップ初期化イベントの定義
}
//--------------------------------------------------------------------------------------------------
//□初期化
function KsGMapInit(){
if( ksgmap_debug_mode ){ ksgmap_start_date = new Date(); } //デバッグ:スタート時間を記録
/* 【v3】
//APIのバージョンの取得(たぶんもっとスマートな方法があると思う)
ksgmap_apiversion = ( typeof( G_NORMAL_MAP ) == "object" ? 2 : 1 );
if( ksgmap_apiversion == 1 ){ return KsGMapCommon.Error.trigger( "本バージョンの KsGMap は Google Maps API Ver2 でのみ動作します。\nGoogle の APIキーを入力する所の v=1 を v=2 にして下さい。" , 0 , 3 ); }
*/
//HTMLの初期化処理及び、非マップ環境の場合は終了
if( !ksgmap_import_flag && !KsGMapInit_html() ){ return; }
//URLに引数がある場合
if( location.search ){ KsGMapInit_procUrlArgument(); }
//XMLファイルからデータをインポート(読み込みが完了するまで停止)
if( ( ksgmap_import_file || ksgmap_import_current_file ) && !ksgmap_import_flag ){
if( !ksgmap_import_current_file ){ ksgmap_import_current_file = ksgmap_import_file; }
KsGMapCommon.XML.include( ksgmap_import_path + ksgmap_import_current_file , KsGMapInit_import ); return;
}
//カテゴリに特殊カテゴリを追加
KsGMapDataCategory( "_all" , "-" ); //「すべて表示」の追加
KsGMapDataCategory( "_map" , "-" ); //「マップ内のアイテムを表示」を追加
//コールバック
KsGMapEX.callback( this , arguments );
//フォーカスカテゴリのセット
if( ksgmap_default_category && ksgmap_category[ ksgmap_default_category ] ){ ksgmap_focus_category = ksgmap_default_category; } //通常処理
else if( ksgmap_default_item && ksgmap_item[ ksgmap_default_item ] ){ ksgmap_focus_category = ksgmap_item[ ksgmap_default_item ].category; } //デフォルトアイテム指定
else { ksgmap_focus_category = KsGMapCommon.Array.keys( ksgmap_category )[ 2 ]; } //それでもダメな場合、最初のカテゴリにする(0は_all、1は_map)
//オブジェクトを初期化
window.KsGMapMapInitResult = KsGMapMap.init();
}
function KsGMapInit2(){
var KsGMapMapInitResult = window.KsGMapMapInitResult;
window.KsGMapMapInitResult = null;
KsGMapCategoryNavi.init();
KsGMapItemNavi.init();
KsGMapSearch.init();
KsGMapSort.init();
//アイコンのデフォルト値が未定義の場合定義する
if( !ksgmap_marker[ "_default" ] ){ KsGMapDataMarker( "_default" , "http://www.google.com/mapfiles/marker%count%.png" , "http://www.google.com/mapfiles/shadow50.png" , ",[A-Z]" , 20 , 34 , 37 , 34 , 9 , 34 , 9 , 2 ); }
//センターマーカーが定義されている場合、センターマーカーを作成する
if( ksgmap_marker[ "_center" ] ){ ksgmap_marker[ "_center" ].marking(); }
/*
//HTML処理 【v3】 1.20 では非表示
if( ksgmap_poweredByKsGMap_time ){ //Powerd By KsGMap の表示
KsGMapCommon.HTML.setDisplay( "ksgmap--map-poweredByKsGMap" , 1 );
setTimeout( "KsGMapCommon.HTML.setDisplay( \"ksgmap--map-poweredByKsGMap\" , 0 );" , ( ksgmap_poweredByKsGMap_time * 1000 ) - 500 ); //一定時間後消去
}
*/
//マップ情報の表示
if( ksgmap_html_mapInfo_point ){ KsGMapInfo.dispPoint( KsGMapMapInitResult.defaultPoint.lng() , KsGMapMapInitResult.defaultPoint.lat() ); }
//特殊カテゴリのラベルを設定
if( ksgmap_category_all ){ ksgmap_category[ "_all" ].name = ksgmap_category_all_label; }
if( ksgmap_category_map ){ ksgmap_category[ "_map" ].name = ksgmap_category_map_label.replace( "%item_name%" , ksgmap_item_name ); }
//初期カテゴリに移動 (初期のカテゴリ変更は既に移動済みの為、移動をオフにしておく
if( !ksgmap_focus_category ){ ksgmap_focus_category = KsGMapInit_getDefaultCategory(); } //初期カテゴリ取得を試みる
if( ksgmap_focus_category ){ ksgmap_category[ ksgmap_focus_category ].change( "MOVE:off INIT" ); }
//カテゴリナビゲーションの設置
KsGMapCategoryNavi.create();
//初期メッセージが存在する場合、表示させる
var temp_message = KsGMapCommon.Variable.getTempValue( "urlArgumentUserMessage" );
if( temp_message ){
var layoutSize = KsGMapCommon.HTML.getLayoutSize( temp_message );
var opt = {
content : "" + temp_message + "
",
position: KsGMapMapInitResult.defaultPoint
};
var infoWindow = new google.maps.InfoWindow(opt);
infoWindow.open(KsGMapMap.gmap);
}
//初期化終了処理
KsGMapInit_finish();
}
//□初期化終了処理
function KsGMapInit_finish(){
KsGMapEX.callback( this , arguments ); //コールバック
//初期アイテムが存在する場合、それを開く
if( ksgmap_default_item ){ ksgmap_item[ ksgmap_default_item ].openInfoWindowByItemNavi(); }
//デバッグモードの時はタイマーを切る
if( ksgmap_debug_mode ){ KsGMapInit_debug_timer(); }
}
//□初期化 - URL引数の処理
function KsGMapInit_procUrlArgument(){
if( ksgmap_limit_urlArgument ){ return ; } //制限
var urlArgumentFlag = 0;
//URLの引数で座標が指定されている場合( &lng=[lng]&lat=[lat] )
if( location.search.match( /(?=.*[&\?]lng=([0-9\.-]+))(?=.*[&\?]lat=([0-9\.-]+))/ ) ){
ksgmap_default_lng = parseFloat( RegExp.$1 );
ksgmap_default_lat = parseFloat( RegExp.$2 );
ksgmap_default_category = ""; ksgmap_default_item = ""; //カテゴリとアイテムをキャンセル
urlArgumentFlag = 1;
}
//URLの引数でカテゴリが指定されている場合( &category=[category_id] )
if( location.search.match( /[&\?]category=([a-zA-Z0-9_-]+)/ ) ){
ksgmap_default_category = RegExp.$1;
ksgmap_default_item = ""; //アイテムが指定されていてもキャンセル
urlArgumentFlag = 1;
}
//URLの引数でアイテムが指定されている場合( &item=[item_id] )
if( location.search.match( /[&\?]item=([a-zA-Z0-9_\.-]+)/ ) ){
ksgmap_default_item = RegExp.$1;
ksgmap_default_category = ( ksgmap_item[ ksgmap_default_item ] ? ksgmap_item[ ksgmap_default_item ].category : "" ); //カテゴリは指定したアイテムのカテゴリとする
urlArgumentFlag = 1;
}
//URLの引数で尺度が指定されている場合( &zoom=[zoom level] )
if( location.search.match( /[&\?]zoom=([0-9]{1,2})/ ) ){
ksgmap_default_zoom = parseInt( RegExp.$1 );
urlArgumentFlag = 1;
}
//URLの引数でタイプが指定されている場合( &type=satellite )
if( location.search.match( /[&\?]type=(map|satellite|hybrid)/ ) ){
ksgmap_default_type = RegExp.$1;
urlArgumentFlag = 1;
}
//URLの引数でXMLファイルが指定されている場合( &import=hogehoge.xml )
if( location.search.match( /[&\?]import=([0-9a-zA-Z!$%&()+,;=@\[\]^_=`{}~\.-]+)/ ) ){
ksgmap_import_current_file = RegExp.$1;
urlArgumentFlag = 1;
}
//ユーザーメッセージが指定されている場合( &message=hogehoge )
if( location.search.match( /[&\?]message=([^&\?]+)/ ) && !ksgmap_limit_userMessage ){
KsGMapInfo.userMessageEditor.message = RegExp.$1;
var temp_userMessage = decodeURIComponent( RegExp.$1 );
temp_userMessage = KsGMapCommon.HTML.encode( temp_userMessage ); //エンコードしてタグを無効化
temp_userMessage = temp_userMessage.replace( "|" , " " ); // | を改行に変換
KsGMapCommon.Variable.setTempValue( temp_userMessage , "urlArgumentUserMessage" );
}
//制限のチェック
if( ksgmap_default_lng < ksgmap_limit_lng_min || ksgmap_default_lng > ksgmap_limit_lng_max || ksgmap_default_lat < ksgmap_limit_lat_min || ksgmap_default_lat > ksgmap_limit_lat_max ){ //制限のチェック
ksgmap_default_lng = ( ( [ ksgmap_default_lng , ksgmap_limit_lng_min , ksgmap_limit_lng_max ] ).sort() )[ 1 ];
ksgmap_default_lat = ( ( [ ksgmap_default_lat , ksgmap_limit_lat_min , ksgmap_limit_lat_max ] ).sort() )[ 1 ];
}
if( ksgmap_default_zoom < ksgmap_limit_zoom_min ){ ksgmap_default_zoom = ksgmap_limit_zoom_min; }
if( ksgmap_default_zoom > ksgmap_limit_zoom_max ){ ksgmap_default_zoom = ksgmap_limit_zoom_max; }
//指定があった場合は、このページのURL欄にそれを写す
if( urlArgumentFlag ){ KsGMapInfo.setURL( "location" ); }
}
//□初期化 - インポート処理
function KsGMapInit_import( xmlDoc ){
KsGMapDataImportXML( xmlDoc );
//初期化を再開する
ksgmap_import_flag = 1;
KsGMapInit();
}
//□初期化 - HTMLの初期化
function KsGMapInit_html(){
var temp_gmap = document.getElementById( ksgmap_html_googleMap );
var insertTag = "";
var style_displayNone = ( !ksgmap__ua.Opera ? "display: none;" : "visibility: hidden;" ); //Operaはdisplayが制御できない為
//リキッドデザインの指定がある場合
if( ksgmap_design_mapLiquidWidth || ksgmap_design_mapLiquidHeight ){
var windowSize = KsGMapCommon.HTML.getWindowSize();
if( ksgmap_design_mapLiquidWidth ){ temp_gmap.style.width = String( windowSize.width + ksgmap_design_mapLiquidWidth ) + "px"; }
if( ksgmap_design_mapLiquidHeight ){ temp_gmap.style.height = String( windowSize.height + ksgmap_design_mapLiquidHeight ) + "px"; }
}
//センターマーカーがある場合、2で割り切れる数にしておく
if( ksgmap_marker[ "_center" ] && temp_gmap.offsetWidth % 2 == 1 ){ temp_gmap.style.width = String( temp_gmap.offsetWidth - 1 ) + "px"; }
if( ksgmap_marker[ "_center" ] && temp_gmap.offsetHeight % 2 == 1 ){ temp_gmap.style.height = String( temp_gmap.offsetHeight - 1 ) + "px"; }
//マップにメッセージを表示
/* 【v3】
if( typeof( GBrowserIsCompatible ) == "undefined" ){ var mapMessage = "マップをご利用になるには、インターネットに接続されている必要があります。"; var r_value = false; }
else if( !GBrowserIsCompatible() ){ var mapMessage = "ご利用のブラウザ、環境ではマップをご利用になることはできません。"; var r_value = false; }
else { var mapMessage = "読み込み中..."; var r_value = true; }
*/
var mapMessage = "読み込み中..."; var r_value = true;
KsGMapCommon.HTML.write( "ksgmap--map-message" , mapMessage );
//マップ外センターマーカー
if( ksgmap_marker[ "_center" ] ){
var centerMarkert_style_icon = "position: absolute; z-index: 101; width: " + ksgmap_marker[ "_center" ].width + "px; height: " + ksgmap_marker[ "_center" ].height + "px; " + style_displayNone + " ";
var centerMarkert_style_shadow = "position: absolute; z-index: 100; width: " + ksgmap_marker[ "_center" ].swidth + "px; height: " + ksgmap_marker[ "_center" ].sheight + "px; " + style_displayNone + " ";
if( ksgmap__ua.MSIE && ksgmap__ua.MSIE < 7.0 ){
centerMarkert_style_icon += " filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + ksgmap_marker[ "_center" ].iconfile + "',sizingmethod=image);"
centerMarkert_style_shadow += " filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + ksgmap_marker[ "_center" ].siconfile + "',sizingmethod=image);"
insertTag = "
\n";
if( ksgmap_marker[ "_center" ].giconS ){ insertTag += "
\n"; }
} else {
insertTag = " \n";
if( ksgmap_marker[ "_center" ].giconS ){ insertTag += " \n"; }
}
}
//情報バー用HTML
var temp_css = "left: " + ( temp_gmap.offsetLeft + 10 ) + "px; top: " + ( temp_gmap.offsetHeight - 70 ) + "px; " + style_displayNone;
insertTag += KsGMapMap.infoBar.html.replace( "%css%" , temp_css );
/*
//Powerd By KsGMap 表記 【v3】 1.20 では非表示
if( ksgmap_poweredByKsGMap_time ){
insertTag += "\n";
}
*/
//サイズ測定用HTML
insertTag += "
\n";
//デバッグ用HTML
if( ksgmap_debug_mode ){
KsGMapCommon.HTML.write( ksgmap_html_debug , "
" );
KsGMapCommon.HTML.setDisplay( ksgmap_html_debug , 1 );
}
//HTMLの追加(マップのあるエリア)
if( ksgmap__ua.MSIE ){ temp_gmap.parentElement.innerHTML = temp_gmap.parentElement.innerHTML + insertTag; }
else { temp_gmap.parentNode.innerHTML = temp_gmap.parentNode.innerHTML + insertTag; }
var insertTag = ""; //ここから先は、HTMLのBODY直下のHTML
//ポップアップの影用
insertTag += "
\n";
document.getElementsByTagName( "body" )[ 0 ].innerHTML = document.getElementsByTagName( "body" )[ 0 ].innerHTML + insertTag;
return r_value;
}
//□初期化 - ハイブリッドが利用可能かチェックする
function KsGMapInit_checkHybridEnable(){
return true; //【v3】
}
//□初期化 - 初期カテゴリの取得(失敗することもある)
function KsGMapInit_getDefaultCategory(){
var result_array = KsGMapCommon.Map.getNearData( ksgmap_category , "all" , 1 );
if( result_array ){ var result = result_array[ 0 ]; }
return result;
}
//□初期化 - デバッグで時間を計る
function KsGMapInit_debug_timer(){
if( ksgmap__ua.Firefox ){
for ( i = 0; i < document.images.length; i++ ){ //画像が読み込まれるまでループ
if( !document.images[ i ].complete ){ setTimeout( "KsGMapInit_debug_timer()" , 100 ); return ; }
}
}
var ksgmap_end_date = new Date();
KsGMapCommon.HTML.write( "ksgmap--debug-timer" , ( ( ksgmap_end_date.getTime() - ksgmap_start_date.getTime() ) / 1000 ) + " 秒" );
}
//--------------------------------------------------------------------------------------------------
//□マップ
var KsGMapMap = new function(){
this.id = "";
this.gmap = {};
this.geocoder = null;
this.inited = 0;
this.dummyMarker = null;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.event = {}; //イベント
this.event.moveCompletionID = "";
this.event.moveStart = KsGMapMap_event_moveStart;
this.event.moveEnd = KsGMapMap_event_moveEnd;
this.event.moveCompletion = KsGMapMap_event_moveCompletion;
this.event.resize = KsGMapMap_event_resize;
this.event.zoomEnd = KsGMapMap_event_zoomEnd;
this.event.infoWindowOpen = KsGMapMap_event_infoWindowOpen;
this.event.infoWindowClose = KsGMapMap_event_infoWindowClose;
// this.event.mouseWheel = KsGMapMap_event_mouseWheel;
// this.event.keyDown = KsGMapMap_event_keyDown;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.infoBar = {}; //情報バー
this.infoBar.clear = KsGMapMap_infoBar_clear;
this.infoBar.display = KsGMapMap_infoBar_display;
this.infoBar.opacity = 0.7;
this.infoBar.html = "
\n";
this.infoBar.message = {};
// - - - - - - - - - - - - - - - - - - - - - - - -
this.infoBar.message.limitPoint = "表示範囲を超えました。これ以上、移動することはできません。";
this.infoBar.message.limitZoomMin = "表示範囲を超えました。これ以上、広域にズームすることはできません。";
this.infoBar.message.limitZoomMax = "表示範囲を超えました。これ以上、詳細にズームすることはできません。";
this.infoBar.message.waitMarking = "しばらくお待ち下さい。";
this.infoBar.message.waitLoading = "しばらくお待ち下さい。";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.infoWindow = {}; //情報ウィンドウ
this.infoWindow.tabPage = 1;
this.infoWindow.tabLabel = [];
this.infoWindow.currentItemID = "";
this.infoWindow.currentMarker = "";
this.infoWindow.currentTabPage = null;
this.infoWindow.enabled = true;
this.infoWindow.iconMoveCenterFile = "ksgmap_infowindow_movecenter.png";
this.infoWindow.iconZoomDetailFile = "ksgmap_infowindow_zoomdetail.png";
this.infoWindow.open = KsGMapMap_infoWindow_open;
this.infoWindow.close = KsGMapMap_infoWindow_close;
this.infoWindow.changeTab = KsGMapMap_infoWindow_changeTab;
this.infoWindow.moveCenter = KsGMapMap_infoWindow_moveCenter;
this.infoWindow.zoomDetail = KsGMapMap_infoWindow_zoomDetail;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.userControl = {}; //ユーザーコントロール
this.userControl.marker = new KsGMapMap_userControl_marker;
this.userControl.marker.type = "marker";
this.userControl.centerMarker = new KsGMapMap_userControl_marker; //マーカーと共通
this.userControl.centerMarker.type = "centerMarker"; //だから←で区別する
this.userControl.mouseWheel = {};
this.userControl.mouseWheel.status = 1;
this.userControl.mouseWheel.reverse = 0;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.zMarking = {}; //Zマーキング
this.zMarking.dformerDigit = [ -1 , -2 , -1 , -1 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 2 , 2 , 2 , 3 , 3 , 4 , 4 , 5 , 5, 5, 5 ]; //尺度対小数点以下桁数
// this.zMarking.dformerDigit = new Array( 4 , 4 , 3 , 3 , 2 , 2 , 2 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , -1 , -1 , -2 , -2 ); //尺度対小数点以下桁数
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.init = KsGMapMap_init;
}
//□マップ - 初期化
function KsGMapMap_init(){
var gmapInitResult = KsGMapMap_init_gmap(); //Google Maps関連
KsGMapMap_init_event(); //イベント
KsGMapMap.inited = 1;
//Zマーキング機能がオフの場合
if( !ksgmap_zmarking ){ this.zMarking.dformerDigit = [ 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ]; }
return gmapInitResult;
}
//□マップ - 初期化 - Google Maps関連
function KsGMapMap_init_gmap(){
//【v3】全面的に変更
var G = google.maps;
var gOpt = {};
if(ksgmap_control_zoom == 1){
gOpt.panControl = true;
gOpt.zoomControl = true;
gOpt.zoomControlOptions = { style: G.ZoomControlStyle.LARGE };
} else if (ksgmap_control_zoom == 2) {
gOpt.panControl = true;
gOpt.zoomControl = true;
gOpt.zoomControlOptions = { style: G.ZoomControlStyle.SMALL };
} else if (ksgmap_control_zoom == 3) {
gOpt.zoomControl = true;
gOpt.zoomControlOptions = { style: G.ZoomControlStyle.SMALL };
}
if( ksgmap_control_type){
gOpt.mapTypeControl = true;
}
if( ksgmap_control_scale){
gOpt.scaleControl = true;
}
if( ksgmap_control_overviewMap ){
gOpt.overviewMapControl = true;
}
if (ksgmap_control_streetView == 0) {
gOpt.streetViewControl = false;
}
//初期設定
if( ksgmap_default_item ){ var defaultPoint = new G.LatLng( ksgmap_item[ ksgmap_default_item ].lat , ksgmap_item[ ksgmap_default_item ].lng ); } //アイテム指定
else if( ksgmap_default_lng && ksgmap_default_lat ){ var defaultPoint = new G.LatLng( ksgmap_default_lat , ksgmap_default_lng ); } //座標指定
else if( ksgmap_focus_category ){ var defaultPoint = new G.LatLng( ksgmap_category[ ksgmap_focus_category ].lat , ksgmap_category[ ksgmap_focus_category ].lng ); } //カテゴリ指定
else { var defaultPoint = new G.LatLng( 35.68402 , 139.77448 ); } //その他
gOpt.center = defaultPoint;
KsGMapMap.currentZoom = gOpt.zoom = ksgmap_default_zoom;
/*
if( ksgmap_default_type == "hybrid" && KsGMapInit_checkHybridEnable() ){ KsGMapMap.gmap.setMapType( G_HYBRID_MAP ); } //マップをハイブリッド(デュアル)
if( ksgmap_default_type == "satellite" ){ KsGMapMap.gmap.setMapType( G_SATELLITE_MAP ); } // 〃 サテライトにする
*/
//制限事項
if( ksgmap_limit_dragging ){ gOpt.draggable = false; }
KsGMapMap.gmap = new G.Map( document.getElementById( ksgmap_html_googleMap ), gOpt ); //Google Maps APIのマップを定義
//ジオコーダーをセット
KsGMapMap.geocoder = new google.maps.Geocoder();
//アンロード時に、リソースを開放する
// window.onunload = GUnload;
var gmapInitResult = {};
gmapInitResult.defaultPoint = defaultPoint;
return gmapInitResult;
}
//□マップ - 初期化 - イベント
function KsGMapMap_init_event(){
var obj_gmap = document.getElementById( ksgmap_html_googleMap );
//Google Maps API関連イベント
google.maps.event.addListener(KsGMapMap.gmap, "dragstart", KsGMapMap.event.moveStart);
google.maps.event.addListener(KsGMapMap.gmap, "dragend", KsGMapMap.event.moveEnd);
google.maps.event.addListener(KsGMapMap.gmap, "zoom_changed", KsGMapMap.event.zoomEnd);
google.maps.event.addListenerOnce(KsGMapMap.gmap, "tilesloaded", KsGMapInit2);
/*
GEvent.addListener( KsGMapMap.gmap , "movestart" , KsGMapMap.event.moveStart );
GEvent.addListener( KsGMapMap.gmap , "moveend" , KsGMapMap.event.moveEnd );
GEvent.addListener( KsGMapMap.gmap , "zoomend" , KsGMapMap.event.zoomEnd );
GEvent.addListener( KsGMapMap.gmap , "infowindowopen" , KsGMapMap.event.infoWindowOpen ); //★
GEvent.addListener( KsGMapMap.gmap , "infowindowclose" , KsGMapMap.event.infoWindowClose ); //★
*/
var oldIE = (window.attachEvent ? true : false);
//ウィンドウ(リサイズ)
if( oldIE ){ window.attachEvent( "onresize" , KsGMapMap.event.resize ); }
else if( ksgmap__ua.Safari ){ window.onresize = KsGMapMap.event.resize; }
else { window.addEventListener( "resize" , KsGMapMap.event.resize , false ); }
//クリック(フォーカスを当てる)
if(oldIE){ obj_gmap.attachEvent( "onclick" , function(){ obj_gmap.focus(); } ); }
/*
//マウスホイールのイベントをくっつける
if(oldIE){ obj_gmap.attachEvent( "onmousewheel" , KsGMapMap.event.mouseWheel ); }
else if( ksgmap__ua.Safari ){ obj_gmap.onmousewheel = KsGMapMap.event.mouseWheel; }
else { obj_gmap.addEventListener( "DOMMouseScroll" , KsGMapMap.event.mouseWheel , false ); }
*/
//キーボード操作
// if( ksgmap__ua.MSIE ){ obj_gmap.attachEvent( "onkeydown" , KsGMapMap.event.keyDown ); }
// else { document.getElementById( ksgmap_html_search_itemName_textField ).addEventListener( "keydown" , KsGMapFunc_operateByKeyboard , false ); }
}
//□マップ - イベント - 移動開始
function KsGMapMap_event_moveStart(){
var center = KsGMapMap.gmap.getCenter();
center.x = center.lng(); center.y = center.lat(); //【v3】
KsGMapEX.callback( this , arguments , center.x , center.y ); //コールバック
if( ksgmap_marker[ "_center" ] ){ ksgmap_marker[ "_center" ].movestart(); } //センターマーカーの切り替え
//完了イベントのタイムアウト処理
if( KsGMapMap.event.moveCompletionID ){
clearTimeout( KsGMapMap.event.moveCompletionID );
KsGMapMap.event.moveCompletionID = "";
}
}
//□マップ - イベント - 移動終了
function KsGMapMap_event_moveEnd(){
var center = KsGMapMap.gmap.getCenter();
center.x = center.lng(); center.y = center.lat(); //【v3】
KsGMapEX.callback( this , arguments , center.x , center.y ); //コールバック
//制限関連
if( center.x < ksgmap_limit_lng_min || center.x > ksgmap_limit_lng_max || center.y < ksgmap_limit_lat_min || center.y > ksgmap_limit_lat_max ){
var lng = ( ( [ center.x , ksgmap_limit_lng_min , ksgmap_limit_lng_max ] ).sort() )[ 1 ];
var lat = ( ( [ center.y , ksgmap_limit_lat_min , ksgmap_limit_lat_max ] ).sort() )[ 1 ]; //移動先の決定
KsGMapMap.gmap.panTo( new google.maps.LatLng( lat , lng ) );
KsGMapMap.infoBar.display( KsGMapMap.infoBar.message.limitPoint , 5000 ); //情報バーにメッセージ表示
return ;
}
if( ksgmap_marker[ "_center" ] ){ ksgmap_marker[ "_center" ].marking(); } //センターマーカーの移動
//完了イベントのタイムアウト処理
if( KsGMapMap.event.moveCompletionID ){ clearTimeout( KsGMapMap.event.moveCompletionID ); }
KsGMapMap.event.moveCompletionID = setTimeout( "KsGMapMap.event.moveCompletion( " + center.x + " , " + center.y + " )" , 750 );
}
//□マップ - イベント - 移動完了(移動終了0.75秒後)
function KsGMapMap_event_moveCompletion( lng , lat ){
KsGMapEX.callback( this , arguments , lng , lat ); //コールバック
var temp = String( lng ).split( "." ); var str_lng = temp[ 0 ] + "." + temp[ 1 ].substring( 0 , 5 ); //小数点以下5桁にする
var temp = String( lat ).split( "." ); var str_lat = temp[ 0 ] + "." + temp[ 1 ].substring( 0 , 5 );
KsGMapInfo.setURL( "point" , str_lng , str_lat ); //「このページのURL」をセット
if( ksgmap_html_mapInfo_point ){ KsGMapInfo.dispPoint( lng , lat ); } //「経度/緯度」
//常に現在地からの距離順ソートがオンの場合 もしくは マップ内のアイテム表示の場合、リマーキングする
if( ( KsGMapSort.distance && KsGMapInfo.urlPriorityType != "item" ) || ksgmap_focus_category == "_map" ){
ksgmap_category[ ksgmap_focus_category ].marking();
}
//自動ズーム(マップ上のアイテムをすべて表示)が有効かチェック
if( ksgmap_html_itemNavi_autoZoom ){ KsGMapItemNavi.checkAutoZoom(); }
//デバッグの座標
if( ksgmap_debug_mode ){ KsGMapCommon.HTML.write( "ksgmap--debug-point" , ( str_lng + " , " + str_lat + " lng=\"" + str_lng + "\" lat=\"" + str_lat + "\"" + " z=" + KsGMapMap.gmap.getZoom() ) ); }
//「Google ローカル」の為のコピー
if( ksgmap_html_googleLocal ){ document.getElementById( ksgmap_html_googleLocal ).value = String( lat ) + "," + String( lng ); }
KsGMapMap.event.moveCompletionID = "";
}
//□マップ - イベント - リサイズ
function KsGMapMap_event_resize(){
var windowSize = KsGMapCommon.HTML.getWindowSize();
KsGMapEX.callback( this , arguments , windowSize.width , windowSize.height ); //コールバック
var map_width = parseInt( document.getElementById( ksgmap_html_googleMap ).offsetWidth );
var map_height = parseInt( document.getElementById( ksgmap_html_googleMap ).offsetHeight );
//リキッドデザインの指定がある場合
if( ksgmap_design_mapLiquidWidth ){ map_width = windowSize.width + ksgmap_design_mapLiquidWidth; }
if( ksgmap_design_mapLiquidHeight ){ map_height = windowSize.height + ksgmap_design_mapLiquidHeight; }
//センターマーカーがある場合、2で割り切れる数にしておく
if( ksgmap_marker[ "_center" ] && map_width % 2 == 1 ){ map_width--; }
if( ksgmap_marker[ "_center" ] && map_height % 2 == 1 ){ map_height--; }
if( ksgmap_design_mapLiquidWidth ){ document.getElementById( ksgmap_html_googleMap ).style.width = String( map_width ) + "px"; }
if( ksgmap_design_mapLiquidHeight ){ document.getElementById( ksgmap_html_googleMap ).style.height = String( map_height ) + "px"; }
if( ksgmap_marker[ "_center" ] ){ ksgmap_marker[ "_center" ].movestart(); } //センターマーカーの移動
// KsGMapMap.gmap.checkResize(); //Google Maps API自体を更新 【v3】
}
//□マップ - イベント - ズーム
function KsGMapMap_event_zoomEnd(newZoomLevel ){
var oldZoomLevel = KsGMapMap.currentZoom;
var newZoomLevel = KsGMapMap.currentZoom = KsGMapMap.gmap.getZoom();
KsGMapEX.callback( this , arguments , oldZoomLevel, newZoomLevel ); //コールバック
if( newZoomLevel < ksgmap_limit_zoom_min ){ KsGMapMap.gmap.setZoom( ksgmap_limit_zoom_min ); KsGMapMap.infoBar.display( KsGMapMap.infoBar.message.limitZoomMin , 5000 ); return ; } //制限
if( newZoomLevel > ksgmap_limit_zoom_max ){ KsGMapMap.gmap.setZoom( ksgmap_limit_zoom_max ); KsGMapMap.infoBar.display( KsGMapMap.infoBar.message.limitZoomMax , 5000 ); return ; }
//マーキングしなおす(尺度対小数点以下桁数が異なる場合のみ)
if( KsGMapMap.zMarking.dformerDigit[ oldZoomLevel ] != KsGMapMap.zMarking.dformerDigit[ newZoomLevel ] ){
if (ksgmap_category[ ksgmap_focus_category ]) {
ksgmap_category[ ksgmap_focus_category ].marking( "" , "TYPE:zoom" );
}
}
}
//□マップ - イベント - 情報ウィンドウが開く
function KsGMapMap_event_infoWindowOpen(){
var temp_id = KsGMapMap.infoWindow.currentItemID;
if( !temp_id ){ KsGMapMap.infoWindow.currentItemID = "_unknown"; }
KsGMapEX.callback( this , arguments , temp_id ); //コールバック
KsGMapInfo.setURL( "item" , temp_id ); //「このページのURL」をセット
if( ksgmap_marker[ "_center" ] ){ ksgmap_marker[ "_center" ].remove(); } //センターマーカーを消す
}
//□マップ - イベント - 情報ウィンドウが閉じる
function KsGMapMap_event_infoWindowClose(){
var temp_id = KsGMapMap.infoWindow.currentItemID;
KsGMapEX.callback( this , arguments , temp_id ); //コールバック
KsGMapMap.infoWindow.currentItemID = "";
KsGMapInfo.urlPriorityType = "";
if( ksgmap_marker[ "_center" ] ){ ksgmap_marker[ "_center" ].marking(); } //センターマーカーの表示
}
/*
//□マップ - イベント - マウスホイール 【v3】公式が採用
function KsGMapMap_event_mouseWheel( event ){
}
//□マップ - イベント - キー操作 【v3】公式が採用
function KsGMapMap_event_keyDown( event ){
}
*/
//□マップ - 情報バー - クリア
function KsGMapMap_infoBar_clear(){
KsGMapEX.callback( this , arguments ); //コールバック
if( !ksgmap__ua.Opera ){ //Opera以外は徐々に透明度が低くなるようにする
var obj = document.getElementById( "ksgmap--map-infobar" );
KsGMapMap.infoBar.opacity = ( KsGMapMap.infoBar.opacity >= 0.1 ? KsGMapMap.infoBar.opacity - 0.1 : 0.7 );
if( ksgmap__ua.MSIE ){ obj.style.filter = "Alpha(opacity=" + String( KsGMapMap.infoBar.opacity * 100 ) + ")"; }
if( ksgmap__ua.Gecko ){ obj.style.MozOpacity = KsGMapMap.infoBar.opacity; }
if( ksgmap__ua.Safari ){ obj.style.opacity = KsGMapMap.infoBar.opacity; }
if( KsGMapMap.infoBar.opacity != 0.7 ){
setTimeout( "KsGMapMap.infoBar.clear();" , 75 );
return;
}
}
KsGMapCommon.HTML.setDisplay( "ksgmap--map-infobar" , 0 );
}
//□マップ - 情報バー - 表示
function KsGMapMap_infoBar_display( value , msec ){
KsGMapEX.callback( this , arguments ); //コールバック
var obj_infoBar = document.getElementById( 'ksgmap--map-infobar' );
obj_infoBar.style.width = String( document.getElementById( ksgmap_html_googleMap ).offsetWidth - 40 ) + "px";
KsGMapCommon.HTML.setDisplay( "ksgmap--map-infobar" , 1 );
obj_infoBar.innerHTML = value;
if( msec ){ setTimeout( "KsGMapMap.infoBar.clear();" , msec ); } //msec後に自動消去
}
//□マップ - 情報ウィンドウ - 開く
function KsGMapMap_infoWindow_open( type , item_id , marker ){
if( !KsGMapMap.infoWindow.enabled ){ return; }
//既に情報ウィンドウが開いている場合は閉じる
if( KsGMapMap.infoWindow.currentItemID ){ KsGMapMap.infoWindow.close(); }
// var tabPage = KsGMapMap.infoWindow.tabPage;
// if( tabPage == undefined ){ tabPage = 1; } //tabPageはタブのページ
KsGMapMap.infoWindow.currentItemID = item_id;
KsGMapMap.infoWindow.currentMarker = marker;
var callback_result = KsGMapEX.callback( this , arguments, type , item_id , marker ); //コールバック
if( callback_result.cancelParentProcess ){ return ; } //コールバック戻り値の処理
//タブの数だけ実行
if( !ksgmap_infoWindow_tab ){ //通常モード
var temp_html = ksgmap_item[ item_id ].getInfoWindowHTML(); //HTMLの取得
temp_html = temp_addFunc( temp_html ); //情報ウィンドウ機能の付加
// marker.openInfoWindowHtml( temp_html ); //情報ウィンドウの表示
var infoWindow = new google.maps.InfoWindow({
content: temp_html
});
infoWindow.open(KsGMapMap.gmap, marker);
KsGMapMap.infoWindow.currentIns = infoWindow;
} else { //タブモード
KsGMapMap.infoWindow.currentTabPage = ksgmap_infoWindow_tab_defaultVisible;
var tabData1 = [], tabData2 = []; var tabLabel = ksgmap_infoWindow_tab.split( "," );
for( var i = 1 ; i <= 2 ; i++ ){
KsGMapMap.infoWindow.tabPage = i;
var temp_html = ksgmap_item[ item_id ].getInfoWindowHTML(); //HTMLの取得
if( !temp_html ){ continue; }
if( i == 1 ){ temp_html = temp_addFunc( temp_html ); } //情報ウィンドウ機能の付加
var cSty = "";
var tSty = "float: left; position: relative; top: -19px; margin: 0 5px 0 5px; padding: 0 3px 0 3px; border-style: solid; border-width: 1px; background-color: #ffffff; cursor: pointer;";
if (ksgmap_infoWindow_tab_defaultVisible == i) { //カレントタブ
cSty += "display: block;";
tSty += "border-color: #ababab #ababab #ffffff #ababab;";
} else { //非カレントタブ
cSty += "display: none;";
tSty += "border-color: #ababab;";
}
var ev = "KsGMapMap.infoWindow.changeTab(" + i + ");";
tabData1.push( "" + tabLabel[i - 1] + "
" );
tabData2.push( "" + temp_html + "
" );
}
var tgSty = "position: absolute; top: -20px; "
var infoWindow = new google.maps.InfoWindow({
content: "" + tabData1.join("") + "
" + tabData2.join("")
});
infoWindow.open(KsGMapMap.gmap, marker);
KsGMapMap.infoWindow.currentIns = infoWindow;
google.maps.event.addListenerOnce(infoWindow, "domready", function() {
var e = document.getElementById("KsGMap--tabGroup");
e.parentNode.style.overflow = "scroll";
e.parentNode.parentNode.style.overflow = "";
});
}
//情報ウィンドウ機能の付加
function temp_addFunc( html ){
var func_html = ""; var func_css_left = 0;
if( ksgmap_infoWindow_func_moveCenter ){ func_html += KsGMapCommon.HTML.makePngTag( ksgmap_image_path + KsGMapMap.infoWindow.iconMoveCenterFile , 40 , 13 , { onclick : "KsGMapMap.infoWindow.moveCenter( event );" , style : "position: absolute; left: " + func_css_left + "px; cursor: pointer;" } , "image" ); func_css_left += 42; }
if( ksgmap_infoWindow_func_zoomDetail ){ func_html += KsGMapCommon.HTML.makePngTag( ksgmap_image_path + KsGMapMap.infoWindow.iconZoomDetailFile , 40 , 13 , { onclick : "KsGMapMap.infoWindow.zoomDetail( event );" , style : "position: absolute; left: " + func_css_left + "px; cursor: pointer;" } , "image" ); func_css_left += 42; }
if( func_html ){ html = "" + func_html + "
" + html; }
return html;
}
}
//□マップ - 情報ウィンドウ - 閉じる
function KsGMapMap_infoWindow_close(){
if (KsGMapMap.infoWindow.currentIns) {
KsGMapMap.infoWindow.currentIns.close();
delete KsGMapMap.infoWindow.currentIns;
}
}
//□マップ - 情報ウィンドウ - センタリング
function KsGMapMap_infoWindow_moveCenter( event ){
var temp = ksgmap_item[ KsGMapMap.infoWindow.currentItemID ];
var lng = ( temp.zCurrentPoint.lng ? temp.zCurrentPoint.lng : temp.lng ) + ( Math.random() / 100000 );
var lat = ( temp.zCurrentPoint.lat ? temp.zCurrentPoint.lat : temp.lat ) + ( Math.random() / 100000 );
KsGMapMap.infoWindow.close();
KsGMapMap.gmap.panTo( new google.maps.LatLng( lat , lng ) ); //センタリング
}
//□マップ - 情報ウィンドウ - ズーム
function KsGMapMap_infoWindow_zoomDetail( event ){
var temp = ksgmap_item[ KsGMapMap.infoWindow.currentItemID ].zBrother; //範囲はそのアイテムとZマーキングが同様のもの
var map_point = new KsGMapPoint(); //マップ内にすべて納めるようにする
for( var i = 0 ; i < temp.length ; i++ ){ map_point.addPoint( ksgmap_item[ temp[ i ] ].lng , ksgmap_item[ temp[ i ] ].lat ); }
KsGMapMap.infoWindow.close();
map_point.moveCenterAndZoom();
}
//□マップ - 情報ウィンドウ - タブの変更
function KsGMapMap_infoWindow_changeTab( no ){
var cTP = KsGMapMap.infoWindow.currentTabPage;
if (cTP !== no) {
var oldTabElm = document.getElementById("KsGMap--tab" + cTP);
var newTabElm = document.getElementById("KsGMap--tab" + no);
var oldContElm = document.getElementById("KsGMap--tabContent" + cTP);
var newContElm = document.getElementById("KsGMap--tabContent" + no);
oldContElm.style.display = "none";
newContElm.style.display = "block";
oldTabElm.style.borderColor = "#ababab";
newTabElm.style.borderColor = "#ababab #ababab #ffffff #ababab";
KsGMapMap.infoWindow.currentTabPage = no;
}
}
//□マップ - ユーザーコントロール - マーカー
function KsGMapMap_userControl_marker(){
this.type = "";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.visibility = 1;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.changeVisibility = KsGMapMap_userControl_marker_changeVisibility;
}
//□マップ - ユーザーコントロール - マーカー - 表示の切り替え
function KsGMapMap_userControl_marker_changeVisibility( status ){
this.visibility = status;
KsGMapEX.callback( this , arguments , status ); //コールバック
switch( this.type ){
case "marker" : ksgmap_category[ ksgmap_focus_category ].marking(); break; //マーカーを引きなおす
case "centerMarker" : ksgmap_marker[ "_center" ].marking(); break; //センターマーカーをマーキングしなおす
}
}
//--------------------------------------------------------------------------------------------------
//□カテゴリ
function KsGMapCategory( category_id , name , lng , lat , group ){
this.id = category_id;
this.name = name;
this.lng = parseFloat( lng );
this.lat = parseFloat( lat );
this.group = ( group != undefined ? group : "" );
this.defaultItems = [];
this.searchResultItems = [];
this.sortCacheItems = [];
this.markerCount = 0;
this.bounds = { minLng : 180 , maxLng : -180 , minLat : 90 , maxLat : -90 };
if( category_id == "_map" ){
this.cacheItems = "";
}
}
KsGMapCategory.prototype = new function(){
this.setItem = KsGMapCategory_setItem;
this.addSearchResultItems = KsGMapCategory_addSearchResultItems;
this.change = KsGMapCategory_change;
this.clearSearchResultItems = KsGMapCategory_clearSearchResultItems;
this.clearSortCacheItems = KsGMapCategory_clearSortCacheItems;
this.getTargetItems = KsGMapCategory_getTargetItems;
this.getZMarker = KsGMapCategory_getZMarker;
this.marking = KsGMapCategory_marking;
this.sort = KsGMapCategory_sort;
}
var KsGMapCategory_callback = new KsGMapCategory( "" , "" , 0 , 0 , "" ); //コールバック用
//□カテゴリ - アイテムをセット
function KsGMapCategory_setItem( item_id , lng , lat ){
this.defaultItems[ this.defaultItems.length ] = item_id; //初期アイテム一覧
//このカテゴリの範囲を記録
if( this.bounds.minLng > lng ){ this.bounds.minLng = lng; }
if( this.bounds.maxLng < lng ){ this.bounds.maxLng = lng; }
if( this.bounds.minLat > lat ){ this.bounds.minLat = lat; }
if( this.bounds.maxLat < lat ){ this.bounds.maxLat = lat; }
}
//□カテゴリ - 検索結果アイテムの追加
function KsGMapCategory_addSearchResultItems( item_id ){
this.searchResultItems[ this.searchResultItems.length ] = item_id;
}
//□カテゴリ - 変更
function KsGMapCategory_change( option , tid ){ //第3引数TID
if( option == undefined ){ option = ""; }
if( this.id == "-" ){ return ; }
KsGMapItemNavi.page.num = 1; //ページを1にリセット
if( !tid ){ KsGMapEX.callback( this , arguments ); } //コールバック
//ダミーマーカーがある場合、削除
if( KsGMapMap.dummyMarker ){ KsGMapMap.dummyMarker.setMap(null); }
//情報ウィンドウが開いている場合閉じる
if( !option.match( /INIT/ ) ){ KsGMapMap.infoWindow.close(); }
//座標を記録する為のオブジェクト
if( !tid ){
var map_point = new KsGMapPoint();
} else {
var temp = KsGMapCommon.Variable.getTempValue( tid , false ); //一時変数から取得
var map_point = temp.map_point; option = temp.option;
}
//距離ソートの場合で、現在地と移動後が異なる場合、移動イベントでマーキングする
if( KsGMapSort.distance ){
var center = KsGMapMap.gmap.getCenter();
center.x = center.lng(); center.y = center.lat(); //【v3】
if( this.lng != center.x || this.lat != center.y ){ option += " MARKING:off ITEMNAVI:off"; }
}
//マーキングする
var result = this.marking( map_point , option , tid );
ksgmap_focus_category = this.id;
if( !result ){ return; } //マーキング失敗(途中終了)の場合、ここでキャンセル
//移動
if( !option.match( /MOVE:off/ ) ){ //オプションでオフになっている場合は、移動しない
var temp_autoCentering = ksgmap_category_autoCentering;
if( option.match( /AUTOCENTERING:([0-9])/ ) ){ temp_autoCentering = parseInt( RegExp.$1 ); } //オプションでセンターとズームがオン
if( map_point && temp_autoCentering ){ //自動センタリング
switch( temp_autoCentering ){
case 1: map_point.moveCenter(); break; //センタリングのみ
case 2: map_point.moveCenterAndZoom(); break; //センタリングとズーム
}
} else if( this.lng && this.lat ){ //通常移動(座標が存在する場合)
KsGMapMap.gmap.panTo( new google.maps.LatLng( this.lat , this.lng ) );
}
map_point = {};
}
//関連処理
KsGMapInfo.setURL( "category" , this.id ); //「このページのURL」をセット
if( ksgmap__ua.MSIE ){ document.getElementById( ksgmap_html_googleMap ).focus(); } //フォーカスをマップにする(IE以外はなぜかエラー)
}
//□カテゴリ - 検索結果アイテムのクリア
function KsGMapCategory_clearSearchResultItems(){
this.searchResultItems = [];
}
//□カテゴリ - ソートキャッシュアイテムのクリア
function KsGMapCategory_clearSortCacheItems(){
this.sortCacheItems = [];
}
//□カテゴリ - アイテム一覧の取得
function KsGMapCategory_getTargetItems(){
//すべてのカテゴリのアイテム一覧を取得
var targetItems = [];
var callback_result = KsGMapEX.callback( this , arguments ); //コールバック
if( callback_result.cancelParentProcess ){ //コールバック戻り値の処理
return callback_result.returnValue.targetItems;
}
//表示対象
if( this.id == "_all" ){ //すべて表示
//すべてのカテゴリから取得
for( var category_id in ksgmap_category ){/*●_●*/
if( category_id == "clear" || category_id.match( /^_/ ) ){ continue; }
targetItems = targetItems.concat( ( !KsGMapSearch.status ? ksgmap_category[ category_id ].defaultItems : ksgmap_category[ category_id ].searchResultItems ) );
}
} else if( this.id == "_map" ){ //マップ上表示のアイテム
var bounds = KsGMapMap.gmap.getBounds();
var tempSW = bounds.getSouthWest(); var tempNE = bounds.getNorthEast();
tempSW.x = tempSW.lng(); tempSW.y = tempSW.lat(); tempNE.x = tempNE.lng(); tempNE.y = tempNE.lat(); //【v3】
var bound_w = ( tempNE.x - tempSW.x ) / 2; var bound_h = ( tempNE.y - tempSW.y ) / 2;
// var bound_w = ( bounds.maxX - bounds.minX ) / 2; var bound_h = ( bounds.maxY - bounds.minY ) / 2;
for( var category_id in ksgmap_category ){/*●_●*/
if( category_id == "clear" || category_id.match( /^_/ ) ){ continue; }
var c_bounds = ksgmap_category[ category_id ].bounds;
//カテゴリ自体がマップ外の場合は、スキップ
if( ( c_bounds.maxLng < tempSW.x - bound_w ) || ( tempNE.x + bound_w < c_bounds.minLng ) || ( c_bounds.maxLat < tempSW.y - bound_h ) || ( tempNE.y + bound_h < c_bounds.minLat ) ){ continue; }
//マップ内(及び余白)のアイテムのみ追加
var temp_targetItems = ( !KsGMapSearch.status ? ksgmap_category[ category_id ].defaultItems : ksgmap_category[ category_id ].searchResultItems );
for( var i = 0 ; i < temp_targetItems.length ; i++ ){
if( ( ksgmap_item[ temp_targetItems[ i ] ].lng < tempSW.x - bound_w ) || ( tempNE.x + bound_w < ksgmap_item[ temp_targetItems[ i ] ].lng ) || ( ksgmap_item[ temp_targetItems[ i ] ].lat < tempSW.y - bound_h ) || ( tempNE.y + bound_h < ksgmap_item[ temp_targetItems[ i ] ].lat ) ){ continue; }
targetItems[ targetItems.length ] = temp_targetItems[ i ];
}
}
} else { //カテゴリ別
targetItems = ( !KsGMapSearch.status ? this.defaultItems : this.searchResultItems );
}
//ソートもしくは距離ソート
if( KsGMapSort.status || KsGMapSort.distance ){ targetItems = this.sort( targetItems ); }
//ページモードの場合
if( KsGMapItemNavi.page.items ){
var page_num = KsGMapItemNavi.page.num;
var page_items = KsGMapItemNavi.page.items;
KsGMapItemNavi.page.qty = Math.ceil( targetItems.length / page_items );
targetItems = targetItems.slice( ( page_num - 1 ) * page_items , page_num * page_items );
}
return targetItems;
}
//□カテゴリ - マーキング
function KsGMapCategory_marking( map_point , option , tid ){
if( option == undefined ){ option = ""; }
//マーキングが多い場合は、その旨のメッセージを表示する処理
if( !tid ){
var targetItems = this.getTargetItems(); //ターゲットを取得
//Zマーカーの取得及び
var zMarker = this.getZMarker( targetItems , map_point );
//20件以上の場合、情報バーにメッセージ表示
if( KsGMapCommon.Array.count( zMarker.zpoint ) >= 20 && KsGMapMap.userControl.marker.visibility && !option.match( /MARKING:off/ ) ){
var temp = {};
temp.targetItems = targetItems; temp.zMarker = zMarker; temp.map_point = map_point; temp.option = option;
var tid = KsGMapCommon.Variable.setTempValue( temp ); //一時変数にセット
KsGMapMap.infoBar.display( KsGMapMap.infoBar.message.waitMarking , 0 ); //情報バーにメッセージ表示
KsGMapItemNavi.clear(); //アイテムナビをクリア
if( map_point ){ setTimeout( "ksgmap_category[ '" + this.id + "' ].change( '" + option + "' , '" + tid + "' );" , 100 ); } //カテゴリ変更
else { setTimeout( "ksgmap_category[ '" + this.id + "' ].marking( 0 , '" + option + "' , '" + tid + "' );" , 100 ); } //マーキングのみ
return false;
}
} else {
var temp = KsGMapCommon.Variable.getTempValue( tid ); //一時変数から取得
var targetItems = temp.targetItems; var zMarker = temp.zMarker;
KsGMapMap.infoBar.clear(); //情報バーをクリア
}
//「マップ内のアイテムを表示」でキャッシュと同一の場合はリマーキングしない
if( this.id == "_map" && zMarker.cacheItems == this.cacheItems ){ return ; } else if( this.id == "_map" ){ this.cacheItems = zMarker.cacheItems; }
//ズームによる移動で、マーカーの個数が変わっていなければマーキングしない
if( !tid && this.id != "_map" && option.match( /TYPE:zoom/ ) && this.markerCount == KsGMapCommon.Array.count( zMarker.zpoint ) && ksgmap_category_autoCentering != 2 ){ return ; }
//一度、マーカーを消して書き直す
for( var i = 0 ; i < ksgmap_current_marker.length ; i++ ){ ksgmap_current_marker[ i ].setMap(null); }
ksgmap_current_marker = [];
//ズーム(尺度対小数点以下桁数)が異なる場合、ズームイベントでマーキングする
if( map_point && ( ksgmap_category_autoCentering == 2 || option.match( /AUTOCENTERING:2/ ) ) && !option.match( /INIT/ ) ){
map_point.setCenterAndZoom();
if( KsGMapMap.zMarking.dformerDigit[ map_point.newZoom ] != KsGMapMap.zMarking.dformerDigit[ KsGMapMap.gmap.getZoom() ] ){ return true; }
}
//マーカーを付加する
if( !option.match( /MARKING:off/ ) ){ //オプションでオフになっている場合はスキップ
for( var zpoint in zMarker.zpoint ){
if( zpoint == "clear" ){ continue; }
//マーカーを付加する(zマーキングでない場合のみ)
ksgmap_item[ zMarker.zpoint[ zpoint ].item_id ].addMarker( zMarker.zpoint[ zpoint ].count , ( zMarker.zpoint[ zpoint ].sumLng / zMarker.zpoint[ zpoint ].qty ) , ( zMarker.zpoint[ zpoint ].sumLat / zMarker.zpoint[ zpoint ].qty ) , zMarker.zpoint[ zpoint ].marker , zMarker.zpoint[ zpoint ].items.length );
}
this.markerCount = KsGMapCommon.Array.count( zMarker.zpoint );
}
//アイテムナビゲーションの作成
if( !option.match( /ITEMNAVI:off/ ) ){ //オプションでオフになっている場合はスキップ
for( var i = 0 ; i < targetItems.length ; i++ ){
var item_id = targetItems[ i ];
var zpoint = zMarker.item2point[ item_id ];
if( this.id == "_map" && !zMarker.zpoint[ zpoint ].flagInMap ){ continue; } //マップ内のアイテムを表示で、マップ外の場合スキップ
KsGMapItemNavi.add( item_id , zMarker.zpoint[ zpoint ].count , zMarker.zpoint[ zpoint ].marker ); //各アイテムのHTML
ksgmap_item[ item_id ].zBrother = zMarker.zpoint[ zpoint ].items; //同じマーカーのを記録しておく
ksgmap_item[ item_id ].zCurrentPoint = { lng : ( zMarker.zpoint[ zpoint ].sumLng / zMarker.zpoint[ zpoint ].qty ) , lat : ( zMarker.zpoint[ zpoint ].sumLat / zMarker.zpoint[ zpoint ].qty ) }; //zマーキングでの座標(アイテムナビからの表示の際に利用)
}
//アイテムナビゲーションの設置
KsGMapItemNavi.make();
}
return true;
}
//□カテゴリ - Zマーカーの取得(ついでにアイテムナビのHTML追加もしている)
function KsGMapCategory_getZMarker( targetItems , map_point ){
var bounds = KsGMapMap.gmap.getBounds();
//アイテム毎に処理
var count = 1;
var zMarker = {}; //Zマーカー変数
zMarker.zpoint = {}; //Zポイント
zMarker.item2point = {}; //item-zpoint対応配列
zMarker.cacheItems = ""; //
for( var i = 0 ; i < targetItems.length ; i++ ){
var item_id = targetItems[ i ];
var zpoint = ksgmap_item[ item_id ].getZPoint(); //Zポイント取得
var marker = ( ksgmap_marker_key ? ksgmap_item[ item_id ].data[ ksgmap_marker_key ] : "" );
if( zMarker.zpoint[ zpoint ] == null ){ //未定義カウンタ
var tempSW = bounds.getSouthWest(); var tempNE = bounds.getNorthEast();
tempSW.x = tempSW.lng(); tempSW.y = tempSW.lat(); tempNE.x = tempNE.lng(); tempNE.y = tempNE.lat(); //【v3】
//Zマーカーを定義
zMarker.zpoint[ zpoint ] = {};
zMarker.zpoint[ zpoint ].item_id = item_id;
zMarker.zpoint[ zpoint ].marker = "";
zMarker.zpoint[ zpoint ].qty = 0;
zMarker.zpoint[ zpoint ].sumLng = 0;
zMarker.zpoint[ zpoint ].sumLat = 0;
zMarker.zpoint[ zpoint ].items = [];
zMarker.zpoint[ zpoint ].flagInMap = ( ( ksgmap_item[ item_id ].lng < tempSW.x ) || ( tempNE.x < ksgmap_item[ item_id ].lng ) || ( ksgmap_item[ item_id ].lat < tempSW.y ) || ( tempNE.y < ksgmap_item[ item_id ].lat ) ? 0 : 1 );
if( this.id != "_map" || zMarker.zpoint[ zpoint ].flagInMap ){ //通常モードもしくは「マップ内のアイテムを表示」でマップ内
zMarker.zpoint[ zpoint ].count = count;
count++;
} else { //「マップ内のアイテムを表示」でマップ外
zMarker.zpoint[ zpoint ].count = 0;
}
}
zMarker.zpoint[ zpoint ].qty++;
zMarker.zpoint[ zpoint ].sumLng += ksgmap_item[ item_id ].lng;
zMarker.zpoint[ zpoint ].sumLat += ksgmap_item[ item_id ].lat
zMarker.zpoint[ zpoint ].items[ zMarker.zpoint[ zpoint ].items.length ] = item_id;
if( ksgmap_marker[ marker ] ){ //アイコンキーに関する処理
if( !zMarker.zpoint[ zpoint ].marker ){ zMarker.zpoint[ zpoint ].marker = marker; } //未定義なら言うこと無し
else if( ksgmap_marker[ marker ].priority == ksgmap_marker[ zMarker.zpoint[ zpoint ].marker ].priority ){ } //同じアイコン
else if( ksgmap_marker[ "_composite" ] ){ zMarker.zpoint[ zpoint ].marker = "_composite"; } //複合アイコンが存在する場合
else if( ksgmap_marker[ marker ].priority < ksgmap_marker[ zMarker.zpoint[ zpoint ].marker ].priority ){ zMarker.zpoint[ zpoint ].marker = marker; } //優先度が高い場合
}
zMarker.cacheItems += item_id + "-" + zMarker.zpoint[ zpoint ].count + " "; //キャッシュ比較用
zMarker.item2point[ item_id ] = zpoint; //item-zpoint対応配列
if( map_point ){ map_point.addPoint( ksgmap_item[ item_id ].lng , ksgmap_item[ item_id ].lat ); } //座標を加える
}
return zMarker;
}
//□カテゴリ - ソート
function KsGMapCategory_sort( targetItems ){
//キャッシュが存在する場合、そっちを使う(但し順序ソート以外)
if( !KsGMapSort.distance && this.id != "_map" && ksgmap_category[ this.id ].sortCacheItems.length ){
return ksgmap_category[ this.id ].sortCacheItems;
}
//距離ソートの場合、現在の座標を取得
if( KsGMapSort.distance ){
var center = KsGMapMap.gmap.getCenter();
center.x = center.lng(); center.y = center.lat(); //【v3】
var lng = center.x; var lat = center.y;
}
//ソート用配列の作成
var search_array = {};
for( var i = 0 ; i < targetItems.length ; i++ ){
if( KsGMapSort.distance ){
search_array[ targetItems[ i ] ] = ksgmap_item[ targetItems[ i ] ].getDistance( lng , lat );
} else {
var temp = ksgmap_item[ targetItems[ i ] ].data[ KsGMapSort.key ];
search_array[ targetItems[ i ] ] = ( KsGMapSort.type == "number" ? parseFloat( temp ) : temp ); //数値の場合は型を変換
}
}
//ソート処理
search_array = KsGMapCommon.Array.sort( search_array , "" , ( !KsGMapSort.distance && KsGMapSort.desc ? "desc" : "" ) );
//戻り値を生成
var result_array = KsGMapCommon.Array.keys( search_array );
//キャッシュする(距離ソートのキャッシュもアイテムナビの並び順でも利用)
this.sortCacheItems = result_array;
return result_array;
}
//--------------------------------------------------------------------------------------------------
//□アイテム
function KsGMapItem( item_id , category_id , name , lng , lat , argJS , argXML ){
this.id = item_id;
this.category = category_id;
this.lng = parseFloat( lng );
this.lat = parseFloat( lat );
this.name = name;
this.distance = 0;
this.zBrother = [];
this.zCurrentPoint = {};
var gData = [];
if( argJS ){ for( var i= 0 ; i < ksgmap_item_argName.length ; i++ ){ gData[ ksgmap_item_argName[ i ] ] = ( argJS[ i ] ? argJS[ i ] : "" ); } } //JavaScriptデータ:連想配列の形にする
if( argXML ){ gData = argXML; } //XMLデータ:になってるからそのまま
this.data = gData;
this.distance = 0;
ksgmap_category[ category_id ].setItem( item_id , this.lng , this.lat );
}
KsGMapItem.prototype = new function(){
this.addMarker = KsGMapItem_addMarker;
this.getDistance = KsGMapItem_getDistance;
this.getInfoWindowHTML = KsGMapItem_getInfoWindowHTML;
this.getZPoint = KsGMapItem_getZPoint;
this.makeHTML = KsGMapItem_makeHTML;
this.moveCenter = KsGMapItem_moveCenter;
this.openInfoWindowByItemNavi = KsGMapItem_openInfoWindowByItemNavi;
}
//□アイテム - マーカーを追加
function KsGMapItem_addMarker( count , zLng , zLat , marker_id , zBrothers ){
if( !KsGMapMap.userControl.marker.visibility ){ return ; } //ユーザーが非表示にしている場合、表示しない
//座標
var lng = ( zLng ? zLng : this.lng ); var lat = ( zLat ? zLat : this.lat );
//アイコン
if( !marker_id || !ksgmap_marker[ marker_id ] ){ marker_id = "_default"; }
var gicon = ksgmap_marker[ marker_id ].gicon, tgicon = {};
for (var t in gicon) {
tgicon[t] = gicon[t];
}
tgicon.url = ksgmap_marker[ marker_id ].iconfile.replace( "%count%" , ( ksgmap_marker[ marker_id ].filesuffix[ count ] ? ksgmap_marker[ marker_id ].filesuffix[ count ] : ksgmap_marker[ marker_id ].filesuffix[ 0 ] ) );
var m = ksgmap_current_marker.length;
var markerOption = {
icon : tgicon ,
title : this.name + ( zBrothers >= 2 ? " 他" : "" ),
position: new google.maps.LatLng( lat , lng ),
map : KsGMapMap.gmap
}
if (ksgmap_marker[ marker_id ].giconS) {
markerOption.shadow = ksgmap_marker[ marker_id ].giconS;
}
ksgmap_current_marker[ m ] = new google.maps.Marker( markerOption ); //マーカーの作成
//イベント設定
var temp_id = this.id;
google.maps.event.addListener(ksgmap_current_marker[ m ] , "click" , function() { //マーカーのイベント(クリック)
if( KsGMapMap.infoWindow.currentItemID == temp_id ){ KsGMapMap.infoWindow.close(); } //同じマーカーなら情報ウィンドウを閉じる
KsGMapMap.infoWindow.open( "marker" , temp_id , ksgmap_current_marker[ m ] );
} );
}
//□アイテム - 現在地からの距離を取得
function KsGMapItem_getDistance( lng , lat ){
var distance = KsGMapCommon.Map.convPointsToDistance( this.lng , this.lat , lng , lat );
this.distance = distance;
return distance;
}
//□アイテム - 情報ウィンドウに表示するHTMLを取得
function KsGMapItem_getInfoWindowHTML(){
var html = ""; var tab = [ "-" , true , false ];
var myZPoint = this.getZPoint(); //自分のZポイントを取得
var temp_html = this.makeHTML();
html = ( typeof( temp_html ) == "object" ? temp_html.html : temp_html ); //HTML
//Zマーキングで重複するアイテム群
var targetItems = this.zBrother;
for( var i = 0 ; i < targetItems.length ; i++ ){
var item_id = targetItems[ i ];
if( item_id == this.id ){ continue; } //自分自身はスキップ
temp_html = ksgmap_item[ item_id ].makeHTML(); //セパレートとそのHTMLをくっつける
if( !temp_html ){ continue; }
html += ksgmap_zmarking_separate + ( typeof( temp_html ) == "object" ? temp_html.html : temp_html ); //HTML
}
if( !html ){ return ""; }
//情報ウィンドウが大きい場合、スクロールバーを表示するようにする
var temp_gmap = document.getElementById( ksgmap_html_googleMap );
var layoutSize = KsGMapCommon.HTML.getLayoutSize( html );
if( layoutSize.width >= ( temp_gmap.offsetWidth / 1.25 ) || layoutSize.height >= ( temp_gmap.offsetHeight / 2 ) ){
if( layoutSize.height >= ( temp_gmap.offsetHeight / 2 ) ){ layoutSize.width += 20; }
var css_w = ( layoutSize.width >= ( temp_gmap.offsetWidth / 1.25 ) ? 1 : 0 );
var css_h = ( layoutSize.height >= ( temp_gmap.offsetHeight / 2 ) ? 1 : 0 );
html = "" + html + "
";
} else {
html = "" + html + "
";
}
return html;
}
//□アイテム - Zポイントを取得
function KsGMapItem_getZPoint(){
var z = KsGMapMap.gmap.getZoom();
// var z = 17 - KsGMapMap.gmap.getZoom();
var lng = Math.round( this.lng * Math.pow( 10 , KsGMapMap.zMarking.dformerDigit[ z ] ) ) / Math.pow( 10 , KsGMapMap.zMarking.dformerDigit[ z ] );
var lat = Math.round( this.lat * Math.pow( 10 , KsGMapMap.zMarking.dformerDigit[ z ] ) ) / Math.pow( 10 , KsGMapMap.zMarking.dformerDigit[ z ] );
var zpoint = String( lng ) + "," + String( lat );
return zpoint;
}
//□アイテム - HTML生成
function KsGMapItem_makeHTML(){
var gData = this.data;
var iData = {};
for( var i in gData ){ iData[ i ] = gData[ i ]; } //値だけをコピー
if( typeof( user_KsGMapItem_makeHTML ) == "function" ){ //ユーザー関数がある場合、そちらで処理する
var html = user_KsGMapItem_makeHTML( iData );
} else if( ksgmap_template[ "undefined" ] ){ //テンプレートファイルがある場合
var html = KsGMapCommon.Data.convTemplate( iData );
} else { //無い場合はデフォルト処理
if( typeof( iData[ "value" ] ) == "undefined" ){ iData[ "value" ] = ""; }
if( typeof( iData[ "_html" ] ) == "undefined" ){ iData[ "_html" ] = ""; }
var html = "" + iData[ "name" ] + " " + iData[ "value" ] + iData[ "_html" ] + "
";
}
return html;
}
//□アイテム - センターに移動
function KsGMapItem_moveCenter(){
KsGMapMap.infoWindow.close();
KsGMapMap.gmap.panTo( new google.maps.LatLng( this.lat , this.lng ) ); //センタリング
}
//□アイテム - 情報ウィンドウを開く(アイテムナビから)
function KsGMapItem_openInfoWindowByItemNavi( count , option ){
if( option == undefined ){ option = ""; }
var lng = ( this.zCurrentPoint.lng ? this.zCurrentPoint.lng : this.lng );
var lat = ( this.zCurrentPoint.lat ? this.zCurrentPoint.lat : this.lat );
//マーカーの設定
if( KsGMapMap.dummyMarker ){ KsGMapMap.dummyMarker.setMap(null); }
var marker = ( ksgmap_marker_key ? ksgmap_item[ this.id ].data[ ksgmap_marker_key ] : "" );
if( !marker || !ksgmap_marker[ marker ] ){ marker = "_default"; }
// ksgmap_marker[ marker ].gicon.image = ksgmap_marker[ marker ].iconfile.replace( "%count%" , ( ksgmap_marker[ marker ].filesuffix[ count ] ? ksgmap_marker[ marker ].filesuffix[ count ] : ksgmap_marker[ marker ].filesuffix[ 0 ] ) );
//情報ウィンドウを表示する為だけのマーカーの表示
var gicon = ksgmap_marker[ marker ].gicon, tgicon = {};
for (var t in gicon) {
tgicon[t] = gicon[t];
}
tgicon.url = ksgmap_marker[ marker ].iconfile.replace( "%count%" , ( ksgmap_marker[ marker ].filesuffix[ count ] ? ksgmap_marker[ marker ].filesuffix[ count ] : ksgmap_marker[ marker ].filesuffix[ 0 ] ) );
var markerOption = {
icon : tgicon ,
position: new google.maps.LatLng( lat , lng ),
map : KsGMapMap.gmap
}
if (ksgmap_marker[ marker ].giconS) {
markerOption.shadow = ksgmap_marker[ marker ].giconS;
}
KsGMapMap.dummyMarker = new google.maps.Marker( markerOption ); //マーカーの作成
var temp_id = this.id;
if( KsGMapMap.infoWindow.currentItemID == temp_id ){ KsGMapMap.infoWindow.close(); return; } //同じマーカーなら情報ウィンドウを閉じる
KsGMapMap.infoWindow.open( "itemNavi" , temp_id , KsGMapMap.dummyMarker );
google.maps.event.addListener( KsGMapMap.infoWindow.currentIns , 'closeclick' , function(){ //情報ウィンドウクローズ後の処理
if( !KsGMapMap.userControl.marker.visibility || option.match( /ADDMARKER/ ) ){ KsGMapMap.dummyMarker.setMap(null); } //マーカーを削除/ユーザーがマーカー非表示時
} );
}
//--------------------------------------------------------------------------------------------------
//□マップポイント
function KsGMapPoint(){
this.count = 0; this.minLng = 0; this.maxLng = 0; this.minLat = 0; this.maxLat = 0;
this.newPoint = 0; this.newLng = 0; this.newLat = 0; this.newZoom = 0;
this.addPoint = KsGMapPoint_addPoint;
this.moveCenter = KsGMapPoint_moveCenter;
this.moveCenterAndZoom = KsGMapPoint_moveCenterAndZoom;
this.setCenterAndZoom = KsGMapPoint_setCenterAndZoom;
}
//□マップポイント - ポイントを加える
function KsGMapPoint_addPoint( lng , lat ){
if( !lng || !lat ){ return ; } //変なごみ
this.count++
if( !this.minLng || this.minLng > lng ){ this.minLng = lng; } //最西と最東の座標を計算
if( !this.maxLng || this.maxLng < lng ){ this.maxLng = lng; }
if( !this.minLat || this.minLat > lat ){ this.minLat = lat; } //最北と最南 〃
if( !this.maxLat || this.maxLat < lat ){ this.maxLat = lat; }
}
//□マップポイント - 中央に移動
function KsGMapPoint_moveCenter(){
KsGMapMap.gmap.panTo( new google.maps.LatLng( ( this.minLat + this.maxLat ) / 2 , ( this.minLng + this.maxLng ) / 2 ) );
}
//□マップポイント - 中央に移動してズーム
function KsGMapPoint_moveCenterAndZoom(){
if( !this.newPoint ){ this.setCenterAndZoom(); }
KsGMapMap.gmap.setCenter( new google.maps.LatLng( this.newLat , this.newLng ) );
KsGMapMap.gmap.setZoom( this.newZoom );
}
//□マップポイント - 中央に移動してズーム
function KsGMapPoint_setCenterAndZoom(){
if( !this.count ){ return ; }
var bounds = KsGMapMap.gmap.getBounds();
var tempSW = bounds.getSouthWest(); var tempNE = bounds.getNorthEast();
tempSW.x = tempSW.lng(); tempSW.y = tempSW.lat(); tempNE.x = tempNE.lng(); tempNE.y = tempNE.lat(); //【v3】
var bound_w = tempNE.x - tempSW.x; var bound_h = tempNE.y - tempSW.y;
var new_lng = ( this.minLng + this.maxLng ) / 2; var new_lat = ( this.minLat + this.maxLat ) / 2;
/*
//マップタイプから最小、最大のズームを取得
var mapTypeList = { "map" : G_NORMAL_MAP , "satellite" : G_SATELLITE_MAP , "hybrid" : G_HYBRID_MAP };
var mapType = mapTypeList[ KsGMapInfo.getType() ];
var minZoom = mapType.getMinimumResolution()
var maxZoom = mapType.getMaximumResolution()
*/
var minZoom = 0; //【v3】
var maxZoom = 19;
if( this.count <= 1 ){ //ひとつの場合は詳細
var n = maxZoom;
} else if( new_lng - ( bound_w / 2 ) > this.minLng || new_lng + ( bound_w / 2 ) < this.maxLng || new_lat - ( bound_h / 2 ) > this.minLat || new_lat + ( bound_h / 2 ) < this.maxLat ){ //いずれか外
var n_x = Math.ceil( Math.log( Math.max( this.maxLng - new_lng , new_lng - this.minLng ) / ( bound_w / 2 ) ) / Math.log( 2 ) )
var n_y = Math.ceil( Math.log( Math.max( this.maxLat - new_lat , new_lat - this.minLat ) / ( bound_h / 2 ) ) / Math.log( 2 ) )
var n = KsGMapMap.gmap.getZoom() - Math.min( n_x , n_y );
if( n < minZoom ){ n = minZoom; }
// var n = KsGMapMap.gmap.getZoom() + Math.max( n_x , n_y );
// if( n > 17 ){ n = 17; }
} else { //すべて内
var n_x = Math.floor( Math.log( ( bound_w / 2 ) / Math.max( this.maxLng - new_lng , new_lng - this.minLng ) ) / Math.log( 2 ) )
var n_y = Math.floor( Math.log( ( bound_h / 2 ) / Math.max( this.maxLat - new_lat , new_lat - this.minLat ) ) / Math.log( 2 ) )
var n = KsGMapMap.gmap.getZoom() + Math.max( n_x , n_y );
if( n > maxZoom ){ n = maxZoom; }
// var n = KsGMapMap.gmap.getZoom() - Math.min( n_x , n_y );
// if( n < 0 ){ n = 0; }
}
this.newPoint = 1; this.newLng = new_lng; this.newLat = new_lat; this.newZoom = n;
}
//--------------------------------------------------------------------------------------------------
//□マーカー
function KsGMapMarker( type ){
this.gicon = "";
this.iconfile = "";
this.filesuffix = [];
this.naviprefix = [];
if( type == "_center" ){
this.marker = "";
this.width = 0;
this.height = 0;
this.marking = KsGMapMarker_marking;
this.remove = KsGMapMarker_remove;
this.movestart = KsGMapMarker_movestart;
}
}
//□マーカー - センターマーカーの表示
function KsGMapMarker_marking(){
if( KsGMapInfo.urlPriorityType == "item" ){ return ; } //アイテム閲覧中は非表示
KsGMapCommon.HTML.setDisplay( "ksgmap--icon-center-outer-icon" , 0 );
KsGMapCommon.HTML.setDisplay( "ksgmap--icon-center-outer-shadow" , 0 );
if( this.marker ){ this.marker.setMap(null); } //センターマーカーを消す
if( !KsGMapMap.userControl.centerMarker.visibility ){ return; } //ユーザーが非表示にしている場合、表示しない
var markerOption = {
icon : this.gicon ,
position: KsGMapMap.gmap.getCenter(),
map : KsGMapMap.gmap
}
if (this.giconS) {
markerOption.shadow = this.giconS;
}
this.marker = new google.maps.Marker( markerOption );
if( ksgmap_apiversion < 2 ){ this.marker.iconImage.style.cursor = "default"; }
}
//□マーカー - センターマーカーの削除
function KsGMapMarker_remove(){
if (this.marker) {
this.marker.setMap(null);
}
KsGMapCommon.HTML.setDisplay( "ksgmap--icon-center-outer-icon" , 0 ); //マップ外センターマーカーを消去
KsGMapCommon.HTML.setDisplay( "ksgmap--icon-center-outer-shadow" , 0 );
this.marker = "";
}
//□マーカー - センターマーカーをマップ外センターマーカーに切り替え
function KsGMapMarker_movestart(){
if( !KsGMapMap.userControl.centerMarker.visibility ){ return; } //ユーザーが非表示にしている場合、表示しない
if( KsGMapInfo.urlPriorityType == "item" ){ return ; } //アイテム閲覧中は非表示
this.remove();
//マップ外センターマーカーの位置を再設定
var ksgmap_obj = document.getElementById( ksgmap_html_googleMap );
var x = String( ksgmap_obj.offsetLeft + ( ( ksgmap_obj.offsetWidth - this.width + 1 ) / 2 ) + ksgmap_marker_center_adjust_x ) + "px";
var y = String( ksgmap_obj.offsetTop + ( ( ksgmap_obj.offsetHeight - this.height + 1 ) / 2 ) + ksgmap_marker_center_adjust_y ) + "px";
document.getElementById( "ksgmap--icon-center-outer-icon" ).style.left = x; document.getElementById( "ksgmap--icon-center-outer-icon" ).style.top = y;
if( ksgmap_marker[ "_center" ].giconS ){ document.getElementById( "ksgmap--icon-center-outer-shadow" ).style.left = x; document.getElementById( "ksgmap--icon-center-outer-shadow" ).style.top = y; }
KsGMapCommon.HTML.setDisplay( "ksgmap--icon-center-outer-icon" , 1 ); //表示
KsGMapCommon.HTML.setDisplay( "ksgmap--icon-center-outer-shadow" , 1 );
}
//--------------------------------------------------------------------------------------------------
//□検索
var KsGMapSearch = new function(){
this.status = 0; //マップ検索状態:0検索無し / 1検索有り
this.count = 0;
this.dictionarySynonym = [];
this.init = KsGMapSearch_init;
this.clear = KsGMapSearch_clear;
this.dispMessage = KsGMapSearch_dispMessage;
this.search = KsGMapSearch_search;
this.geocoding = KsGMapSearch_geocoding;
this.itemName = {}; //アイテム名検索
this.itemName.name = [];
this.itemName.clear = KsGMapSearch_itemName_clear;
this.itemName.set = KsGMapSearch_itemName_set;
this.narrow = {}; //絞り込み検索
this.narrow.keys = [];
this.narrow.change = KsGMapSearch_narrow_change;
this.geocodingSearch = {}; //住所検索
this.geocodingSearch.value = "";
this.geocodingSearch.prevCategory = "";
this.geocodingSearch.result = "";
this.geocodingSearch.trimPrefix = "(日本)|日本";
this.geocodingSearch.template = {};
this.geocodingSearch.template.unmatch = "見付かりませんでした。 キーワードを変えて再検索を行ってください。
";
this.geocodingSearch.template.outer = "";
this.geocodingSearch.template.row = "%col% ";
this.geocodingSearch.template.col = "%address% ";
}
//□検索 - 初期化
function KsGMapSearch_init(){
//類義語辞書を初期化登録
var dic = ksgmap_search_dic_synonym;
if( dic ){
dic = dic.replace( /\t/g , " " ); dic = dic.replace( /\s{2,}/g , " " );
var temp_dic = dic.split( " " );
for( var i = 0 ; i < temp_dic.length; i++ ){ this.dictionarySynonym[ this.dictionarySynonym.length ] = "(?:" + temp_dic[ i ].replace( /,/ , "|" ) + ")"; } //HOGE,FOO ⇒ (?:HOGE|FOO|…)
}
}
//□検索 - アイテム名検索 - 値のクリア
function KsGMapSearch_itemName_clear(){
//ジオコーディングの場合、前のカテゴリに戻す
if( ksgmap_focus_category == "_geocoding" ){
ksgmap_focus_category = KsGMapSearch.geocodingSearch.prevCategory;
KsGMapSearch.geocodingSearch.prevCategory = "";
}
this.name = [];
KsGMapSearch.geocodingSearch.value = "";
KsGMapSearch.geocodingSearch.result = "";
}
//□検索 - アイテム名検索 - 値のセット
function KsGMapSearch_itemName_set( value ){
KsGMapSearch.geocodingSearch.value = value;
//類義語辞書処理
for( var i = 0 ; i < KsGMapSearch.dictionarySynonym.length ; i++ ){
var reg = new RegExp( KsGMapSearch.dictionarySynonym[ i ] , "i" );
value = value.replace( reg , KsGMapSearch.dictionarySynonym[ i ] );
}
this.name = value.split( " " );
}
//□検索 - 絞り込み検索 - 条件の変更
function KsGMapSearch_narrow_change( key , num ){
num = parseInt( num ); //数値化
var tempNarrowSearchKeys = [];
var flag_match = 0;
for( var i = 0 ; i < this.keys.length ; i++ ){
var reg = new RegExp( "^" + key + ":" );
if( this.keys[ i ].match( reg ) && num ){ this.keys[ i ] = key + ":" + num; flag_match = 1; } //差し替え
if( this.keys[ i ].match( reg ) && !num ){ flag_match = 1; continue; } //削除
tempNarrowSearchKeys[ tempNarrowSearchKeys.length ] = this.keys[ i ];
}
if( !flag_match && num ){ tempNarrowSearchKeys[ tempNarrowSearchKeys.length ] = key + ":" + num; } //追加
this.keys = tempNarrowSearchKeys;
}
//□検索 - クリア
function KsGMapSearch_clear(){
this.status = 0;
//ジオコーディングの場合、前のカテゴリに戻す
if( ksgmap_focus_category == "_geocoding" ){
ksgmap_focus_category = KsGMapSearch.geocodingSearch.prevCategory;
KsGMapSearch.geocodingSearch.prevCategory = "";
}
if( ksgmap_focus_category ){ ksgmap_category[ ksgmap_focus_category ].marking(); } //マーカーを引きなおす
KsGMapCategoryNavi.create(); //カテゴリナビを作り直す
KsGMapCommon.HTML.write( ksgmap_html_search_message , "" );
}
//□検索 - メッセージの表示
function KsGMapSearch_dispMessage(){
if( this.count ){ //成功
var resultMessage = "" + this.count + "件の" + ksgmap_item_name + "が見つかりました。
";
} else { //失敗(マッチ0件)
var resultMessage = "1件も見つかりませんでした。
";
}
KsGMapCommon.HTML.write( ksgmap_html_search_message , resultMessage );
}
//□検索 - 検索処理
function KsGMapSearch_search(){
KsGMapEX.callback( this , arguments ); //コールバック
//ジオコーディング
if( ksgmap_focus_category == "_geocoding" ){
KsGMapSearch.geocoding();
return;
}
//検索結果をクリアにしておく
this.count = 0;
for( var category_id in ksgmap_category ){
if( category_id == "clear" ){ continue; }
ksgmap_category[ category_id ].clearSearchResultItems(); //検索結果のクリア
ksgmap_category[ category_id ].clearSortCacheItems(); //ソートのキャッシュもクリア
}
//アイテム名検索の正規表現オブジェクト生成
var reg_searchName = [];
if( this.itemName.name.length ){
for( i = 0 ; i < this.itemName.name.length ; i++ ){
if( !this.itemName.name[ i ] ){ continue; }
reg_searchName[ reg_searchName.length ] = new RegExp( this.itemName.name[ i ] , "i" );
}
}
//検索条件が無い場合
if( !this.itemName.name.length && !this.narrow.keys.length ){ this.clear(); return; }
//検索開始
LABEL_for01:
for( var item_id in ksgmap_item ){
if( item_id == "clear" ){ continue; }
//アイテム名検索
for( var i = 0 ; i < reg_searchName.length ; i++ ){ if( !ksgmap_item[ item_id ].name.match( reg_searchName[ i ] ) ){ continue LABEL_for01; } }
//絞り込み検索
for( var i = 0 ; i < this.narrow.keys.length ; i++ ){ //絞込み検索
if( !ksgmap_narrowCondition[ this.narrow.keys[ i ] ] || ksgmap_narrowCondition[ this.narrow.keys[ i ] ].match( /;/ ) ){ continue; }
if( !eval( ksgmap_narrowCondition[ this.narrow.keys[ i ] ].replace( /%([a-zA-Z][a-zA-Z0-9_]+)%/g , "ksgmap_item[ \"" + item_id + "\" ].data[ \"$1\" ]" ) ) ){ continue LABEL_for01; }
}
//以下マッチ結果処理
ksgmap_category[ ksgmap_item[ item_id ].category ].addSearchResultItems( item_id ); //カテゴリに検索結果を追加
this.count++;
}
//検索結果が存在する場合、もしくは住所検索が有効の場合、ステータスを1にしておく
if( this.count || ksgmap_search_geocoding ){ this.status = 1; }
KsGMapItemNavi.page.num = 1; //ページを1にリセット
if( ksgmap_focus_category ){ ksgmap_category[ ksgmap_focus_category ].marking(); } //マーカーを引きなおす
KsGMapCategoryNavi.create(); //カテゴリナビを作り直す
if( !ksgmap_search_narrow_message && !this.itemName.name.length ){ return ; } //絞り込み検索でメッセージ表示無し設定で、アイテム名検索無しの場合、メッセージを表示せず完了
this.dispMessage(); //メッセージを表示
}
//□検索 - ジオコーディング
function KsGMapSearch_geocoding( option ){
if( !option ){ option = {}; }
//ジオコーディング前のカテゴリを記録
if( ksgmap_focus_category != "_geocoding" ){
KsGMapSearch.geocodingSearch.prevCategory = ksgmap_focus_category;
ksgmap_focus_category = "_geocoding";
}
//キーワード生成
var keyword = KsGMapSearch.geocodingSearch.value;
if( ksgmap_search_geocoding_joinPrefix ){ //プレフィックス付加がある場合
keyword = keyword.replace( new RegExp( "^" + ksgmap_search_geocoding_joinPrefix.replace( /\s/g , "|" ) , "g" ) , "" );
keyword = ksgmap_search_geocoding_joinPrefix.replace( /\s/g , "" ) + keyword;
}
//ジオコーディング検索
var isLandmark = ( option.landmark ? true : false );
KsGMapMap.geocoder.geocode({ 'address': keyword },
function( result, status ) {
if( status !== google.maps.GeocoderStatus.OK ){ //失敗時
KsGMapSearch.geocodingSearch.result = KsGMapSearch.geocodingSearch.template.unmatch;
} else {
//HTMLを作成
var html = "";
for( var i = 0 ; i < result.length ; i++ ){
var replace_list = {};
var placemark = result[ i ];
var lng = placemark.geometry.location.lng();
var lat = placemark.geometry.location.lat();
//列
var replace_list = {
address : placemark.formatted_address.replace( new RegExp( "^" + KsGMapSearch.geocodingSearch.trimPrefix ) , "" ).replace(/^, /, "") ,
script : "return KsGMapFunc.move.toLatLng( event , " + lat + " , " + lng + " );"
};
//行
var replace_list = {
col : KsGMapCommon.String.convTemplate( KsGMapSearch.geocodingSearch.template.col , replace_list ) ,
row_class : ( ksgmap_itemNavi_rowStrips && i % 2 != 1 ? "ksgmap--itemNavi-row-strips" : "" )
};
html += KsGMapCommon.String.convTemplate( KsGMapSearch.geocodingSearch.template.row , replace_list );
}
KsGMapSearch.geocodingSearch.result = KsGMapCommon.String.convTemplate( KsGMapSearch.geocodingSearch.template.outer , { html : html } );
}
KsGMapItemNavi.make();
}
);
}
//--------------------------------------------------------------------------------------------------
//□ソート
var KsGMapSort = new function(){
this.status = 0; //状態
this.key = ""; //ソートするキー
this.desc = 0; //昇順/降順
this.type = "string"; //型
this.distance = 0; //距離ソート
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.init = KsGMapSort_init;
this.clear = KsGMapSort_clear;
this.setSortVar = KsGMapSort_setSortVar;
}
function KsGMapSort_init(){
if( ksgmap_default_sort ){ this.setSortVar( ksgmap_default_sort ); } //初期ソートがある場合値をセット
}
//□ソート - クリア
function KsGMapSort_clear(){
this.status = 0; this.key = ""; this.desc = 0; this.itemNaviFormat = "";
KsGMapItemNavi.page.num = 1; //ページを1にリセット
for( var category_id in ksgmap_category ){
if( category_id == "clear" ){ continue; }
ksgmap_category[ category_id ].clearSortCacheItems(); //ソートのキャッシュもクリア
}
}
//□ソート - ソート変数のセット
function KsGMapSort_setSortVar( sortKey ){
this.status = 1;
KsGMapItemNavi.page.num = 1; //ページを1にリセット
sortKey.match( /^([a-zA-Z0-9_-]+)(\s.+)?$/i );
var option = RegExp.$2;
if( RegExp.$1 == "_distance" ){ //現在地からの距離順
this.distance = 1;
} else { //通常ソート
this.distance = 0;
this.key = RegExp.$1;
this.desc = ( option.match( /desc/ ) ? 1 : 0 ); //降順
this.type = ( option.match( /num/ ) ? "number" : "string" ); //数値
}
this.itemNaviFormat = ( option.match( /navi:(.+)/ ) ? RegExp.$1 : "" ); //アイテムナビのフォーマット
}
//--------------------------------------------------------------------------------------------------
//□カテゴリ・ナビゲーション
var KsGMapCategoryNavi = new function(){
this.id = "";
this.html = "";
this.group = {};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.template = {};
this.template.outer = "%html% ";
this.template.group = " %html% ";
this.template.inner = "%name% ";
this.innerUndefined = "%ksgmap_category_name%を選択して下さい。 ";
this.innerSearchUnmatch = "%ksgmap_category_name%を選択して下さい。 ";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.init = KsGMapCategoryNavi_init;
this.add = KsGMapCategoryNavi_add;
this.change = KsGMapCategoryNavi_change;
this.make = KsGMapCategoryNavi_make;
this.clear = KsGMapCategoryNavi_clear;
this.create = KsGMapCategoryNavi_create;
this.click = KsGMapCategoryNavi_click;
}
//□カテゴリ・ナビゲーション - 初期化
function KsGMapCategoryNavi_init(){
this.id = ksgmap_html_categoryNavi;
//アイテム名とカテゴリ名を挿入
var replace_list = {};
replace_list[ "ksgmap_category_name" ] = ksgmap_category_name;
this.innerUndefined = KsGMapCommon.String.convTemplate( this.innerUndefined , replace_list );
this.innerSearchUnmatch = KsGMapCommon.String.convTemplate( this.innerSearchUnmatch , replace_list );
}
//□カテゴリ・ナビゲーション - 追加
function KsGMapCategoryNavi_add( category_id ){
if( !this.id || category_id == "clear" ){ return ; }
if( category_id == "_all" && ksgmap_category_all == 0 && ksgmap_focus_category != "_all" ){ return ;}
if( category_id == "_map" && ksgmap_category_map == 0 && ksgmap_focus_category != "_map" ){ return ;}
var replace_list = {};
replace_list[ "category_id" ] = category_id; replace_list[ "name" ] = ( category_id != "_geocodingSearch" ? ksgmap_category[ category_id ].name : "住所検索結果" ); replace_list[ "selected" ] = ( category_id == ksgmap_focus_category ? " selected=\"selected\"" : "" ); replace_list[ "html_id" ] = category_id.replace( /^_/ , "-" );
var html = KsGMapCommon.String.convTemplate( this.template.inner , replace_list );
if( ksgmap_category[ category_id ] && ksgmap_category[ category_id ].group ){
if( !this.group[ ksgmap_category[ category_id ].group ] ){ this.group[ ksgmap_category[ category_id ].group ] = ""; }
this.group[ ksgmap_category[ category_id ].group ] += html;
} else {
this.html += html;
}
}
//□カテゴリ・ナビゲーション - 変更
function KsGMapCategoryNavi_change( category_id ){
if (!document.getElementById( "ksgmsp--categoryNavi-select" )) { return; }
document.getElementById( "ksgmsp--categoryNavi-select" ).value = category_id;
}
//□カテゴリ・ナビゲーション - クリア
function KsGMapCategoryNavi_clear(){
if( this.id ){ document.getElementById( !this.id ).innerHTML = ""; }
}
//□カテゴリ・ナビゲーション - 設置
function KsGMapCategoryNavi_create(){
//初期カテゴリが未指定の場合
if( !ksgmap_focus_category ){ this.html = this.innerUndefined + this.html; }
for( var category_id in ksgmap_category ){
if( category_id == "clear" ){ continue; }
//検索でマッチしない場合
if( KsGMapSearch.status && category_id != "_all" && !ksgmap_category[ category_id ].searchResultItems.length ){
if( ksgmap_focus_category == category_id ){ //「~を選択して下さい。」を表示
var replace_list = {};
replace_list[ "category_id" ] = category_id; replace_list[ "name" ] = ksgmap_category[ category_id ].name;
this.html = KsGMapCommon.String.convTemplate( this.innerSearchUnmatch , replace_list ) + this.html;
}
continue;
}
this.add( category_id );
}
//検索時は住所検索の結果を表示するようにする
if( KsGMapSearch.status && ksgmap_search_geocoding ){ KsGMapCategoryNavi.add( "_geocodingSearch" ); }
this.make();
}
//□カテゴリ・ナビゲーション - 生成
function KsGMapCategoryNavi_make(){
if( !this.id ){ return; }
var html = this.html;
//グループの処理
for( var group_name in this.group ){
var replace_list = {};
replace_list[ "group_name" ] = group_name; replace_list[ "html" ] = this.group[ group_name ];
html += KsGMapCommon.String.convTemplate( this.template.group , replace_list );
}
//全体の処理
var replace_list = {};
replace_list[ "html" ] = html;
document.getElementById( this.id ).innerHTML = KsGMapCommon.String.convTemplate( this.template.outer , replace_list );
this.html = ""; this.group = {}; //生成したらクリア
}
//□カテゴリ・ナビゲーション - クリック
function KsGMapCategoryNavi_click( form ){
if( form.value == "_geocodingSearch" ){ KsGMapSearch.geocoding(); return; }
if( ksgmap_focus_category == form.value ){ return ; } //同じだと最初のクリック(onchangeにしていないのは、IEでマウスホイールのバグがある為)
ksgmap_category[ form.value ].change();
}
//--------------------------------------------------------------------------------------------------
//□アイテム・ナビゲーション
var KsGMapItemNavi = new function(){
this.id = "";
this.html = "";
this.firstID = "";
this.tempCount = 0;
this.page = {};
this.page.num = 1;
this.page.items = 0;
this.page.qty = 1;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.template = {};
this.template.outer = "";
this.template.inner = {};
this.template.inner.row = "%col1%%col2%%col3% ";
this.template.inner.col1 = "%countInnerHTML% ";
this.template.inner.col2 = "%name% ";
this.template.inner.col3 = "%thirdRow% ";
this.template.pageNavi = "";
this.innerEmpty = "%ksgmap_category_name%には%ksgmap_item_name%は存在しません。
";
this.innerSearchUnmatch = "%ksgmap_category_name%には検索結果にマッチする%ksgmap_item_name%は存在しません。マップ上にすべて表示する場合はクリック
";
this.innerSearchAddress = "住所検索を行う場合はクリック
";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.init = KsGMapItemNavi_init;
this.add = KsGMapItemNavi_add;
this.makeThirdRow = KsGMapItemNavi_makeThirdRow;
this.changeFocus = KsGMapItemNavi_changeFocus;
this.clear = KsGMapItemNavi_clear;
this.make = KsGMapItemNavi_make;
this.openInfoWindow = KsGMapItemNavi_openInfoWindow;
this.changePage = KsGMapItemNavi_changePage;
this.checkAutoZoom = KsGMapItemNavi_checkAutoZoom;
}
//□アイテム・ナビゲーション - 初期化
function KsGMapItemNavi_init(){
this.id = ksgmap_html_itemNavi;
this.page.items = ksgmap_itemNavi_page_items;
//スクロールバーの調整
if( this.id ){
var obj = document.getElementById( this.id );
if( ksgmap__ua.MSIE ){ obj.style.overflowY = "auto"; obj.style.overflowX = "hidden"; } //IE
else if( ksgmap__ua.Gecko ){ obj.style.overflow = "-moz-scrollbars-vertical"; } //Gecko系
else { obj.style.overflow = "auto"; } //Safariとか(実現できず)
}
//自動ズーム(マップ上のアイテムをすべて表示)が有効かチェック
if( ksgmap_html_itemNavi_autoZoom ){ KsGMapItemNavi.checkAutoZoom(); }
}
//□アイテム・ナビゲーション - 追加
function KsGMapItemNavi_add( item_id , count , marker_id ){
if( !this.id ){ return; }
if( !this.html ){ this.firstID = "ksgmap--itemNavi-countLabel-" + item_id; } //一番上のIDを記録しておく(フォーカスを当てる為)
this.tempCount++;
var replace_list = {};
replace_list[ "item_id" ] = item_id; replace_list[ "count" ] = count; replace_list[ "name" ] = ksgmap_item[ item_id ].name;
//カウンタラベルの生成
if( !marker_id || !ksgmap_marker[ marker_id ] ){ marker_id = "_default"; }
replace_list[ "countLabel" ] = ( ksgmap_marker[ marker_id ].naviprefix[ count ] ? ksgmap_marker[ marker_id ].naviprefix[ count ] : ksgmap_marker[ marker_id ].naviprefix[ 0 ] );
replace_list[ "countInnerHTML" ] = replace_list[ "countLabel" ];
//カウンターマーカーの作成
if( ksgmap_marker[ "itemnavi:" + marker_id ] != undefined ){
var countMarkerFilename = ksgmap_marker[ "itemnavi:" + marker_id ].iconfile.replace( "%count%" , ( ksgmap_marker[ "itemnavi:" + marker_id ].filesuffix[ count ] ? ksgmap_marker[ "itemnavi:" + marker_id ].filesuffix[ count ] : ksgmap_marker[ "itemnavi:" + marker_id ].filesuffix[ 0 ] ) );
if( ksgmap_focus_category == "_map" && ksgmap__ua.MSIE <= 6 && navigator.userAgent.match( /SV1/ ) ){ //IE 非SP2 暫定処理
replace_list[ "countInnerHTML" ] = " ";
} else { //通常処理
replace_list[ "countInnerHTML" ] = KsGMapCommon.HTML.makePngTag( countMarkerFilename , ksgmap_marker[ "itemnavi:" + marker_id ].width , ksgmap_marker[ "itemnavi:" + marker_id ].height , { style : "border: 0;" , title : replace_list[ "countLabel" ] , alt : replace_list[ "countLabel" ] } );
}
}
//ソート値の生成
replace_list[ "thirdRow" ] = this.makeThirdRow( item_id );
replace_list[ "main_colspan" ] = ( replace_list[ "thirdRow" ] ? 1 : 2 );
//属性(共通)
replace_list[ "function_openInfoWindow" ] = "KsGMapItemNavi.openInfoWindow( event , this , '" + item_id + "' , " + count + " );";
//各列部分の置換
replace_list[ "row_class" ] = ( ksgmap_itemNavi_rowStrips && this.tempCount % 2 != 1 ? "ksgmap--itemNavi-row-strips" : "" );
replace_list[ "col1" ] = ( ksgmap_itemNavi_countColumn ? KsGMapCommon.String.convTemplate( this.template.inner.col1 , replace_list ) : "" );
replace_list[ "col2" ] = KsGMapCommon.String.convTemplate( this.template.inner.col2 , replace_list );
replace_list[ "col3" ] = ( replace_list[ "thirdRow" ] ? KsGMapCommon.String.convTemplate( this.template.inner.col3 , replace_list ) : "" );
this.html += KsGMapCommon.String.convTemplate( this.template.inner.row , replace_list );
}
//□アイテム・ナビゲーション - 3列目の作成
function KsGMapItemNavi_makeThirdRow( item_id ){
var value = ""; var format = "";
//ソートがある場合、それを優先する
if( KsGMapSort.itemNaviFormat && KsGMapSort.distance ){ //現在地からの距離順
format = KsGMapSort.itemNaviFormat;
value = ksgmap_item[ item_id ].distance;
} else if( KsGMapSort.itemNaviFormat && KsGMapSort.status && KsGMapSort.itemNaviFormat ){ //通常ソート
format = KsGMapSort.itemNaviFormat;
value = ksgmap_item[ item_id ].data[ KsGMapSort.key ];
} else if( ksgmap_itemNavi_thirdRow ){ //設定でキー指定
var temp = ksgmap_itemNavi_thirdRow.split( " " );
format = ( temp[ 1 ] ? temp[ 1 ] : "" );
value = ksgmap_item[ item_id ].data[ temp[ 0 ] ];
}
//コールバックの戻り値がある場合、それを優先
var callback = KsGMapEX.callback( this , arguments , item_id , value , format ); //コールバック
if( callback.cancelParentProcess ){ return callback.returnValue.result; }
if( callback.returnValue && callback.returnValue.format ){ format = callback.returnValue.format; }
if( callback.returnValue && callback.returnValue.value ){ value = callback.returnValue.value; }
//sprintf関数で変換
if( value && format ){ value = KsGMapCommon.String.sprintf( format , value ); }
return value;
}
//□アイテム・ナビゲーション - フォーカスを移す
function KsGMapItemNavi_changeFocus( event ){
if( !ksgmap__ua.MSIE ){ return ; }
if( event.shiftKey || event.keyCode == 9 ){ return ; } //タブキーはそのまま
KsGMapMap.infoWindow.close(); //情報ウィンドウを閉じる
document.getElementById( ksgmap_html_googleMap ).focus(); //それ以外は、マップにフォーカス
}
//□アイテム・ナビゲーション - クリア
function KsGMapItemNavi_clear(){
if( !this.id ){ return; }
document.getElementById( ksgmap_html_itemNavi ).innerHTML = "";
}
//□アイテム・ナビゲーション - 生成
function KsGMapItemNavi_make(){
if( !this.id ){ return; }
if( this.html ){ //通常処理
var replace_list = {};
replace_list[ "html" ] = this.html;
this.html = KsGMapCommon.String.convTemplate( this.template.outer , replace_list );
//ページモードの場合で、ページ数が2ページ以上の場合
if( KsGMapItemNavi.page.items && this.page.qty >= 2 ){
var replace_list = {};
replace_list[ "prev_attr" ] = " onclick=\"KsGMapItemNavi.changePage( event , " + ( this.page.num - 1 ) + " )\"" + ( this.page.num == 1 ? " disabled=\"disabled\"" : "" );
replace_list[ "next_attr" ] = " onclick=\"KsGMapItemNavi.changePage( event , " + ( this.page.num + 1 ) + " )\"" + ( this.page.num == this.page.qty ? " disabled=\"disabled\"" : "" );
replace_list[ "pageInfo" ] = this.page.num + " / " + this.page.qty;
var pageNavi = KsGMapCommon.String.convTemplate( this.template.pageNavi , replace_list );
this.html = pageNavi + this.html + pageNavi;
}
} else { //1件も存在しない場合のメッセージ
var replace_list = {};
replace_list[ "ksgmap_category_name" ] = ( ksgmap_focus_category != "_map" ? "この" + ksgmap_category_name : "マップ内" );
replace_list[ "ksgmap_item_name" ] = ksgmap_item_name;
if( KsGMapSearch.status ){ //検索の場合
if( !KsGMapSearch.geocodingSearch.result ){
if( KsGMapSearch.count ){ this.html = KsGMapCommon.String.convTemplate( this.innerSearchUnmatch , replace_list ); }
if( ksgmap_search_geocoding ){ this.html += KsGMapCommon.String.convTemplate( this.innerSearchAddress , replace_list ); }
} else { //ジオコーディング結果がある場合
this.html = KsGMapSearch.geocodingSearch.result;
}
} else if( !KsGMapSearch.status ){ //検索でない場合(「マップ内のアイテムを表示」)
this.html = KsGMapCommon.String.convTemplate( this.innerEmpty , replace_list );
}
}
document.getElementById( ksgmap_html_itemNavi ).innerHTML = this.html;
this.html = ""; //生成したらクリア
this.tempCount = 0;
}
//□アイテム・ナビゲーション - 情報ウィンドウを開く
function KsGMapItemNavi_openInfoWindow( event , obj , item_id , count ){
if( event.shiftKey && obj.tagName != "A" ){ //シフトキーを押しているとセンタリングだけする(アルファベットは除く)
ksgmap_item[ item_id ].moveCenter();
} else { //通常処理
ksgmap_item[ item_id ].openInfoWindowByItemNavi( count );
}
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□アイテム・ナビゲーション - ページの変更
function KsGMapItemNavi_changePage( event , pageNo ){
if( 1 <= pageNo && pageNo <= this.page.qty ){
this.page.num = pageNo;
ksgmap_category[ ksgmap_focus_category ].marking();
}
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□アイテム・ナビゲーション - 自動ズーム(マップ上のアイテムをすべて表示)が有効かチェック
function KsGMapItemNavi_checkAutoZoom(){
if( ksgmap_focus_category == "_geocoding" ){ return false; }
var map_boudns = bounds = KsGMapMap.gmap.getBounds();
var tempSW = map_boudns.getSouthWest(); var tempNE = map_boudns.getNorthEast();
tempSW.x = tempSW.lng(); tempSW.y = tempSW.lat(); tempNE.x = tempNE.lng(); tempNE.y = tempNE.lat(); //【v3】
var category_bounds = ksgmap_category[ ksgmap_focus_category ].bounds;
var obj = document.getElementById( ksgmap_html_itemNavi_autoZoom );
//すべてのアイテムがマップ内の場合、自動ズームを無効にする
if( tempSW.x < category_bounds.minLng && category_bounds.maxLng < tempNE.x && tempSW.y < category_bounds.minLat && category_bounds.maxLat < tempNE.y ){
obj.disabled = true; obj.style.cursor = "default";
} else {
obj.disabled = false; obj.style.cursor = "auto";
}
}
//--------------------------------------------------------------------------------------------------
//□マップ情報
var KsGMapInfo = new function(){
this.urlPriorityType = "";
this.active = ( ( ksgmap_html_mapInfo_url || ksgmap_html_mapInfo_point ) ? 1 : 0 );
this.url = "";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.xmlInfo = {}; //XMLからのデータが入る(以下同)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.dispURL_extraArg = ""; //追加引数
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.dispURL = KsGMapInfo_dispURL;
this.dispPoint = KsGMapInfo_dispPoint;
this.getType = KsGMapInfo_getType;
this.getURL = KsGMapInfo_getURL;
this.setURL = KsGMapInfo_setURL;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.userMessageEditor = {};
this.userMessageEditor.message = "";
this.userMessageEditor.html = " ";
this.userMessageEditor.open = KsGMapInfo_userMessageEditor_open;
this.userMessageEditor.submit = KsGMapInfo_userMessageEditor_submit;
this.userMessageEditor.onblur = KsGMapInfo_userMessageEditor_onblur;
}
//□マップ情報 - 「このページのURL」の表示
function KsGMapInfo_dispURL(){
var tempObj = document.getElementById( ksgmap_html_mapInfo_url );
if (!tempObj) { return; }
if( tempObj.tagName != "INPUT" ){ tempObj.innerHTML = this.url; } else { tempObj.value = this.url; } //インプットタグの場合は値を、それ以外はいつも通り、innerHTML
}
//□マップ情報 - 「緯度/経度」の表示
function KsGMapInfo_dispPoint( lng , lat ){
var result = "";
if( ksgmap_mapInfo_point_base == 60 ){ //60進数
switch( ksgmap_mapInfo_point_base60_language ){ //表示言語の指定
case "jp" : var lang = [ "東経" , "西経" , "北緯" , "南緯" , "度" , "分" , "秒" ]; break; //見てのとおり日本語
case "sign" : var lang = [ "E" , "W" , "N" , "S" , "°" , "′" , "″" ]; break; //見てのとおり記号(英語)
}
var decimalDigit = ksgmap_mapInfo_point_base60_decimalDigit;
var base60_lng = KsGMapCommon.Map.convBase10ToBase60( lng ); //10進数から60進数に変換
base60_lng.match( /^(.)([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?$/ );
var result_lng = ( RegExp.$1 == "+" ? lang[ 0 ] : lang[ 1 ] ) + RegExp.$2 + lang[ 4 ] + RegExp.$3 + lang[ 5 ] + RegExp.$4 + lang[ 6 ] + ( decimalDigit ? RegExp.$5.substring( 1 , ( decimalDigit + 1 ) ) : "" );
var base60_lat = KsGMapCommon.Map.convBase10ToBase60( lat );
base60_lat.match( /^(.)([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?$/ );
var result_lat = ( RegExp.$1 == "+" ? lang[ 2 ] : lang[ 3 ] ) + RegExp.$2 + lang[ 4 ] + RegExp.$3 + lang[ 5 ] + RegExp.$4 + lang[ 6 ] + ( decimalDigit ? RegExp.$5.substring( 1 , ( decimalDigit + 1 ) ) : "" );
} else { //10進数
var decimalDigit = ksgmap_mapInfo_point_base10_decimalDigit;
var temp = String( lng ).split( "." ); var result_lng = temp[ 0 ] + "." + temp[ 1 ].substring( 0 , decimalDigit );
var temp = String( lat ).split( "." ); var result_lat = temp[ 0 ] + "." + temp[ 1 ].substring( 0 , decimalDigit );
}
var result = ksgmap_mapInfo_point_format;
result = result.replace( "%lng%" , result_lng );
result = result.replace( "%lat%" , result_lat );
document.getElementById( ksgmap_html_mapInfo_point ).innerHTML = result;
}
//□マップ情報 - タイプの取得
function KsGMapInfo_getType(){
var type = KsGMapMap.gmap.getMapTypeId() + "";
if (type === "roadmap") { type = "map"; }
return type;
}
//□マップ情報 - 「このページのURL」の取得
function KsGMapInfo_getURL(){
return this.url;
}
//□マップ情報 - 「このページのURL」のセット
function KsGMapInfo_setURL( type ){
var arg = arguments;
if( this.urlPriorityType ){ //優先指定されている場合
if( this.urlPriorityType == "location" ){ this.urlPriorityType = ""; return ; } //locationは初回のみでクリア
else { return ; } //それ以外
}
//有効でないタイプの場合は、point にする
if( type != "point" && ( !ksgmap_mapInfo_point_enableType || !type.match( new RegExp( ksgmap_mapInfo_point_enableType.replace( /,|\t|\s/g , "|" ) , "i" ) ) ) ){
if( type == "location" ){ return; } else { type = "point"; }
}
if( type == "item" || type == "location" ){ this.urlPriorityType = type; } //アイテム表示中に移動した場合、座標になってしまう為(情報ウィンドウが消えたらオフ
if( type == "item" && !arg[ 1 ] ){ return ; } //ユーザーメッセージの場合
if( type == "point" && ( !arg[ 1 ] || !arg[ 2 ] ) ){ //座標未指定の場合
var center = KsGMapMap.gmap.getCenter();
center.x = center.lng(); center.y = center.lat(); //【v3】
var temp = String( center.x ).split( "." ); arg[ 1 ] = temp[ 0 ] + "." + temp[ 1 ].substring( 0 , 5 ); //小数点以下5桁にする
var temp = String( center.y ).split( "." ); arg[ 2 ] = temp[ 0 ] + "." + temp[ 1 ].substring( 0 , 5 );
}
//URLの引数の作成
var urlArg = "http://" + location.host + location.pathname + "?" + this.dispURL_extraArg;
switch( type ){
case "category" : urlArg += "category=" + arg[ 1 ]; break; //カテゴリ
case "item" : urlArg += "item=" + arg[ 1 ]; break; //アイテム
case "point" : urlArg += "lng=" + arg[ 1 ] + "&lat=" + arg[ 2 ] + ( ksgmap_focus_category != undefined ? "&category=" + ksgmap_focus_category : "" ); break; //座標
case "location" : urlArg += location.search.replace( /^\?/ , "" ); break; //URL引数
}
if( type != "location" ){
var temp_type = this.getType(); var temp_zoom = KsGMapMap.gmap.getZoom();
urlArg += ( temp_zoom != ksgmap_default_zoom ? "&zoom=" + temp_zoom : "" ); //ズーム
urlArg += ( temp_type != ksgmap_default_type ? "&type=" + temp_type : "" ); //タイプ
urlArg += ( ksgmap_import_current_file && ksgmap_import_current_file != ksgmap_import_file ? "&import=" + ksgmap_import_current_file : "" ); //XMLファイル名
}
if( this.userMessageEditor.message && type != "item" ){ //ユーザーメッセージ
urlArg += "&message=" + this.userMessageEditor.message;
}
this.url = urlArg;
//「このページのURL」表示欄がある場合
if( ksgmap_html_mapInfo_url ){ this.dispURL(); }
}
//□マップ情報 - ユーザーメッセージ編集機能 - 開く
function KsGMapInfo_userMessageEditor_open(){
var html = this.html;
var message = decodeURIComponent( this.message );
message = KsGMapCommon.HTML.encode( message ); //エンコードしてタグを無効化
message = message.replace( "|" , "\n" ); // | を改行に変換
html = KsGMapCommon.String.convTemplate( html , { message : message } ); //既にあるメッセージを置換
var center = KsGMapMap.gmap.getCenter();
center.x = center.lng(); center.y = center.lat(); //【v3】
var layoutSize = KsGMapCommon.HTML.getLayoutSize( html );
KsGMapMap.gmap.openInfoWindowHtml( new google.maps.LatLng( center.y , center.x ) , "" + html + "
" );
}
//□マップ情報 - ユーザーメッセージ編集機能 - 実行
function KsGMapInfo_userMessageEditor_submit(){
var message = document.getElementById( "ksgmsp--mapInfo-userMessageEditor-textarea" ).value;
message = message.replace( "\n" , "|" ); //改行を|に変換
message = encodeURIComponent( message );
this.message = message;
KsGMapMap.infoWindow.close();
KsGMapInfo.setURL( "point" ); //「このページのURL」をセット
}
//□マップ情報 - ユーザーメッセージ編集機能 - フォーカスを失った場合
function KsGMapInfo_userMessageEditor_onblur( obj ){
if( KsGMapMap.infoWindow.currentItemID ){ obj.focus(); } //情報ウィンドウが開いている場合はフォーカスを保つ
}
//--------------------------------------------------------------------------------------------------
//□拡張
var KsGMapEX = new function(){
this.callbackList = [];
this.addCallback = KsGMapEX_addCallback;
this.callback = KsGMapEX_callback;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.plugInList = [];
this.addPlugIn = KsGMapEX_addPlugIn;
this.isPlugInExist = KsGMapEX_isPlugInExist;
}
//□拡張 - コールバックの追加
function KsGMapEX_addCallback( callFunc , procFunc ){
if( this.callbackList[ callFunc ] == undefined ){ this.callbackList[ callFunc ] = []; } //未定義の場合Arrayを作る
this.callbackList[ callFunc ][ this.callbackList[ callFunc ].length ] = procFunc; //追加
}
//□拡張 - コールバック処理
function KsGMapEX_callback( ref , arg ){
var callFunc = arg.callee;
if( this.callbackList[ callFunc ] == undefined ){ return false; } //未定義
ref.arg = arg;
var result = { cancelParentProcess : false , returnValue : null }
//引数の作成
var arg = [];
for( var i = 2 ; i < arguments.length ; i++ ){ arg[ i - 2 ] = arguments[ i ]; }
//追加した分だけ繰り返す
for( var i = 0 ; i < this.callbackList[ callFunc ].length ; i++ ){
var func = this.callbackList[ callFunc ][ i ];
if( !func ){ continue; }
var temp_ret = func.apply( ref , arg );
if( temp_ret ){ //戻り値がある場合
if( temp_ret.cancelParentProcess ){ result.cancelParentProcess = temp_ret.cancelParentProcess; }
if( temp_ret.returnValue ){ result.returnValue = temp_ret.returnValue; }
}
}
return result;
}
//□拡張 - プラグインを登録する
function KsGMapEX_addPlugIn( plugInName , version , compatibilityVersion ){
if( compatibilityVersion != undefined && ksgmap__version < compatibilityVersion ){ KsGMapCommon.Error.trigger( "設定エラー:プラグイン( " + plugInName + " )は、この KsGMap本体のバージョンでは動作しません。" , "i003" ); return; }
this.plugInList[ this.plugInList.length ] = plugInName;
}
//□拡張 - プラグインが登録されているかチェックする
function KsGMapEX_isPlugInExist( plugInName ){
for( var i = 0 ; i < this.plugInList.length ; i++ ){ if( this.plugInList[ i ] == plugInName ){ return true; } }
return false;
}
//--------------------------------------------------------------------------------------------------
//□カテゴリデータ
function KsGMapDataCategory( category_id , name , lng , lat , group ){
ksgmap_category[ category_id ] = new KsGMapCategory( category_id , name , lng , lat , group );
}
//□アイテムデータ
function KsGMapDataItem( item_id , category_id , name , lng , lat ){
if( !ksgmap_category[ category_id ] ){ KsGMapCommon.Error.trigger( "データインポートエラー:" + name + "(" + item_id + " )のカテゴリ( " + category_id + " )が定義されていません。" , "i002" , 0 ); }
ksgmap_item[ item_id ] = new KsGMapItem( item_id , category_id , name , lng , lat , arguments , "" );
}
//□XMLファイルからデータをインポート
function KsGMapDataImportXML( xmlDoc ){
KsGMapEX.callback( this , arguments , xmlDoc ); //コールバック
//KsGMap情報を変数に収納
ksgmap__title = KsGMapCommon.XML.getValueByUniqueTag( xmlDoc , "title" ); //タイトル取得(マップナビプラグインの下位互換の為)
KsGMapInfo.xmlInfo = {}; //初期化
var ksgmapinfo = [ "title" , "link" , "author" , "generator" , "createdate" , "lastupdate" ]; //基本データ
for( var i = 0 ; i < ksgmapinfo.length ; i++ ){ KsGMapInfo.xmlInfo[ ksgmapinfo[ i ] ] = KsGMapCommon.XML.getValueByUniqueTag( xmlDoc , ksgmapinfo[ i ] ); }
//各種データをインポート
KsGMapDataImportXML_xml2data( xmlDoc , "category" ); //カテゴリのインポート
KsGMapDataImportXML_xml2data( xmlDoc , "item" ); //アイテムのインポート
KsGMapDataImportXML_xml2data( xmlDoc , "template" ); //テンプレートのインポート
}
//□XMLファイルからデータをインポートする - XMLをデータに変換
function KsGMapDataImportXML_xml2data( xmlDoc , type ){
var count_max = Infinity;
switch( type ){
case "category" : count_max = ksgmap_import_maxCategorys; break;
case "item" : count_max = ksgmap_import_maxItems; break;
}
var temp_xmlData = xmlDoc.documentElement.getElementsByTagName( type ); //カテゴリタグ
for( var i = 0 ; i < temp_xmlData.length ; i++ ){ //すべてのデータタグからデータを取得
var iData = KsGMapCommon.XML.convAttributesToArray( temp_xmlData[ i ] ); //属性を配列に入れ替える
iData[ "flagXML" ] = 1; //XMLデータである識別フラグ
//データを定義
switch( type ){
case "category" : //カテゴリ
ksgmap_category[ iData[ "id" ] ] = new KsGMapCategory( iData[ "id" ] , iData[ "name" ] , iData[ "lng" ] , iData[ "lat" ] , iData[ "group" ] );
break;
case "item" : //アイテム
if( !ksgmap_category[ iData[ "category" ] ] ){ KsGMapCommon.Error.trigger( "データインポートエラー:" + iData[ "name" ] + "( " + iData[ "id" ] + " )のカテゴリ( " + iData[ "category" ] + " )が定義されていません。" , "i002" , 0 ); break; }
ksgmap_item[ iData[ "id" ] ] = new KsGMapItem( iData[ "id" ] , iData[ "category" ] , iData[ "name" ] , iData[ "lng" ] , iData[ "lat" ] , "" , iData );
break;
case "template" : //テンプレート
if( iData[ "id" ] == undefined ){ iData[ "id" ] = "undefined"; }
iData[ "_html" ] = temp_xmlData[i].textContent || //【v3】
temp_xmlData[i].innerText ||
temp_xmlData[i].childNodes[0].nodeValue;
ksgmap_template[ iData[ "id" ] ] = { html : iData[ "_html" ] , attribute : iData };
break;
}
if( i >= ( count_max - 1 ) ){ break; } //最大数を超えた場合
}
}
//□マーカーデータ
function KsGMapDataMarker( key_value , image , shadow , image_suffix , iconSize_w , iconSize_h , shadowSize_w , shadowSize_h , iconAnchor_x , iconAnchor_y , infoWindowAnchor_x , infoWindowAnchor_y ){
//image_suffixが[A-K]のような形式は A,B…J,K に直す
if( image_suffix.match( /(\[([A-Z])-([A-Z])\])/ ) && RegExp.$2.charCodeAt( 0 ) <= RegExp.$3.charCodeAt( 0 ) ){
var temp = [];
for( var i = RegExp.$2.charCodeAt( 0 ) ; i <= RegExp.$3.charCodeAt( 0 ) ; i++ ){ temp[ temp.length ] = String.fromCharCode( i ); }
image_suffix = image_suffix.replace( RegExp.$1 , temp.join( "," ) );
}
ksgmap_marker[ key_value ] = new KsGMapMarker( key_value );
ksgmap_marker[ key_value ].iconfile = image; //GIconの方は書き換えられる為、オリジナルとして保管
ksgmap_marker[ key_value ].siconfile = shadow;
ksgmap_marker[ key_value ].filesuffix = image_suffix.split( "," );
ksgmap_marker[ key_value ].naviprefix = ksgmap_marker[ key_value ].filesuffix;
ksgmap_marker[ key_value ].filesuffix = image_suffix.split( "," );
ksgmap_marker[ key_value ].priority = KsGMapCommon.Array.count( ksgmap_marker ); //優先度(最初が高い)
ksgmap_marker[ key_value ].width = iconSize_w; ksgmap_marker[ key_value ].height = iconSize_h;
ksgmap_marker[ key_value ].swidth = shadowSize_w; ksgmap_marker[ key_value ].sheight = shadowSize_h;
if( key_value.match( /^itemnavi/ ) ){ return ; } //アイテムナビ用画像はここで終わり
//省略時の処理
if( iconAnchor_x == undefined ){ iconAnchor_x = Math.floor( iconSize_w / 2 ); } //アンカーX座標は 幅/2
if( iconAnchor_y == undefined ){ iconAnchor_y = iconSize_h; } //アンカーY座標は 高さ
if( infoWindowAnchor_x == undefined ){ infoWindowAnchor_x = Math.floor( iconSize_w / 2 ); } //アンカーX座標は 幅/2
if( infoWindowAnchor_y == undefined ){ infoWindowAnchor_y = 2; } //アンカーY座標は 2
//GIconの定義
ksgmap_marker[ key_value ].gicon = {
url : image,
size : new google.maps.Size(iconSize_w, iconSize_h),
// anchor: new google.maps.Point(iconAnchor_y, iconAnchor_x),
anchor: new google.maps.Point(iconAnchor_x, iconAnchor_y),
origin: new google.maps.Point(0, 0)
};
if (shadow) {
ksgmap_marker[ key_value ].giconS = {
url : shadow,
size : new google.maps.Size( shadowSize_w || iconSize_w, shadowSize_h || iconSize_h ),
// anchor: new google.maps.Point(iconAnchor_y, iconAnchor_x),
anchor: new google.maps.Point(iconAnchor_x, iconAnchor_y),
origin: new google.maps.Point(0, 0)
};
}
}
//□絞り込み条件データ
function KsGMapDataNarrowCondition( key , condition ){
if( !key.match( /:\d+$/ ) ){ key += ":1"; }
ksgmap_narrowCondition[ key ] = condition;
}
//--------------------------------------------------------------------------------------------------
//□汎用関数
/* 【諸事情で、ここから先は改造/単独利用はご遠慮下さい。KsGMap での利用では問題ありません】 */
var KsGMapCommon = new function(){
this.Array = {};
this.Array.count = KsGMapCommon_Array_count;
this.Array.keys = KsGMapCommon_Array_keys;
this.Array.merge = KsGMapCommon_Array_merge;
this.Array.sort = KsGMapCommon_Array_sort;
this.Data = {};
this.Data.conv3digitcomma = KsGMapCommon_Data_conv3digitcomma;
this.Data.convTemplate = KsGMapCommon_Data_convTemplate;
this.Data.makeAnchorTag = KsGMapCommon_Data_makeAnchorTag;
this.Data.makeImageTag = KsGMapCommon_Data_makeImageTag;
this.Data.sprintf = KsGMapCommon_String_sprintf; //KsGMapCommon.String.sprintf のエイリアス
this.Error = {};
this.Error.trigger = KsGMapCommon_Error_trigger;
this.Event = {};
this.Event.cancel = KsGMapCommon_Event_cancel;
this.HTML = {};
this.HTML.encode = KsGMapCommon_HTML_encode;
this.HTML.makePngTag = KsGMapCommon_HTML_makePngTag;
this.HTML.getLayoutSize = KsGMapCommon_HTML_getLayoutSize;
this.HTML.getWindowSize = KsGMapCommon_HTML_getWindowSize;
this.HTML.openPopup = KsGMapCommon_HTML_openPopup;
this.HTML.closePopup = KsGMapCommon_HTML_closePopup;
this.HTML.setDisplay = KsGMapCommon_HTML_setDisplay;
this.HTML.write = KsGMapCommon_HTML_write;
this.Map = {};
this.Map.convBase10ToBase60 = KsGMapCommon_Map_convBase10ToBase60;
this.Map.convCoordinateGTokyoToWGS84 = KsGMapCommon_Map_convCoordinateGTokyoToWGS84; //この関数は廃止予定
this.Map.convCoordinateWGS84ToGTokyo = KsGMapCommon_Map_convCoordinateWGS84ToGTokyo; // 〃
this.Map.convPointsToDistance = KsGMapCommon_Map_convPointsToDistance;
this.Map.getNearData = KsGMapCommon_Map_getNearData;
this.String = {};
this.String.convTemplate = KsGMapCommon_String_convTemplate;
this.String.repeat = KsGMapCommon_String_repeat;
this.String.sprintf = KsGMapCommon_String_sprintf;
this.Variable = {};
this.Variable.tempValue = [];
this.Variable.convInputValue = KsGMapCommon_Variable_convInputValue;
this.Variable.clearTempValue = KsGMapCommon_Variable_clearTempValue;
this.Variable.getTempValue = KsGMapCommon_Variable_getTempValue;
this.Variable.setTempValue = KsGMapCommon_Variable_setTempValue;
this.XML = {};
this.XML.convAttributesToArray = KsGMapCommon_XML_convAttributesToArray;
this.XML.include = KsGMapCommon_XML_include;
this.XML.getValueByUniqueTag = KsGMapCommon_XML_getValueByUniqueTag;
}
//□汎用関数 - 配列 - 数を返す(キーがStringの配列も含む)
function KsGMapCommon_Array_count( array ){
if( !array ){ return 0; } //arrayが空
var result = 0;
if( array.length ){ result = array.length; } //普通のlengthで取得できたら、それを返す
else { for( var i in array ){ if( i != "clear" ){ result++; } } } //取得できなかったらループで取得
return result;
}
//□汎用関数 - 配列 - キーを配列で返す
function KsGMapCommon_Array_keys( array ){
var result_array = [];
for( var key in array ){ if( key != "clear" ){ result_array[ result_array.length ] = key; } }
return result_array;
}
//□汎用関数 - 配列 - マージする
function KsGMapCommon_Array_merge(){
var result = [];
for( var i = 0 ; i < arguments.length ; i++ ){
for( var temp in arguments[ i ] ){
if( temp == "clear" ){ continue; }
result[ temp ] = arguments[ i ][ temp ];
}
}
return result;
}
/*
//□汎用関数 - 配列 - ソート
function KsGMapCommon_Array_sort( base_array , sort_key , option ){
var sort_str = 0;
var sort_desc = ( option == "desc" ? 1 : 0 );
//ソート用テーブルを作る
var sort_array = new Array();
for( var key in base_array ){
if( key == "clear" ){ continue; }
var l = sort_array.length;
sort_array[ l ] = new Array();
sort_array[ l ][ "key" ] = key;
sort_array[ l ][ "value" ] = base_array[ key ];
if( isNaN( ( sort_key ? base_array[ key ][ sort_key ] : base_array[ key ] ) ) ){ sort_str = 1; } //ひとつでも文字列の型があれば、文字列で比較
}
//基本交換法によるソート
for( var j = sort_array.length ; j >= 0 ; j-- ){
for( var i = 0 ; i < ( j - 1 ) ; i++ ){
var comp_1 = ( sort_key ? sort_array[ i ][ "value" ][ sort_key ] : sort_array[ i ][ "value" ] );
var comp_2 = ( sort_key ? sort_array[ i + 1 ][ "value" ][ sort_key ] : sort_array[ i + 1 ][ "value" ] );
//比較
var result = ( ( !sort_str ? Number( comp_1 ) : String( comp_1 ) ) > ( !sort_str ? Number( comp_2 ) : String( comp_2 ) ) ? 1 : 0 );
//降順オプションの場合、結果を逆転させる
if( sort_desc ){ result = Math.abs( result - 1 ); }
//値の交換
if( result ){
var temp = sort_array[ i + 1 ];
sort_array[ i + 1 ] = sort_array[ i ];
sort_array[ i ] = temp;
}
}
}
//ソート用テーブルから元と同じ形の配列に戻す
var result_array = new Array();
for( var i = 0 ; i < sort_array.length ; i++ ){
result_array[ sort_array[ i ][ "key" ] ] = sort_array[ i ][ "value" ];
}
return result_array;
}
*/
//□汎用関数 - 配列 - ソート
function KsGMapCommon_Array_sort( base_array , sort_key , option ){
var sort_str = 0;
var sort_desc = ( option == "desc" ? 1 : 0 );
//ソート用テーブルを作る
var sort_array = []; var n = 0;
for( var key in base_array ){
var l = sort_array.length;
sort_array[ l ] = [];
sort_array[ l ][ "key" ] = key;
sort_array[ l ][ "value" ] = base_array[ key ];
if( isNaN( ( sort_key ? base_array[ key ][ sort_key ] : base_array[ key ] ) ) ){ sort_str = 1; } //ひとつでも文字列の型があれば、文字列で比較
n++;
}
if( !n ){ return base_array; }
//型変換用匿名関数
var tempChangeType = ( sort_str ? function( v ){ return String( v ); } : function( v ){ return Number( v ); } );
//クイックソートの再帰的ルーチン処理
if( sort_key ){ tempSortObjectRoutine( sort_array , 0 , sort_array.length - 1 ); }
else { tempSortStandardRoutine( sort_array , 0 , sort_array.length - 1 ); }
//ソート用テーブルから元と同じ形の配列に戻す
var result_array = {};
if( !sort_desc ){ for( var i = 0 ; i < sort_array.length ; i++ ){ result_array[ sort_array[ i ][ "key" ] ] = sort_array[ i ][ "value" ]; } }
else { for( var i = sort_array.length - 1 ; i >= 0 ; i-- ){ result_array[ sort_array[ i ][ "key" ] ] = sort_array[ i ][ "value" ]; } }
return result_array;
//クイックソートの再帰的ルーチン(普通版)
function tempSortStandardRoutine( sort_array , first , last ){
var x = tempChangeType( sort_array[ Math.floor( ( first + last ) / 2 ) ].value ); var i = first; var j = last;
while( true ){
while( tempChangeType( sort_array[ i ].value ) < x ){ i++; }
while( x < tempChangeType( sort_array[ j ].value ) ){ j--; }
if ( i >= j ){ break; }
var t = sort_array[ i ]; sort_array[ i ] = sort_array[ j ]; sort_array[ j ] = t; i++; j--;
}
//再帰的処理
if( first < i - 1 ){ tempSortStandardRoutine( sort_array , first , i - 1 ); }
if( j + 1 < last ){ tempSortStandardRoutine( sort_array , j + 1 , last ); }
}
//クイックソートの再帰的ルーチン(オブジェクト版)
function tempSortObjectRoutine( sort_array , first , last ){
var x = tempChangeType( sort_array[ Math.floor( ( first + last ) / 2 ) ].value[ sort_key ] ); var i = first; var j = last;
while( true ){
while( tempChangeType( sort_array[ i ].value[ sort_key ] ) < x ){ i++; }
while( x < tempChangeType( sort_array[ j ].value[ sort_key ] ) ){ j--; }
if ( i >= j ){ break; }
var t = sort_array[ i ]; sort_array[ i ] = sort_array[ j ]; sort_array[ j ] = t; i++; j--;
}
//再帰的処理
if( first < i - 1 ){ tempSortObjectRoutine( sort_array , first , i - 1 ); }
if( j + 1 < last ){ tempSortObjectRoutine( sort_array , j + 1 , last ); }
}
}
//□汎用関数 - データ - 数値に3桁毎にカンマを振る
function KsGMapCommon_Data_conv3digitcomma( num , failed ){
if( isFinite( num ) ){ //数値
num = String( num );
while( num != ( num = num.replace( /^(-?\d+)(\d{3})(\.?\d*)/ , "$1,$2$3" ) ) ){}
var result = num;
} else { //数値じゃない
var result = ( typeof( failed ) != "undefined" ? failed : num );
}
return result;
}
//□汎用関数 - データ - テンプレート変換をする
function KsGMapCommon_Data_convTemplate( replace_list , template_id ){
if( template_id == undefined ){ template_id = "undefined"; }
if( !ksgmap_template[ template_id ] ){ return "Template Not Fount!"; } //見つからない場合
var result = KsGMapCommon.String.convTemplate( ksgmap_template[ template_id ].html , replace_list );
return result;
}
//□汎用関数 - データ - タグの作成(共通)
function KsGMapCommon_Data__makeTag( tagName , endtag , attribute , innerHTML ){
var result = "<" + tagName; //タグ名
for( var key in attribute ){ //属性
if( key != "clear" && !key.match( /^_/ ) ){ result += " " + key + "=\"" + attribute[ key ] + "\""; }
}
result += ( endtag ? ">" + innerHTML + "" + tagName + ">" : " />" ); //要素と終了タグ
return result;
}
//□汎用関数 - データ - アンカータグの作成
function KsGMapCommon_Data_makeAnchorTag( url , innerHTML , attribute , failed ){
var reg = new RegExp( "^https?:\/\/[\x23-\x2f0-9a-zA-Z_!:;=?\@~]+$|^[\x23-\x2f0-9a-zA-Z_!;=?\@~]+$" ); //URLの正規表現
if( url.match( reg ) ){ //URL
if( !attribute ){ attribute = {}; }
attribute.href = url;
if( !attribute.target && ksgmap_link_type == 2 ){ attribute.target = "_blank"; }
var result = KsGMapCommon_Data__makeTag( "a" , true , attribute , innerHTML );
} else { //URLじゃない
var result = ( typeof( failed ) != "undefined" ? failed : url );
}
return result;
}
//□汎用関数 - データ - イメージタグの作成 【この関数はまだ正しく動作しない!】
function KsGMapCommon_Data_makeImageTag( src , width , height , attribute, failed ){
var img = new Image()
img.src = src;
//画像か否かのチェック
if( ksgmap__ua.MSIE ){ var isImg = ( img.mimeType ? 1 : 0 ); }
else { var isImg = ( img.width ? 1 : 0 ); }
if( isImg ){ //画像
if( !attribute ){ attribute = {}; }
if( attribute._PreserveAspectRatio || attribute._PAR ){ //同アスペクト比での縮尺サイズを取得
var resize = KsGMapCommon_Data_makeImageTag_getSizePreserveAspectRatio( img.width , img.height , width , height )
width = resize.width; height = resize.height;
attribute.style = ( attribute.style ? attribute.style + " " : "" ) + "margin: " + resize.marginY + "px " + resize.marginX + "px " + resize.marginY + "px " + resize.marginX + "px;";
}
attribute.src = src;
attribute.width = ( width ? width : img.width );
attribute.height = ( height ? height : img.height );
attribute.alt = ( attribute.alt ? attribute.alt : "" );
var result = KsGMapCommon_Data__makeTag( "img" , false , attribute );
} else { //画像じゃない
var result = ( typeof( failed ) != "undefined" ? failed : src );
}
return result;
}
//□汎用関数 - データ - イメージタグの作成 - 同アスペクト比での縮尺サイズを取得
function KsGMapCommon_Data_makeImageTag_getSizePreserveAspectRatio( base_width , base_height , resize_width , resize_height ){
var result = {};
//新しいサイズと余白の計算
if( ( resize_width / base_width ) < ( resize_height / base_height ) ){ //横に余白の場合
result.width = resize_width; result.height = Math.round( base_height * ( resize_width / base_width ) );
result.marginX = 0; result.marginY = ( resize_height - result.height ) / 2;
} else if( ( resize_width / base_width ) > ( resize_height / base_height ) ){ //縦に余白の場合
result.width = Math.round( base_width * ( resize_height / base_height ) ); result.height = resize_height;
result.marginX = ( resize_width - result.width ) / 2; result.marginY = 0;
} else { //余白無し(一致)の場合
result.width = resize_width ; result.height = resize_height;
result.marginX = 0; result.marginY = 0;
}
return result;
}
//□汎用関数 - エラー - トリガー
function KsGMapCommon_Error_trigger( message , errNo , errLevel ){
if( errLevel == undefined ){ errLevel = 0; }
if( errLevel == 0 && !ksgmap_debug_mode ){ return true; } //エラーレベル0:デバッグモードでのみアラート
alert( message );
return false;
}
//□汎用関数 - イベント - キャンセル
function KsGMapCommon_Event_cancel( event ){
if( ksgmap__ua.MSIE ){ //IE
event.returnValue = false;
} else { //Firefoxとか
event.preventDefault();
}
return false;
}
//□汎用関数 - HTML - エンコード
function KsGMapCommon_HTML_encode( value ){
var convList = [ "&:&" , "<:<" , ">:>" , "\":"" , "':'" ];
for( var i = 0 ; i < convList.length ; i++ ){
var temp = convList[ i ].split( ":" );
value = value.replace( new RegExp( temp[ 0 ] , "g" ) , temp[ 1 ] );
}
return value;
}
//□汎用関数 - HTML - PNG用タグを生成
function KsGMapCommon_HTML_makePngTag( filename , width , height , attributes , sizingmethod ){
if( !sizingmethod ){ sizingmethod = "scale"; }
//属性の処理
var temp_attributes = ""; var style = "";
if( attributes ){
for( var name in attributes ){ if( name != "style" ){ temp_attributes += " " + name + "=\"" + attributes[ name ] + "\""; } } //style属性以外
if( attributes.style ){ style = attributes.style; } //style属性
}
//タグの生成
if( ksgmap__ua.MSIE && ksgmap__ua.MSIE < 7.0 && filename.match( /\.png$/ ) ){
var result = "
";
} else {
var result = " ";
}
return result;
}
//□汎用関数 - HTML - レイアウトのサイズを取得する
function KsGMapCommon_HTML_getLayoutSize( html ){
var temp_obj = document.getElementById( "ksgmap--common-getlayoutsize" );
temp_obj.innerHTML = "" + html + "
";
var result = { width : temp_obj.firstChild.offsetWidth , height : temp_obj.firstChild.offsetHeight };
return result;
}
//□汎用関数 - HTML - ウィンドウのサイズを取得する
function KsGMapCommon_HTML_getWindowSize(){
var result = {};
var mode_standard = ( document.compatMode == "CSS1Compat" ? 1 : 0 );
if( ksgmap__ua.MSIE && mode_standard ){ //IE標準
result.width = document.body.offsetWidth; result.height = document.documentElement.offsetHeight;
} else if( ( ksgmap__ua.MSIE && !mode_standard ) ){ //IE互換
result.width = document.body.clientWidth; result.height = document.body.clientHeight;
} else if( ksgmap__ua.Gecko || ksgmap__ua.Safari ){ //Gecko/Safari
result.width = document.body.offsetWidth; result.height = window.innerHeight;
} else if( ksgmap__ua.Opera ){ //Opera
result.width = document.body.offsetWidth - 20; result.height = window.innerHeight;
}
return result;
}
//□汎用関数 - HTML - ポップアップを開く
function KsGMapCommon_HTML_openPopup( id , option ){
if( option == undefined ){ option = ""; }
var obj_box = document.getElementById( id );
if( !obj_box ){ KsGMapCommon.Error.trigger( "設定エラー:指定されたID( " + id + " )のHTMLタグが存在しません。" , "i004" , 0 ); return false; }
obj_box.style.display = "block"; //表示
//ユーザー指定スタイルを設定
var temp = [ "width" , "height" , "left" , "top" , "right" , "bottom" ];
for( var i = 0 ; i < temp.length ; i++ ){
if( option.match( new RegExp( temp[ i ] + "\\s?[=:]\\s?([0-9]+)(px|%)?" , "i" ) ) ){ obj_box.style[ temp[ i ] ] = RegExp.$1 + ( RegExp.$2 ? RegExp.$2 : "px" ); }
}
if( option.match( /left\s?[=:]\s?center/i ) ){ obj_box.style.left = String( ( obj_box.parentNode.offsetWidth - obj_box.offsetWidth ) / 2 ) + "px"; }
if( option.match( /top\s?[=:]\s?center/i ) ){ obj_box.style.top = String( ( obj_box.parentNode.offsetHeight - obj_box.offsetHeight ) / 2 ) + "px"; }
obj_box.style.zIndex = 301;
//影の表示
if( !option.match( /shadow\s?[=:]\s?(?:0|off|false)/ ) ){
var obj_shadow = document.getElementById( "ksgmap--common-popupShadow" );
obj_shadow.style.display = "block";
//影のDIVの位置、サイズを指定
var shadow_width = obj_box.offsetWidth + 28; var shadow_height = obj_box.offsetHeight + 28;
obj_shadow.style.left = String( obj_box.offsetLeft ) + "px"; obj_shadow.style.top = String( obj_box.offsetTop ) + "px";
obj_shadow.style.width = String( shadow_width ) + "px"; obj_shadow.style.height = String( shadow_height ) + "px";
obj_shadow.style.zIndex = 300;
var insertTag = ""; //影画像を配置
insertTag += KsGMapCommon.HTML.makePngTag( ksgmap_image_path + "ksgmap_popup_shadow_bl.png" , 28 , 28 , { style : "position: absolute; left: 0px; top: " + String( obj_box.offsetHeight ) + "px;" } );
insertTag += KsGMapCommon.HTML.makePngTag( ksgmap_image_path + "ksgmap_popup_shadow_br.png" , 28 , 28 , { style : "position: absolute; left: " + String( obj_box.offsetWidth ) + "px; top: " + String( obj_box.offsetHeight ) + "px;" } );
insertTag += KsGMapCommon.HTML.makePngTag( ksgmap_image_path + "ksgmap_popup_shadow_tr.png" , 28 , 28 , { style : "position: absolute; left: " + String( obj_box.offsetWidth ) + "px; top: 0px;" } );
insertTag += KsGMapCommon.HTML.makePngTag( ksgmap_image_path + "ksgmap_popup_shadow_bc.png" , ( shadow_width - 56 ) , 28 , { style : "position: absolute; left: 28px; top: " + String( obj_box.offsetHeight ) + "px;" } );
insertTag += KsGMapCommon.HTML.makePngTag( ksgmap_image_path + "ksgmap_popup_shadow_cr.png" , 28 , ( shadow_height - 56 ) , { style : "position: absolute; left: " + String( obj_box.offsetWidth ) + "px; top: 28px;" } );
obj_shadow.innerHTML = insertTag;
}
//閉じるボタンの追加
if( !option.match( /close\s?[=:]\s?(?:0|off|false)/ ) && !document.getElementById( "ksgmap--common-popupClose-" + id ) ){
obj_box.innerHTML = obj_box.innerHTML + "";
}
//セレクトボックスの非表示(IEのみ)
if( ksgmap__ua.MSIE && !option.match( /select\s?[=:]\s?(?:1|on|true)/ ) ){
var obj_select = document.getElementsByTagName( "select" );
for( var i = 0 ; i < obj_select.length ; i++ ){ obj_select[ i ].style.visibility = "hidden"; }
}
//マップのドラッグと情報ウィンドウの表示を制限する
if( !option.match( /maplimit\s?[=:]\s?(?:0|off|false)/ ) ){
// if( !ksgmap_limit_dragging ){ KsGMapMap.gmap.disableDragging(); } 【v3】
// KsGMapMap.infoWindow.enabled = false;
}
}
//□汎用関数 - HTML - ポップアップを閉じる
function KsGMapCommon_HTML_closePopup( id ){
var obj_box = document.getElementById( id );
var obj_shadow = document.getElementById( "ksgmap--common-popupShadow" );
var obj_select = document.getElementsByTagName( "select" );
if( !obj_box ){ KsGMapCommon.Error.trigger( "設定エラー:指定されたID( " + id + " )のHTMLタグが存在しません。" , "i004" , 0 ); return false; }
//閉じるボタンがある場合、削除
if( document.getElementById( "ksgmap--common-popupClose-" + id ) ){ obj_box.removeChild( document.getElementById( "ksgmap--common-popupClose-" + id ) ); }
//非表示
obj_box.style.display = "none"; //表示
obj_shadow.style.display = "none"; //表示
//セレクトボックスを再表示
if( ksgmap__ua.MSIE ){ for( var i = 0 ; i < obj_select.length ; i++ ){ obj_select[ i ].style.visibility = "visible"; } }
/* 【v3】
//マップのドラッグと情報ウィンドウの表示の制限を解除
if( !ksgmap_limit_dragging ){ KsGMapMap.gmap.enableDragging(); }
KsGMapMap.infoWindow.enabled = true;
*/
}
//□汎用関数 - HTML - 表示状態をセットする
function KsGMapCommon_HTML_setDisplay( id , type ){
var obj = document.getElementById( id );
if( !obj ){ return false; }
if( !ksgmap__ua.Opera ){ obj.style.display = ( type ? "block" : "none" ); } //Opera以外
else { obj.style.visibility = ( type ? "visible" : "hidden" ); } //Opera
return true;
}
//□汎用関数 - HTML - HTMLを書き込む
function KsGMapCommon_HTML_write( id , html ){
if( !id || !document.getElementById( id ) ){ return false; }
document.getElementById( id ).innerHTML = html;
return true;
}
//□汎用関数 - マップ - 10進数表記を60進数表記に変換
function KsGMapCommon_Map_convBase10ToBase60( base10 ){
base10 = parseFloat( base10 );
var minus = 0;
if( base10 < 0 ){ base10 *= -1 ; minus = 1; } //西経もしくは南緯の場合
var base60_1 = Math.floor( base10 ); //度
base10 = ( base10 - base60_1 ) * 60;
var base60_2 = Math.floor( base10 ); //分
base10 = ( base10 - base60_2 ) * 60;
var base60_3 = base10; //秒
//戻り値は最初の1文字は+もしくは-、以降 度.分.秒.小数点以下… となる
var result =
( !minus ? "+" : "-" ) +
String( base60_1 ) + "." +
( base60_2 < 10 ? "0" : "" ) + String( base60_2 ) + "." +
( base60_3 < 10 ? "0" : "" ) + String( base60_3 );
//第二引数(緯度)が指定されている場合、それを再帰的に取得しオブジェクトで返す
if( arguments[ 1 ] ){
var result_obj = {};
result_obj.lng = result; result_obj.lat = KsGMapCommon_Map_convBase10ToBase60( arguments[ 1 ] );
return result_obj;
} else {
return result;
}
}
//□汎用関数 - マップ - Google東京測地系(※)から世界測地系(WGS84)に変換 ※世界計測系からの平行移動
function KsGMapCommon_Map_convCoordinateGTokyoToWGS84(){
var result = {};
if( typeof( arguments[ 0 ] ) == "object" ){ result.lng = arguments[ 0 ].x; result.lat = arguments[ 0 ].y; }
else { result.lng = arguments[ 0 ]; result.lat = arguments[ 1 ]; }
//Googleの定めた東京測地系の平行移動の場所
if( ( 115 < result.lng && result.lng < 152 ) && ( 30 < result.lat && result.lat < 50 ) ){
result.lng -= 0.0032027777777777775;
result.lat += 0.003236111111111111;
}
return result;
}
//□汎用関数 - マップ - 世界測地系(WGS84)からGoogle東京測地系(※)に変換 ※世界計測系からの平行移動
function KsGMapCommon_Map_convCoordinateWGS84ToGTokyo(){
var result = {};
if( typeof( arguments[ 0 ] ) == "object" ){ result.lng = arguments[ 0 ].x; result.lat = arguments[ 0 ].y; }
else { result.lng = arguments[ 0 ]; result.lat = arguments[ 1 ]; }
//Googleの定めた東京測地系の平行移動の場所
if( ( 115 < result.lng && result.lng < 152 ) && ( 30 < result.lat && result.lat < 50 ) ){
result.lng += 0.0032027777777777775;
result.lat -= 0.003236111111111111;
}
return result;
}
//□汎用関数 - マップ - 座標間から距離を取得する
function KsGMapCommon_Map_convPointsToDistance( lng1 , lat1 , lng2 , lat2 ){
var lng1 = ( lng1 * Math.PI ) / 180;
var lat1 = ( lat1 * Math.PI ) / 180;
var lng2 = ( lng2 * Math.PI ) / 180;
var lat2 = ( lat2 * Math.PI ) / 180;
var t = Math.sin( lat1 ) * Math.sin( lat2 ) + Math.cos( lat1 ) * Math.cos( lat2 ) * Math.cos( lng1 - lng2 );
var d = 20000 * Math.acos( t ) / Math.PI;
return d;
}
//□汎用関数 - マップ - 現在地から近いデータを取得する
function KsGMapCommon_Map_getNearData( data , type , limit ){
if( !type ){ type = "all"; }
if( !limit ){ limit = Infinity; }
var conditionType = 0;
var center = KsGMapMap.gmap.getCenter(); //現在地の座標を取得
center.x = center.lng(); center.y = center.lat(); //【v3】
//条件の作成
if( type.match( /^(.+):(.+)$/ ) ){ type = RegExp.$1; var ref = RegExp.$2.split( "," ); } //typeの引数を分離
switch( type ){
case "map" : var conditionType = 1; //マップ内(条件タイプ1)
var bounds = KsGMapMap.gmap.getBounds(); //バウンドの取得
var tempSW = bounds.getSouthWest(); var tempNE = bounds.getNorthEast();
tempSW.x = tempSW.lng(); tempSW.y = tempSW.lat(); tempNE.x = tempNE.lng(); tempNE.y = tempNE.lat(); //【v3】
var minLng = tempSW.x; var maxLng = tempNE.x; var minLat = tempSW.y; var maxLat = tempNE.x;
break;
case "dist": var conditionType = 1; //指定範囲内(条件タイプ1) ex: dist:0.01
ref[ 0 ] = parseFloat( ref[ 0 ] );
var minLng = center.x - ref[ 0 ]; var maxLng = center.x + ref[ 0 ]; var minLat = center.y - ref[ 0 ]; var maxLat = center.y + ref[ 0 ];
break;
}
//ソート用配列の作成
var sort_array = [];
for( var id in data ){
if( key == "clear" || !data[ id ].lng || !data[ id ].lat ){ continue; }
//条件
if( conditionType == 1 && ( data[ id ].lng < minLng || maxLng < data[ id ].lng || data[ id ].lat < minLat || maxLat < data[ id ].lat ) ){ continue; }
sort_array[ id ] = KsGMapCommon.Map.convPointsToDistance( data[ id ].lng , data[ id ].lat , center.x , center.y ); //ソート用配列に距離を算出したものを入れる
}
//ソート処理と戻り値の作成
var result_array = []; var c = 1;
if( sort_array ){
sort_array = KsGMapCommon.Array.sort( sort_array ); //ソート処理
for( var key in sort_array ){ //戻り値の生成
if( key == "clear" ){ continue; }
result_array[ result_array.length ] = key;
if( c >= limit ){ break; } else { c++; } //リミット
}
}
return result_array;
}
//□汎用関数 - 文字列 - テンプレート変換
function KsGMapCommon_String_convTemplate( value , replace_list ){
for( var key in replace_list ){ if( key != "clear" && typeof value === "string"){ value = value.replace( new RegExp( "%" + key + "%" , "g" ) , replace_list[ key ] ); } }
return value;
}
//□汎用関数 - 文字列 - 同じ文字を繰り返す
function KsGMapCommon_String_repeat( str , count ){
var result = "";
for( var i = 0 ; i < parseInt( count ) ; i++ ){ result += str; }
return result;
}
//□汎用関数 - 文字列 - 簡易sprintf
function KsGMapCommon_String_sprintf( format ){
var count = 1;
while( format.match( /(%([0-9\.+-]*?)([dfs]))/ ) ){
var value = arguments[ count ];
if( value == undefined ){ continue; }
var replace = RegExp.$1; var parameter = RegExp.$2; var type = RegExp.$3;
format = format.replace( replace , KsGMapCommon_String_sprintf_replace( replace , parameter , type , value ) );
count++;
}
return format;
}
//□汎用関数 - 文字列 - 簡易sprintf - 置換
function KsGMapCommon_String_sprintf_replace( format , parameter , type , value ){
switch( type ){
case "d" : value = parseInt( value ); break; //整数
case "f" : value = parseFloat( value ); break; //小数(浮動小数)
case "s" : value = String( value ); break; //整数
}
var base_value = value;
//▽base_value => value
//小数点以下切り詰め %~.2 3.145 ⇒ 3.14 / 3.1 ⇒ 3.10
if( type == "f" && parameter.match( /\.([1-9]+)$/ ) ){
value = String( parseInt( base_value ) ) + "." + String( Math.floor( ( base_value - parseInt( base_value ) ) * Math.pow( 10 , parseInt( RegExp.$1 ) ) ) );
}
//▽value => value
//文字列切り詰め %~.3s HOGE ⇒ HOG
if( type == "s" && parameter.match( /\.([1-9]+)$/ ) ){
value = value.substring( 0 , parseInt( RegExp.$1 ) );
}
//符号を付ける %+~d 100 ⇒ +100
if( ( type == "d" || type == "f" ) && parameter.match( /^\+/ ) && base_value > 0 ){
value = "+" + String( value );
}
//余白を右に追加 %-7d HOGE ⇒ |HOGE |
if( parameter.match( /^\+?-([1-9][0-9]*)/ ) ){
value = String( value ) + KsGMapCommon.String.repeat( " " , parseInt( RegExp.$1 ) - String( value ).length );
}
//余白を左に追加 %3d HOGE ⇒ | HOGE| %03d 50 ⇒ |050|
if( parameter.match( /^\+?(0)?([1-9][0-9]*)/ ) ){
var temp1 = RegExp.$1; var temp2 = RegExp.$2; var temp3 = ( String( value ).match( /^(\+|-)/ ) ? RegExp.$1 : 0 );
value = ( temp3 ? temp3 : "" ) + KsGMapCommon.String.repeat( ( temp1 != "" ? temp1 : " " ) , parseInt( temp2 ) - String( value ).length ) + String( value ).substring( ( temp3 ? 1 : 0 ) );
}
return value;
}
//□汎用関数 - 変数 - 入力変数を変換する
function KsGMapCommon_Variable_convInputValue( tempArg , option ){
if( typeof( tempArg ) == "object" && option && option.match( /ISCHECKED/i ) ){ var result = tempArg.checked; } //チェックボックス用
else if( typeof( tempArg ) == "object" ){ var result = tempArg.value; } //セレクトボックス等
else { var result = tempArg; } //アンカーやボタンなど値直接指定
return result;
}
//□汎用関数 - 変数 - 一時値をクリア
function KsGMapCommon_Variable_clearTempValue( id ){
KsGMapCommon.Variable.tempValue[ id ] = "";
}
//□汎用関数 - 変数 - 一時値を取得
function KsGMapCommon_Variable_getTempValue( id , isClear ){
var result = KsGMapCommon.Variable.tempValue[ id ];
if( isClear != false ){ KsGMapCommon.Variable.tempValue[ id ] = ""; }
return result;
}
//□汎用関数 - 変数 - 一時値をセット
function KsGMapCommon_Variable_setTempValue( value , id ){
if( typeof( id ) == "undefined" ){ id = "TV" + String( new Date().getTime() ) + String( Math.ceil( Math.random() * 10000 ) ); } //ID生成
KsGMapCommon.Variable.tempValue[ id ] = value;
return id;
}
//□汎用関数 - XML - 属性を配列に入れ替える
function KsGMapCommon_XML_convAttributesToArray( xmlData ){
var result = {};
for( var i = 0 ; i < xmlData.attributes.length ; i++ ){
var temp = xmlData.attributes.item( i ).nodeValue;
temp = temp.replace( /'/g , "'" );
result[ xmlData.attributes.item( i ).nodeName ] = temp;
}
return result;
}
//□汎用関数 - XML - インクルード
function KsGMapCommon_XML_include( filename , func , option ){
if( option == undefined ){ option = "" };
if( ksgmap_debug_mode || !ksgmap_import_cache || option.match( /CACHE:(?:0|OFF)/i ) ){ filename += ( !filename.match( /\?/ ) ? "?" : "&" ) + "rand=" + String( Math.random() ).substring( 2 , 8 ); } //デバッグ時にキャッシュを読まないように、ファイル名をユニークにする
// var ksgmap_request = GXmlHttp.create(); 【v3】
if (ksgmap__ua.MSIE && ksgmap__ua.MSIE < 7.0) {
var ksgmap_request = new ActiveXObject("Msxml2.XMLHTTP");
} else {
var ksgmap_request = new XMLHttpRequest();
}
var method = ( option.match( /METHOD:POST/i ) ? "POST" : "GET" );
ksgmap_request.open( method , filename , true ); //XMLファイルを読み込む
ksgmap_request.onreadystatechange = function(){
if( ksgmap_request.readyState != 4 ){ return; }
var xmlDoc = ksgmap_request.responseXML;
if( !xmlDoc.documentElement ){ KsGMapCommon.Error.trigger( "データインポートエラー:ファイルが存在しないか、XMLファイルではありません。" , "i001" , 3 ); return false; }
func.apply( null , [ xmlDoc ] ); //引数の関数実行
}
ksgmap_request.send( null );
}
//□汎用関数 - XML - ユニークなタグから要素の値を取得する
function KsGMapCommon_XML_getValueByUniqueTag( xmlDoc , tagName ){
var temp_xmlData = xmlDoc.documentElement.getElementsByTagName( tagName );
// var result = GXml.value( temp_xmlData[ 0 ] ); 【v3】
var result = (temp_xmlData && temp_xmlData[0] ? temp_xmlData[0].textContent || temp_xmlData[0].innerText : undefined);
return result;
}
//--------------------------------------------------------------------------------------------------
//□汎用機能
var KsGMapFunc = new function(){
this.category = {};
this.category.change = KsGMapFunc_category_change;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.html = {};
this.html.popupOpen = KsGMapFunc_html_popupOpen;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.item = {};
this.item.openInfoWindow = KsGMapFunc_item_openInfoWindow;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.itemNavi = {};
this.itemNavi.autoZoom = KsGMapFunc_itemNavi_autoZoom;
this.itemNavi.changeThirdRow = KsGMapFunc_itemNavi_changeThirdRow;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.link = {};
this.link.select = KsGMapFunc_link_select;
this.link.ksgmap = KsGMapFunc_link_ksgmap;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.map = {};
this.map.changeType = KsGMapFunc_map_changeType;
this.map.changeZoom = KsGMapFunc_map_changeZoom;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.mapInfo = {};
this.mapInfo.select = KsGMapFunc_mapInfo_select;
this.mapInfo.urlAddFavorite = KsGMapFunc_mapInfo_urlAddFavorite;
this.mapInfo.urlCopyToClipboard = KsGMapFunc_mapInfo_urlCopyToClipboard;
this.mapInfo.urlLink = KsGMapFunc_mapInfo_urlLink;
this.mapInfo.urlSendMail = KsGMapFunc_mapInfo_urlSendMail;
this.mapInfo.urlOpenUserMessageEditor = KsGMapFunc_mapInfo_urlOpenUserMessageEditor;
this.mapInfo.pointChangeBase = KsGMapFunc_mapInfo_pointChangeBase;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.move = {};
this.move.toLatLng = KsGMapFunc_move_toLatLng;
this.move.toLngLat = KsGMapFunc_move_toLngLat;
this.move.select = KsGMapFunc_move_select;
this.move.toNeighbor = KsGMapFunc_move_toNeighbor;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.search = {};
this.search.itemName = {};
this.search.itemName.submit = KsGMapFunc_search_itemName_submit;
this.search.itemName.keydown = KsGMapFunc_search_itemName_keydown;
this.search.itemName.clear = KsGMapFunc_search_itemName_clear;
this.search.narrow = {};
this.search.narrow.change = KsGMapFunc_search_narrow_change;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.sort = {};
this.sort.change = KsGMapFunc_sort_change;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
this.userControl = {};
this.userControl.marker = {};
this.userControl.marker.changeVisibility = KsGMapFunc_userControl_marker_changeVisibility;
this.userControl.marker.hidden = KsGMapFunc_userControl_marker_hidden;
this.userControl.marker.visible = KsGMapFunc_userControl_marker_visible;
this.userControl.centerMarker = {};
this.userControl.centerMarker.changeVisibility = KsGMapFunc_userControl_centerMarker_changeVisibility;
this.userControl.centerMarker.hidden = KsGMapFunc_userControl_centerMarker_hidden;
this.userControl.centerMarker.visible = KsGMapFunc_userControl_centerMarker_visible;
this.userControl.mouseWheel = {};
this.userControl.mouseWheel.changeStatus = KsGMapFunc_userControl_mouseWheel_changeStatus;
this.userControl.mouseWheel.changeDirection = KsGMapFunc_userControl_mouseWheel_changeDirection;
}
//□汎用機能 - カテゴリ - 変更
function KsGMapFunc_category_change( event , category_id ){
if( ksgmap_category[ category_id ] ){
if( ksgmap_html_categoryNavi ){ KsGMapCategoryNavi.change( category_id ); } //セレクトボックスを変更
ksgmap_category[ category_id ].change();
}
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセル
}
//□汎用機能 - HTML - ポップアップを開く
function KsGMapFunc_html_popupOpen( event , target_id , option ){
KsGMapCommon.HTML.openPopup( target_id , option );
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセル
}
//□汎用機能 - アイテム - 情報ウィンドウを表示
function KsGMapFunc_item_openInfoWindow( event , item_id ){
if( ksgmap_item[ item_id ] ){
var option = ( ksgmap_item[ item_id ].category != ksgmap_focus_category ? "ADDMARKER" : "" ); //他のカテゴリの場合、マーカーが無いと変になっちゃうので付加
ksgmap_item[ item_id ].moveCenter();
ksgmap_item[ item_id ].openInfoWindowByItemNavi( 0 , option );
}
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセル
}
//□汎用機能 - アイテムナビ - 自動ズーム(マップ上のアイテムをすべて表示)
function KsGMapFunc_itemNavi_autoZoom( event ){
if( !ksgmap_html_itemNavi_autoZoom || document.getElementById( ksgmap_html_itemNavi_autoZoom ).disabled == false ){ //すでに範囲内でアンカー/ボタンが無効の場合は動作しない
ksgmap_category[ ksgmap_focus_category ].change( 'AUTOCENTERING:2' );
}
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□汎用機能 - アイテムナビ - 3列目を変更
function KsGMapFunc_itemNavi_changeThirdRow( event , tempValue ){
ksgmap_itemNavi_thirdRow = KsGMapCommon.Variable.convInputValue( tempValue );
ksgmap_category[ ksgmap_focus_category ].marking(); //マーキングしなおす
return KsGMapCommon.Event.cancel( event );
}
//□汎用機能 - リンク - 処理(共通)
function KsGMapFunc_link__commonLink( event , url ){
switch( ksgmap_link_type ){
case 1 : location.href = url; break; //現在のブラウザで移動
case 2 : window.open( url , "_blank" ); break; //新しいウィンドウで開く
}
KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□汎用機能 - リンク - イベント取得(共通)
function KsGMapFunc_link__getEvent( temp_event ){
if( typeof( temp_event ) == "string" ){
var event = KsGMapCommon_Variable_getTempValue( temp_event ); //一時値から取得
} else {
var event = temp_event;
}
return event;
}
//□汎用機能 - リンク - セレクトボックスの処理
function KsGMapFunc_link_select( event , form ){
var site = form.value;
if( site == "-" ){ return ; }
if( site.match( /^ksgmap,(.+)$/ ) ){ //他のKsGMapへのリンク
KsGMapFunc.link.ksgmap( event , RegExp.$1 );
} else if( site.match( /^KsGMapPlugIn/ ) ){ //プラグイン等
var eid = KsGMapCommon.Variable.setTempValue( event ); //イベント変数を一時的に記録
eval( site + "( '" + eid + "' );" );
} else if( KsGMapEX.isPlugInExist( "mapLink" ) ) { //それ以外のリンク(マップリンク・プラグイン Ver1.00)
var eid = KsGMapCommon.Variable.setTempValue( event ); //イベント変数を一時的に記録
eval( "KsGMapPlugIn_mapLink_" + site + "( '" + eid + "' );" );
}
form.selectedIndex = 0; //選択肢を先頭に戻しておく(連続して同じ値が選択できなくなる為)
}
//□汎用機能 - リンク - KsGMap
function KsGMapFunc_link_ksgmap( temp_event , url ){ /* この関数は改造禁止です */
var event = KsGMapFunc_link__getEvent( temp_event );
var center = KsGMapMap.gmap.getCenter(); //中央座標取得
center.x = center.lng(); center.y = center.lat(); //【v3】
//リンクの引数
url += "?lng=" + center.x;
url += "&lat=" + center.y;
url += "&zoom=" + KsGMapMap.gmap.getZoom();
url += "&referer=" + escape( location.href );
//共通リンク処理にてリンクする
KsGMapFunc_link__commonLink( event , url );
return false;
}
//□汎用機能 - マップ - タイプの変更
function KsGMapFunc_map_changeType( event , type ){
if( type == "map" ){ KsGMapMap.gmap.setMapTypeId( google.maps.MapTypeId.ROADMAP ); } //マップ
if( type == "satellite" ){ KsGMapMap.gmap.setMapTypeId( google.maps.MapTypeId.SATELLITE ); } //サテライト
if( type == "hybrid" ){ KsGMapMap.gmap.setMapTypeId( google.maps.MapTypeId.HYBRID ); } //デュアル
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□汎用機能 - マップ - ズームの変更
function KsGMapFunc_map_changeZoom( event , tempValue ){
var level = KsGMapCommon.Variable.convInputValue( tempValue );
level = ( String( level ).match( /^[+-][0-9]+$/ ) ? KsGMapMap.gmap.getZoom() + parseInt( level ) : parseInt( level ) );
if( level < 0 ){ level = 0; } else if( level > 17 ){ level = 17; }
KsGMapMap.gmap.setZoom( level );
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□汎用機能 - マップ情報 - セレクトボックスの処理
function KsGMapFunc_mapInfo_select( event , form ){
//alert( form.value );
switch( form.value ){
case "urlAddFavorite" : KsGMapFunc.mapInfo.urlAddFavorite( event ); break; //お気に入りに追加
case "urlCopyToClipboard" : KsGMapFunc.mapInfo.urlCopyToClipboard( event ); break; //クリップボードにコピー
case "urlLink" : KsGMapFunc.mapInfo.urlLink( event ); break; //リンク
case "urlSendMail" : KsGMapFunc.mapInfo.urlSendMail( event ); break; //メールで送信
case "urlOpenUserMessageEditor" : KsGMapFunc.mapInfo.urlOpenUserMessageEditor( event ); break; //ユーザーメッセージ編集
}
form.selectedIndex = 0; //選択肢を先頭に戻しておく(連続して同じ値が選択できなくなる為)
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□汎用機能 - マップ情報 - このページのURLをお気に入りに追加
function KsGMapFunc_mapInfo_urlAddFavorite( event ){
var url = KsGMapInfo.getURL(); //このページのURLを取得
window.external.AddFavorite( url , document.title );
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□汎用機能 - マップ情報 - このページのURLをクリップボードにコピー
function KsGMapFunc_mapInfo_urlCopyToClipboard( event ){
var url = KsGMapInfo.getURL(); //このページのURLを取得
clipboardData.setData( "Text" , url );
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□汎用機能 - マップ情報 - このページのURLにリンク
function KsGMapFunc_mapInfo_urlLink( event ){
var url = KsGMapInfo.getURL(); //このページのURLを取得
location.href = url;
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□汎用機能 - マップ情報 - このページのURLをメールで送信
function KsGMapFunc_mapInfo_urlSendMail( event ){
var url = KsGMapInfo.getURL(); //このページのURLを取得
location.href = "mailto:?body=" + escape( url );
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□汎用機能 - マップ情報 - このページのURLのユーザーメッセージ編集機能を開く
function KsGMapFunc_mapInfo_urlOpenUserMessageEditor( event ){
KsGMapInfo.userMessageEditor.open();
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□汎用機能 - マップ情報 - 緯度/経度の表示の進数を変更
function KsGMapFunc_mapInfo_pointChangeBase( event , base ){
if( !base ){ base = ( ksgmap_mapInfo_point_base == 60 ? 10 : 60 ); } //進数未指定の場合、現在のでは無いものにする
ksgmap_mapInfo_point_base = base;
var center = KsGMapMap.gmap.getCenter();
center.x = center.lng(); center.y = center.lat(); //【v3】
KsGMapInfo.dispPoint( center.x , center.y ); //表示
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□汎用機能 - 移動 - 指定緯度経度
function KsGMapFunc_move_toLatLng( event , lat , lng ){
KsGMapMap.infoWindow.close(); //情報ウィンドウを閉じる
lng = parseFloat( lng ); lat = parseFloat( lat );
KsGMapMap.gmap.panTo( new google.maps.LatLng( lat , lng ) );
return ( event ? KsGMapCommon.Event.cancel( event ) : true ); //イベントをキャンセルしとく
}
//□汎用機能 - 移動 - 指定経度緯度
function KsGMapFunc_move_toLngLat( event , lng , lat ){
return KsGMapFunc.move.toLatLng( event , lat , lng ); //エイリアス
}
//□汎用機能 - 移動 - セレクトボックスの処理
function KsGMapFunc_move_select( event , form ){
if( form.value == "-" ){ return ; }
KsGMapMap.infoWindow.close(); //情報ウィンドウを閉じる
var point = form.value.split( /[,\s\t]/ );
lng = parseFloat( point[ 1 ] ); lat = parseFloat( point[ 0 ] );
KsGMapMap.gmap.panTo( new google.maps.LatLng( lat , lng ) );
}
//□汎用機能 - 移動 - 隣に移動
function KsGMapFunc_move_toNeighbor( event , tempValue ){
KsGMapMap.infoWindow.close(); //情報ウィンドウを閉じる
var direction = KsGMapCommon.Variable.convInputValue( tempValue );
var bounds = KsGMapMap.gmap.getBounds(); //表示範囲の座標を取得
var tempSW = bounds.getSouthWest(); var tempNE = bounds.getNorthEast();
tempSW.x = tempSW.lng(); tempSW.y = tempSW.lat(); tempNE.x = tempNE.lng(); tempNE.y = tempNE.lat(); //【v3】
var center = KsGMapMap.gmap.getCenter(); //中央座標取得
center.x = center.lng(); center.y = center.lat(); //【v3】
var lng = center.x; var lat = center.y;
switch( direction.toLowerCase() ){
case "north" : lat = tempNE.y + ( ( tempNE.y - tempSW.y ) / 3 ); break; //北
case "east" : lng = tempNE.x + ( ( tempNE.x - tempSW.x ) / 3 ); break; //東
case "south" : lat = tempSW.y - ( ( tempNE.y - tempSW.y ) / 3 ); break; //南
case "west" : lng = tempSW.x - ( ( tempNE.x - tempSW.x ) / 3 ); break; //西
}
KsGMapMap.gmap.panTo( new google.maps.LatLng( lat , lng ) );
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□汎用機能 - 検索 - アイテム名 - 実行
function KsGMapFunc_search_itemName_submit( event , form ){
var searchName = document.getElementById( ksgmap_html_search_itemName_textField ).value; //検索する文字
//-- UI依存ここまで --
KsGMapSearch.itemName.set( searchName ); //アイテム名を検索をセット
KsGMapSearch.search(); //検索処理
}
//□汎用機能 - 検索 - アイテム名 - キーダウン
function KsGMapFunc_search_itemName_keydown( event , form ){
if( event.keyCode == 13 ){ KsGMapFunc.search.itemName.submit( event , form ); }
}
//□汎用機能 - 検索 - アイテム名 - クリア
function KsGMapFunc_search_itemName_clear( event , form ){
document.getElementById( ksgmap_html_search_itemName_textField ).value = ""; //フォームの値を削除
//-- UI依存ここまで --
KsGMapSearch.itemName.clear(); //アイテム名をクリア
KsGMapSearch.search(); //検索処理
}
//□汎用機能 - 検索 - 絞り込み検索 - 条件の変更
function KsGMapFunc_search_narrow_change( event , form ){
var key = form.name; //キー抽出
if( form.type == "checkbox" ){ //チェックボックス
var value = ( form.value.match( /!(\d+)/ ) ? RegExp.$1 : form.value ); //値抽出
var checked = ( form.checked ? 1 : 0 );
if( form.value.match( /!/ ) ){ checked = Math.abs( checked - 1 ); } //!が付いていたら反転
value = ( checked ? value : 0 );
} else { //ラジオボタンとセレクトボックス
var value = form.value;
}
//-- UI依存ここまで --
KsGMapSearch.narrow.change( key , value ); //絞り込み条件の変更
KsGMapSearch.search(); //検索処理
}
//□汎用機能 - ソート - 変更
function KsGMapFunc_sort_change( event , tempValue ){
var sortKey = KsGMapCommon.Variable.convInputValue( tempValue );
KsGMapSort.clear(); //ソートをクリア
if( sortKey || sortKey != "-" ){ KsGMapSort.setSortVar( sortKey ); } //ソートキーをセット(未指定の場合、ソートをしない)
ksgmap_category[ ksgmap_focus_category ].marking(); //マーキングしなおし
return KsGMapCommon.Event.cancel( event ); //イベントをキャンセルしとく
}
//□汎用機能 - ユーザーコントロール - マーカー - 変更
function KsGMapFunc_userControl_marker_changeVisibility( event , form ){ KsGMapMap.userControl.marker.changeVisibility( ( form.checked ? 1 : 0 ) ); }
function KsGMapFunc_userControl_marker_hidden( event , form ){ KsGMapMap.userControl.marker.changeVisibility( 0 ); }
function KsGMapFunc_userControl_marker_visible( event , form ){ KsGMapMap.userControl.marker.changeVisibility( 1 ); }
//□汎用機能 - ユーザーコントロール - センターマーカー - 変更
function KsGMapFunc_userControl_centerMarker_changeVisibility( event , form ){ KsGMapMap.userControl.centerMarker.changeVisibility( ( form.checked ? 1 : 0 ) ); }
function KsGMapFunc_userControl_centerMarker_hidden( event , form ){ KsGMapMap.userControl.centerMarker.changeVisibility( 0 ); }
function KsGMapFunc_userControl_centerMarker_visible( event , form ){ KsGMapMap.userControl.centerMarker.changeVisibility( 1 ); }
//□汎用機能 - ユーザーコントロール - マウスホイール - 状態変更
function KsGMapFunc_userControl_mouseWheel_changeStatus( event , tempValue ){
var value = KsGMapCommon.Variable.convInputValue( tempValue , "isChecked" );
KsGMapMap.userControl.mouseWheel.status = value;
}
//□汎用機能 - ユーザーコントロール - マウスホイール - 方向変更
function KsGMapFunc_userControl_mouseWheel_changeDirection( event , tempValue ){
var value = KsGMapCommon.Variable.convInputValue( tempValue , "isChecked" );
KsGMapMap.userControl.mouseWheel.reverse = tempValue;
}
//--------------------------------------------------------------------------------------------------