$(document).ready(function() { if (typeof itsmo.baseball.onload === "function") { itsmo.baseball.onload(); } }); if (typeof itsmo == 'undefined') { var itsmo = {}; } if (typeof itsmo.baseball === 'undefined') { itsmo.baseball = {}; } itsmo.baseball.widgets = []; itsmo.baseball.arrayLatLon = []; itsmo.baseball.g_map_obj = []; itsmo.baseball.initMapDetail = function(elmId) { itsmo.baseball.g_map_obj[elmId] = null; itsmo.baseball.arrayLatLon[elmId] = []; itsmo.baseball.widgets[elmId] = []; if (typeof ZDC === 'undefined' || typeof ZDC.Map === 'undefined') { return; } var lvl = 13; var lat = $('input#ground-lat-' + elmId).val(); var lon = $('input#ground-lon-' + elmId).val(); var groundLink = $('input#ground-link-' + elmId).val(); if (typeof lat === 'undefined' || typeof lon === 'undefined') { return; } lat = parseInt(lat, 10) / (60 * 60 * 1000); lon = parseInt(lon, 10) / (60 * 60 * 1000); var latlon = new ZDC.LatLon(lat, lon); var latlons = []; ZDC._TILE_PATHS["4"] = ZDC._TILE_PATHS["24"]; itsmo.baseball.g_map_obj[elmId] = new ZDC.Map( $('#idMap' + elmId).get(0), { mapType: ZDC.MAPTYPE_COLOR, latlon: latlon, zoom: lvl } ); itsmo.baseball.g_map_obj[elmId].dragOn(); itsmo.baseball.g_map_obj[elmId].zoomOn(); // クリック地点を地図の中心点として移動 ZDC.addListener(itsmo.baseball.g_map_obj[elmId], ZDC.MAP_CLICK, function(){ var latlon = itsmo.baseball.g_map_obj[elmId].getClickLatLon(); itsmo.baseball.g_map_obj[elmId].moveLatLon(latlon); }); var e = $('#list_hiden_data' + elmId + ' input:first-child').val(); if (typeof e !== 'undefined') { $('#list_hiden_data' + elmId + ' input').each(function() { var e = $(this); var s = e.val().split(','); var id = s[0]; var name = s[1]; var type = s[2]; var lat = parseInt(s[3], 10) / (60 * 60 * 1000); var lon = parseInt(s[4], 10) / (60 * 60 * 1000); var index = parseInt(s[5],10); if(!isNaN(lat) && !isNaN(lon)) { var latlon = new ZDC.LatLon(lat, lon); var url = window.location.href + id + '/'; var mark = new ZDC.UserWidget(latlon, { size: new ZDC.WH(30, 31), html: '', offset: new ZDC.Pixel(-16, -30) }); itsmo.baseball.g_map_obj[elmId].addWidget(mark); mark.open(); var html = '
\
\ \
  • ' + name + '
\
\
\
'; var sz = itsmo.baseball.getHtmlSize(html, elmId); var widget = new ZDC.UserWidget(latlon, { size: sz, html: html, offset: new ZDC.Pixel(-sz.width/2, -(sz.height/2+ 50)) }); latlons.push(latlon); itsmo.baseball.arrayLatLon[elmId].push(latlon); itsmo.baseball.widgets[elmId].push(widget); } }); } var html = ''; var makerRed = new ZDC.UserWidget(latlon, { size: new ZDC.WH(22, 34), html: html, offset: new ZDC.Pixel(-10, -29) }); latlons.push(latlon); itsmo.baseball.g_map_obj[elmId].addWidget(makerRed); makerRed.open(); var adjustZoom = itsmo.baseball.g_map_obj[elmId].getAdjustZoom(latlons, true); if(adjustZoom){ itsmo.baseball.g_map_obj[elmId].setZoom(adjustZoom.zoom); itsmo.baseball.g_map_obj[elmId].moveLatLon(adjustZoom.latlon); } }; itsmo.baseball.showDetail = function (index, elmId){ itsmo.baseball.closeBalloon(elmId); itsmo.baseball.g_map_obj[elmId].moveLatLon(itsmo.baseball.arrayLatLon[elmId][index]); itsmo.baseball.g_map_obj[elmId].addWidget(itsmo.baseball.widgets[elmId][index]); itsmo.baseball.widgets[elmId][index].open(); }; itsmo.baseball.closeBalloon = function(elmId){ var arrayLength = itsmo.baseball.widgets[elmId].length; for (var i = 0; i < arrayLength; i++){ itsmo.baseball.widgets[elmId][i].close(); } }; itsmo.baseball.zoomInMap = function(elmId){ itsmo.baseball.g_map_obj[elmId].zoomIn(); }; itsmo.baseball.zoomOutMap = function(elmId){ itsmo.baseball.g_map_obj[elmId].zoomOut(); }; itsmo.baseball.getHtmlSize = function(html, elmId) { var sz = $('#idCalcSize' + elmId).html(html); sz = new ZDC.WH(sz.outerWidth({margin: true}), sz.outerHeight({margin: true})); sz.width = sz.width + 10; sz.height = sz.height + 10; return sz; }; itsmo.baseball.gMapObj = {}; itsmo.baseball.createMap = function (lat, lon, mapLink) { if (typeof ZDC === 'undefined' || typeof ZDC.Map === 'undefined') { return; } lat = ZDC.msTodeg(lat); lon = ZDC.msTodeg(lon); var latlon = new ZDC.LatLon(lat, lon); var maptype = ZDC.MAPTYPE_COLOR; var lvl = 13; ZDC._TILE_PATHS["4"] = ZDC._TILE_PATHS["24"]; itsmo.baseball.gMapObj = new ZDC.Map( $('#idMap').get(0), { mapType: maptype, latlon: latlon, zoom: lvl } ); console.log($('#idMap').get(0)); itsmo.baseball.gMapObj.dragOn(); itsmo.baseball.gMapObj.zoomOn(); ZDC.addListener(itsmo.baseball.gMapObj, ZDC.MAP_CLICK, function () { var latlon = itsmo.baseball.gMapObj.getClickLatLon(); itsmo.baseball.gMapObj.moveLatLon(latlon); }); var size = new ZDC.WH(32, 32); var widget = new ZDC.StaticUserWidget({top: 8, left: 8}, { html: '
', size: size }); itsmo.baseball.gMapObj.addWidget(widget); widget.open(); widget = new ZDC.StaticUserWidget({top: 39, left: 8}, { html: '
', size: size }); itsmo.baseball.gMapObj.addWidget(widget); widget.open(); itsmo.baseball.createOsusumeWidget(latlon, mapLink); }; itsmo.baseball.createOsusumeWidget = function (latlon, mapLink) { var html = ''; var maker = new ZDC.UserWidget(latlon, { size: new ZDC.WH(22, 34), html: html, offset: new ZDC.Pixel(-10, -29) }); itsmo.baseball.gMapObj.addWidget(maker); maker.open(); }; itsmo.baseball.showContentLeague = function () { var acdHead = '.acdHead'; var acdBody = '.acdBody'; $(acdHead).addClass('closed'); $(acdHead).append('
'); $(acdBody).css('display','none'); $(acdHead).click(function(){ $icon = $(this).find('.icon'); if($(this).siblings(acdBody).is(':visible')){ $(this).siblings(acdBody).slideUp(100); $(this).removeClass('closed'); $icon.removeClass('fa-minus-square-o'); $icon.addClass('fa-plus-square-o'); $(this).addClass('opened'); } if($(this).siblings(acdBody).is(':hidden')){ $(this).siblings(acdBody).slideDown(100) $(this).removeClass('opened'); $icon.removeClass('fa-plus-square-o'); $icon.addClass('fa-minus-square-o'); $(this).addClass('closed'); } }); $('.block-team-central-league li:first').children(acdHead).trigger('click'); $('.block-team-pacific-league li:first').children(acdHead).trigger('click'); }; itsmo.baseball.showContentTab = function () { var contentTab = $('.contentsWrap.tabContent'); contentTab.not(contentTab.first()).hide(); $('.tabNav').each(function(){ var tabs = $(this).find('a[href^=#]'); var contents; tabs.each(function(){ var selecter = $(this).attr('href'); if (contents) { contents = contents.add(selecter); } else { contents = $(selecter); } $(this).click(function(){ tabs.parent().removeClass('active'); $(this).parent().addClass('active'); contents.hide(); $(selecter).show(); $(window).trigger('resize'); return false; }); }); }); }; itsmo.baseball.selectedContentTab = function () { if (window.location.hash != '') { var tabSelected = $('.tabNav').find('a[href^='+ window.location.hash +']'); if (tabSelected.length != 0) { $('.tabNav').find('a[href^=#]').parent().removeClass('active'); tabSelected.parent().addClass('active'); $('.tab-wrap .tabContent').hide(); $(window.location.hash).show(); return false; } } }; itsmo.baseball.setWidthTabs = function () { var countTab = itsmo.baseball.countTab; $('.tabNav li').css("width", (100/countTab) + '%'); };