",
zIndex: 1
});
}
});
/* 아파트 단지 클릭 시 우측에 해당 단지 정보를 보여 주도록 한다. */
$(".cluster_apt").click(function(){
var apt_id = $(this).data("id");
$(".cluster_apt").removeClass("active");
$(this).addClass("active");
$.ajax({
type : "POST",
url : "/apt/view/"+apt_id,
dataType: 'html',
beforeSend:function(){
$("#apt-area").html("
로딩중...
데이터를 로딩중입니다.
");
$("#apt-area").show();
},
complete:function(){
/**/
},
success: function(data) {
$("#apt-area").html(data);
$("#apt-area").show();
$("#map_list").toggleClass("on");
}
});
});
}
function close_apt(){
$(".cluster_apt").removeClass("active");
$(".cluster_num").removeClass("active");
$("#map_list").removeClass("half");
$("#map_list").removeClass("on");
$("#apt-area").hide();
}
function remove_data(){
for (var i = 0; i < markers.length; i++) {
if(typeof markers[i] !== 'undefined') markers[i].setMap(null);
}
if(markers.length>0) markers = [];
for (var i = 0; i < smarkers.length; i++) {
smarkers[i].setMap(null);
}
if(smarkers.length>0) smarkers = [];
for (var i = 0; i < apts.length; i++) {
if(typeof apts[i] !== 'undefined') apts[i].setMap(null);
}
if(apts.length>0) apts = [];
for (var i = 0; i < sido_markers.length; i++) {
sido_markers[i].setMap(null);
}
if(sido_markers.length>0) sido_markers = [];
for (var i = 0; i < gugun_markers.length; i++) {
gugun_markers[i].setMap(null);
}
if(gugun_markers.length>0) gugun_markers = [];
for (var i = 0; i < dong_markers.length; i++) {
dong_markers[i].setMap(null);
}
}
function over_cluster(id){
$('#round'+id).parent().css('z-index',99);
setTimeout(function(){
$('#round'+id).parent().css('z-index',100);
},150);
}
function move_map(lat,lng, pzoom){
map.setCenter(new daum.maps.LatLng(lat, lng));
map.setLevel(pzoom);
}
function level_up(lat,lng){
move_map(lat,lng,level-1);
mapdraw();
}
function init_filter(){
$("#form").find("input:checkbox").each(function(){
$(this).prop("checked", false);
});
$("#form").find("select").each(function(){
$(this).val("");
});
sell_price_range.reset();
deposit_price_range.reset();
rent_price_range.reset();
if($("#area").length>0) area_range.reset();
if($("#area_total").length>0) area_total_range.reset();
if($("#area_land").length>0) area_land_range.reset();
mapdraw_event();
}
function filter_title(){
$("#selltype_label").html("거래 방식");
$("#cate_label").html("매물 종류");
$("#bedcnt_label").html("방 수");
$("#theme_label").html("테마");
$("#price_label").html("가격 대");
$("#area_label").html("면적");
$("#option_label").html(" 상세 검색");
var title = "";
var btn = ['selltype','cate','bedcnt','theme'];
$.each(btn,function(index,item){
title = "";
$("#"+item+"_group input").each(function(){
if($(this).is(":checked")){
if(title=="") title = title + $(this).data("title");
else if(title!="") title = title + "," + $(this).data("title");
}
});
if(title!="") {
$("#"+item+"_label").removeClass("btn-outline-secondary");
$("#"+item+"_label").addClass("btn-secondary");
$("#"+item+"_label").html(title);
} else {
$("#"+item+"_label").removeClass("btn-secondary");
$("#"+item+"_label").addClass("btn-outline-secondary");
}
});
/*
가격대
- 앞 숫자, 뒷 숫자 모두 보여준다.
- labeling_sell_price
- labeling_deposit_price
- labeling_rent_price
*/
title = "";
var sell_price = $("#sell_price").val();
var deposit_price = $("#deposit_price").val();
var rent_price = $("#rent_price").val();
if(sell_price!=";" && sell_price!="null;null" && sell_price!="0;"+sell_price_max) {
title = filter_title_price($("#sell_price").val(),"sell");
}
if(deposit_price!=";" && deposit_price!="null;null" && deposit_price!="0;"+deposit_price_max) {
title = filter_title_price($("#deposit_price").val(),"deposit");
}
if(rent_price!=";" && rent_price!="null;null" && rent_price!="0;"+rent_price_max) {
title = title + filter_title_price($("#rent_price").val(),"rent");
}
if(title.trim()!="") {
$("#price_label").removeClass("btn-outline-secondary");
$("#price_label").addClass("btn-secondary");
$("#price_label").html(title);
} else {
$("#price_label").removeClass("btn-secondary");
$("#price_label").addClass("btn-outline-secondary");
}
/**
* 면적
*/
title = "";
if($("#area").length>0){
var area = $("#area").val();
if(area!="null;null" && area!="0;"+area_max) {
title = filter_title_area($("#area").val());
}
}
if(title.trim()!="") {
$("#area_label").removeClass("btn-outline-secondary");
$("#area_label").addClass("btn-secondary");
$("#area_label").html(title);
} else {
$("#area_label").removeClass("btn-secondary");
$("#area_label").addClass("btn-outline-secondary");
}
/* 옵션 */
//floor, build_date
title="";
if($("#form select[name='floor'] option:selected").val()!="") {
title = $("#form select[name='floor'] option:selected").text()+" ";
}
if($("#form select[name='build_date'] option:selected").val()!=""){
title = title + $("#form select[name='build_date'] option:selected").text();
}
if(title.trim()!="") {
$("#option_label").removeClass("btn-outline-secondary");
$("#option_label").addClass("btn-secondary");
$("#option_label").html(title);
} else {
$("#option_label").removeClass("btn-secondary");
$("#option_label").addClass("btn-outline-secondary");
}
}
function filter_title_price(ts,gubun){
var r = "";
var t = ts.split(';');
if(gubun=="sell"){
/* 주가격 */
if(t[0]!="null" && t[0]!="0") r = r+labeling_sell_price(t[0]);
if(t[1]!="null") r = r+"~"+labeling_sell_price(t[1]);
return r;
} else if(gubun=="deposit"){
/* 주가격 */
if(t[0]!="null" && t[0]!="0") r = r+labeling_deposit_price(t[0]);
if(t[1]!="null") r = r+"~"+labeling_deposit_price(t[1]);
return r;
} else {
/* 보조 가격 */
if(t[0]!="null" && t[0]!="0") r = r+labeling_rent_price(t[0]);
if(t[1]!="null") r = r+"~"+labeling_rent_price(t[1]);
if(r!="") return ",월"+r;
}
}
function filter_title_area(ts){
var r = "";
var t = ts.split(';');
/* 주가격 */
if(t[0]!="null" && t[0]!="0") r = r+t[0]+"평";
if(t[1]!="null" && t[1]!=area_max) r = r+"~"+t[1]+"평";
return r;
}
function filter_title_area_total(ts){
var r = "";
var t = ts.split(';');
/* 주가격 */
if(t[0]!="null" && t[0]!="0") r = r+t[0]+"평";
if(t[1]!="null" && t[1]!=area_total_max) r = r+"~"+t[1]+"평";
return r;
}
function filter_title_area_land(ts){
var r = "";
var t = ts.split(';');
/* 주가격 */
if(t[0]!="null" && t[0]!="0") r = r+t[0]+"평";
if(t[1]!="null" && t[1]!=area_land_max) r = r+"~"+t[1]+"평";
return r;
}
function init_rangeslider(){
$("#sell_price").ionRangeSlider({
type: 'double',
min: 0,
max: sell_price_max,
from: 0,
to: sell_price_max,
values: sell_price,
grid: false,
grid_num:1000,
grid_snap: true,
skin: 'round',
prettify: labeling_sell_price,
});
sell_price_range = $("#sell_price").data("ionRangeSlider");
if($("#form input[name='sell_from']").val()!="" || $("#form input[name='sell_to']").val()!=""){
sell_price_range.update({
from: sell_price.indexOf(Number($("#form input[name='sell_from']").val())),
to: sell_price.indexOf(Number($("#form input[name='sell_to']").val()))
});
}
$("#deposit_price").ionRangeSlider({
type: 'double',
min: 0,
max: deposit_price_max,
from: 0,
to: deposit_price_max,
values: deposit_price,
grid: false,
grid_num:1000,
grid_snap: true,
skin: 'round',
prettify: labeling_deposit_price,
});
deposit_price_range = $("#deposit_price").data("ionRangeSlider");
if($("#form input[name='deposit_from']").val()!="" || $("#form input[name='deposit_to']").val()!=""){
deposit_price_range.update({
from: deposit_price.indexOf(Number($("#form input[name='deposit_from']").val())),
to: deposit_price.indexOf(Number($("#form input[name='deposit_to']").val()))
});
}
$("#rent_price").ionRangeSlider({
type: 'double',
min: 0,
max: rent_price_max,
from: 0,
to: rent_price_max,
values: rent_price,
grid: false,
grid_snap: true,
skin: 'round',
prettify: labeling_rent_price
});
rent_price_range = $("#rent_price").data("ionRangeSlider");
if($("#form input[name='rent_from']").val()!="" || $("#form input[name='rent_to']").val()!=""){
rent_price_range.update({
from: rent_price.indexOf(Number($("#form input[name='rent_from']").val())),
to: rent_price.indexOf(Number($("#form input[name='rent_to']").val()))
});
}
if($("#area").length>0){
$("#area").ionRangeSlider({
type: 'double',
min: 0,
max: area_max,
from: 0,
to: area_max,
values: area,
grid: false,
grid_snap: true,
skin: 'round',
prettify: labeling_area
});
area_range = $("#area").data("ionRangeSlider");
}
if($("#area_total").length>0){
$("#area_total").ionRangeSlider({
type: 'double',
min: 0,
max: area_total_max,
from: 0,
to: area_total_max,
values: area_total,
grid: false,
grid_snap: true,
skin: 'round',
prettify: labeling_area_total
});
area_total_range = $("#area_total").data("ionRangeSlider");
}
if($("#area_land").length>0){
$("#area_land").ionRangeSlider({
type: 'double',
min: 0,
max: area_land_max,
from: 0,
to: area_land_max,
values: area_land,
grid: false,
grid_snap: true,
skin: 'round',
prettify: labeling_area_land
});
area_land_range = $("#area_land").data("ionRangeSlider");
}
filter_title();
}
function labeling_sell_price(ts) {
if(ts == 0) {
return "0원"
} else if(ts >= sell_price_max) return "제한없음";
else return numberToKorean(ts) + "원";
}
function labeling_deposit_price(ts) {
if(ts == 0) {
return "0원"
} else if(ts >= deposit_price_max) return "제한없음";
else return numberToKorean(ts) + "원";
}
/**
* 월세 가격 검색 보여주기
*/
function labeling_rent_price(ts) {
if(ts == 0) {
return "0원"
} else if(ts >= rent_price_max) return "제한없음";
else return numberToKorean(ts) + "원";
}
/**
* 면적 검색 보여주기
*/
function labeling_area(ts) {
if(ts >= area_max) return "제한없음";
else return ts + "평";
}
function labeling_area_total(ts) {
if(ts >= area_total_max) return "제한없음";
else return ts + "평";
}
function labeling_area_land(ts) {
if(ts >= area_land_max) return "제한없음";
else return ts + "평";
}
function numberToKorean(number){
number = number *10000; /* 사이트에서 기본으로 1만원 기준으로 하니까 */
var inputNumber = number < 0 ? false : number; /* 금액이 0보다 작은 것은 성립하지 않는다 */
var unitWords = ['', '만', '억', '조', '경'];
var splitUnit = 10000;
var splitCount = unitWords.length;
var resultArray = [];
var resultString = '';
for (var i = 0; i < splitCount; i++){
var unitResult = (inputNumber % Math.pow(splitUnit, i + 1)) / Math.pow(splitUnit, i);
unitResult = Math.floor(unitResult);
if(unitResult>=1000){
resultArray[i] = unitResult/1000 + "천";
} else if (unitResult >= 100){
resultArray[i] = unitResult/100 + "백";
} else if (unitResult > 0){
resultArray[i] = unitResult;
}
}
for (var i = 0; i < resultArray.length; i++){
if(!resultArray[i]) continue;
resultString = String(resultArray[i]) + unitWords[i] + resultString;
}
return resultString;
}
function zoomIn() {
level = level -1;
map.setLevel(level);
}
function zoomOut() {
level = level + 1;
map.setLevel(level);
}
/**
* traffic,roadview,terrain,use_district,skyview,roadview
*/
function setMapType(maptype) {
if (maptype == 'ROADMAP') {
map.addOverlayMapTypeId(kakao.maps.MapTypeId.ROADMAP);
$("#map-btn").html("일반");
} else if (maptype == 'USE_DISTRICT') {
map.addOverlayMapTypeId(kakao.maps.MapTypeId.USE_DISTRICT);
$("#map-btn").html("지적");
} else if (maptype == 'SKYVIEW') {
map.addOverlayMapTypeId(kakao.maps.MapTypeId.SKYVIEW);
$("#map-btn").html("위성");
} else if (maptype == 'TRAFFIC') {
map.addOverlayMapTypeId(kakao.maps.MapTypeId.TRAFFIC);
$("#map-btn").html("교통");
} else {
map.addOverlayMapTypeId(kakao.maps.MapTypeId.HYBRID);
}
}
var local_img;
function setLocal(local){
remove_local();
var ps = new kakao.maps.services.Places(map);
local_img = '/assets/img/local/'+local+'.png';
ps.categorySearch(local, placesSearchCB, {useMapBounds:true});
}
function placesSearchCB (data, status, pagination) {
if (status === kakao.maps.services.Status.OK) {
for (var i=0; i' + place.place_name + '');
infowindow.open(map, local[i]);
});
}
function remove_local(){
for (var i = 0; i < local.length; i++) {
local[i].setMap(null);
}
}
/* 지하철 처리 */
function get_subway_map(val){
var subway_id = "";
var subway_x = "";
var subway_y = "";
var where = "";
$.each(val, function(key1, val1) {
if(map.getLevel()<=5){
// 커스텀 오버레이를 생성합니다
var subway_icon = "";
/*
"+val1["name"]+"
*/
smarkers[key1] = new daum.maps.CustomOverlay({
map: map,
position: new daum.maps.LatLng(val1["lat"], val1["lng"]),
content: "
"+subway_icon+val1["name"]+"
",
yAnchor: 1
});
}
});
}
/*****************************************************
* 지도에 지하철 역 클러스터 표시
******************************************************/
function get_subway_cluster_map(val){
var subway_id = "";
var subway_x = "";
var subway_y = "";
var where = "";
$.each(val, function(key, val) {
dong_markers[key] = new daum.maps.CustomOverlay({
map: map,
position: new daum.maps.LatLng(val["lat"], val["lng"]),
content: "