diff --git a/tmp_map/base_map.js b/tmp_map/base_map.js index 760911be..6ce82a0a 100644 --- a/tmp_map/base_map.js +++ b/tmp_map/base_map.js @@ -1,3 +1,25 @@ +function convColorValue(color){ + if(color.startsWith('#')){ + color = color.substr(1); + } + color = color.toUpperCase(); + + var colorBase = new Set([ + '000080', '0000FF', '008000', '008080', '00BFFF', '00FF00', '00FFFF', '20B2AA', + '2E8B57', '483D8B', '6495ED', '7B68EE', '7CFC00', '7FFFD4', '800000', '800080', + '808000', '87CEEB', 'A0522D', 'A9A9A9', 'AFEEEE', 'BA55D3', 'E0FFFF', 'F5F5DC', + 'FF0000', 'FF00FF', 'FF6347', 'FFA500', 'FFC0CB', 'FFD700', 'FFDAB9', 'FFFF00', + 'FFFFFF' + ]); + + if(!colorBase.has(color)){ + return '000000'; + } + + return color; + +} + function getCityPosition(){ return { 1: ["업", 345, 130], diff --git a/tmp_map/map.css b/tmp_map/map.css index 8f4963f4..57946321 100644 --- a/tmp_map/map.css +++ b/tmp_map/map.css @@ -103,3 +103,101 @@ border:solid 0.02em red;/* Always 1px :) */ outline:dotted 3px red; } + +.city_base{ + position:absolute; + width:40px; + height:30px; + margin-left:-20px; + margin-top:-10px; +} + +.city_base .city_bg{ + position:absolute; + left:10px; + top:20px; + background-position: center; +} + +.map_detail .city_base.city_level_1 .city_bg{ + /*수*/ + width:48px; + height:45px; + background-size:48px 45px; + margin-top:-24px; + margin-left:-22.5px; +} + +.map_detail .city_base.city_level_2 .city_bg{ + /*진*/ + width:60px; + height:42px; + background-size:60px 42px; + margin-top:-30px; + margin-left:-21px; +} + +.map_detail .city_base.city_level_3 .city_bg{ + /*관*/ + width:42px; + height:42px; + background-size:42px 42px; + margin-top:-21px; + margin-left:-21px; +} + +.map_detail .city_base.city_level_4 .city_bg{ + /*이*/ + width:60px; + height:45px; + background-size:60px 45px; + margin-top:-30px; + margin-left:-22.5px; +} + +.map_detail .city_base.city_level_5 .city_bg{ + /*소*/ + width:72px; + height:48px; + background-size:72px 48px; + margin-top:-36px; + margin-left:-24px; +} + +.map_detail .city_base.city_level_6 .city_bg{ + /*중*/ + width:78px; + height:54px; + background-size:78px 54px; + margin-top:-39px; + margin-left:-27px; +} + +.map_detail .city_base.city_level_7 .city_bg{ + /*대*/ + width:84px; + height:60px; + background-size:84px 60px; + margin-top:-42px; + margin-left:-30px; +} + +.map_detail .city_base.city_level_8 .city_bg{ + /*특*/ + width:96px; + height:72px; + background-size:96px 72px; + margin-top:-48px; + margin-left:-36px; +} + +.city_img{ + display: table-cell; + position:absolute; + /*line-height:30px;*/ + vertical-align: middle; + width:40px; + height:30px; + text-align:center; + align-items: center; +} \ No newline at end of file diff --git a/tmp_map/map.html b/tmp_map/map.html index 9ffcd0d5..a521a94d 100644 --- a/tmp_map/map.html +++ b/tmp_map/map.html @@ -18,7 +18,6 @@
-
diff --git a/tmp_map/map.js b/tmp_map/map.js index a907e9de..7095226a 100644 --- a/tmp_map/map.js +++ b/tmp_map/map.js @@ -129,7 +129,7 @@ function reloadWorldMap(isDetailMap, clickableAll, selectCallback){ case 8: level_str = "특】"; break; } - city.text = region_str + city.name + level_str; + city.text = region_str + level_str + city.name; city.region_str = region_str; city.level_str = level_str; @@ -179,7 +179,7 @@ function reloadWorldMap(isDetailMap, clickableAll, selectCallback){ if(nationId == myNation){ clickable |= 4; } - if(id in shownByGeneralList){ + if(shownByGeneralList.has(id)){ clickable |= 2; } if(clickableAll){ @@ -192,10 +192,10 @@ function reloadWorldMap(isDetailMap, clickableAll, selectCallback){ } cityList = cityList - .map(formatCityInfo) .map(mergePositionInfo) .map(mergeNationInfo) - .map(mergeClickable); + .map(mergeClickable) + .map(formatCityInfo); return { 'cityList' : cityList, @@ -205,31 +205,63 @@ function reloadWorldMap(isDetailMap, clickableAll, selectCallback){ function drawDetailWorldMap(obj){ - var flagTemplate = '
'; - var backgroundTemplate = '
'; + var $map_body = $('.world_map .map_body'); var cityList = obj.cityList; var myCity = obj.myCity; - //TODO: 도시를 그린다......... - // - //도시 선택 크기는 동일하게 가고 도시 이미지는 div로 설정. + cityList.forEach(function(city){ + console.log(city); + var id = city.id; + $('.city_base_{0}'.format(id)).detach(); + var flagTemplate = '
'; + var stateTemplate = '
'; + var backgroundTemplate = '
'; + + + + + //TODO: 도시를 그린다......... + // + //도시 선택 크기는 동일하게 가고 도시 이미지는 div로 설정. + var $cityObj = $('
'.format(id)); + $cityObj.addClass('city_level_{0}'.format(city.level)); + + $cityObj.css({'left':city.x,'top':city.y}); + + var $linkObj = $(''); + var $bgObj = $('
'); + var $imgObj = $('
'.format(city.level)); + $cityObj.data('obj', city); + //$cityObj.append($bgObj); + //$cityObj.append($linkObj); + + if('color' in city && city.color !== null){ + $cityObj.append($bgObj); + $bgObj.css({'background-image':"url('/images/b{0}.png')".format(convColorValue(city.color))}); + } + + $cityObj.append($linkObj); + + $linkObj.append($imgObj); + $map_body.append($cityObj); + + if(selectCallback){ + $linkObj.click(function(){ + selectCallback($cityObj); + return false; + }); + } + + + }); return obj; } function drawBasicWorldMap(obj){ - var flagTemplate = '
'; - var backgroundTemplate = '
'; - - var cityList = obj.cityList; - var myCity = obj.myCity; - - //TODO: 도시를 그린다......... - // - //도시 선택 크기는 동일하게 가고 도시 이미지는 div로 설정. return obj; diff --git a/tmp_map/result.json b/tmp_map/result.json index f305e298..31946aad 100644 --- a/tmp_map/result.json +++ b/tmp_map/result.json @@ -4,7 +4,7 @@ "year":217, "month":10, "cityList":[ - [1, 8, 0, 0, 1, 1], + [1, 8, 0, 1, 1, 1], [2, 8, 0, 0, 2, 1], [3, 8, 0, 0, 2, 1], [4, 8, 0, 0, 3, 1],