/* * guimap.pr.js * Product module */ /* jslint */ /* global $, guimap */ guimap.pr = (function () { // ---------- MODULE SCOPE VARIABLES ---------- var configMap = { settable_map: { center_lat: true, center_lng: true, zoom: true, prty: true, maker: true, scale: true, snap_to_border: true }, initialized: false, center_lat: 37.566535, center_lng: 126.977969, zoom: 3, prty: '11', maker: '11', scale: '1', snap_to_border: false, prmapcolors: {'11': '#4169e1', '12': '#ff0000', '13': '#800080', '14': '#9400d3', '15': '#b8860b'}, prmapoptions: { strokeColor: '#b8860b',//'#1e90ff','#ff1e90','#ff901e','#008000','#663399','#800080', strokeOpacity: 1.0, strokeWeight: 1, fillColor: '#dc143c', fillOpacity: 0.003 }, prmapoptions_focused: { strokeColor: '#000000', strokeOpacity: 1.0, strokeWeight: 1, fillColor: '#000000', fillOpacity: 0.2 }, prmapoptions_selected: { strokeColor: '#000000', strokeOpacity: 1.0, strokeWeight: 1, fillColor: '#000000', fillOpacity: 0.2 }, prmapoptions_cart: { strokeColor: '#cd5c5c', strokeOpacity: 1.0, strokeWeight: 1, fillColor: '#cd5c5c', fillOpacity: 0.2 }, route: null, q: null }, stateMap = { map: null, focused: null, selected: null, label: null, cartcallback: null }, jqueryMap = {}, setJqueryMap, drawPrMap, loadPrData, reloadPrData, loadCart, focusPrMap, blurPrMap, addToCart, addToCartRouteMap, isPrContainsRoute, showPrLabel, hidePrLabel, updatePrLabel, onPrMouseOver, onPrMouseOut, initModule, loadCategory, getStatus, searchPrByCode, viewPr, loadRoute, removeFromCart, emptyCart; var kapp, vapp, timer, curpos, infowindow; // ---------- UTILITY METHODS ---------- addToCart = function () { var prid = $('#form-ord [name="prid"]').val(); /* 20200714 추가 jhcho */ var caid = $('#form-ord [name="caid"]').val(); $.getJSON('/include/lib.php?act=ord_addtocart_guimap&restype=json&caid='+caid+'&prid='+prid+'&qty=1', function(response){ if (response.status=='1') { stateMap.selected.cart = true; infowindow.close(); deselectPrMap(stateMap.selected); if (stateMap.hasOwnProperty('cartcallback')) { stateMap['cartcallback'](); } //alert(response.msg); } else { if (response.msg=='') alert('처리중 오류가 발생하였습니다'); else alert(response.msg); } }); }; addToCartRouteMap = function () { var prcd = []; var qty = []; for (var i=0;i=10 ||*/ kapp[i].sizemn/boundsmn*800>10 && (/*zoom<=2 ||*/ kapp[i].sizemn/boundsmn*800<600)) && (true || zoom >= kapp[i].mn && zoom <= kapp[i].mn+3) && //if ( (bounds.contains(kapp[i].pts[0]) || bounds.contains(kapp[i].pts[1]) || bounds.contains(kapp[i].pts[2]) || bounds.contains(kapp[i].pts[3]))) { if (kapp[i].poly===null) { var poly = new google.maps.Polygon({ paths: kapp[i].pts, zIndex: kapp[i].zIndex }); configMap.prmapoptions.strokeColor = configMap.prmapcolors[kapp[i].maker]; poly.setOptions(configMap.prmapoptions); poly.setMap(stateMap.map); kapp[i].poly = poly; addPrMapListeners(poly, kapp[i]); } else { kapp[i].poly.setMap(stateMap.map); if (kapp[i].selected) { kapp[i].poly.setOptions(configMap.prmapoptions_selected); } } } else { if (kapp[i].poly !== null) { kapp[i].poly.setMap(null); //kapp[i].poly = null; } } } //google.maps.event.addListener(stateMap.map, 'mousemove', function(event) {console.log('mousemove');}); }; loadPrData = function (candraw) { guimap.shell.showProgress(100); if (infowindow) { infowindow.setMap(null); infowindow = null; } if (kapp) { for (var i=0;i'+searchlist[i].name+''); } jqueryMap.$searchResult.show(); } }); */ } focusPrMap = function (akapp) { if (stateMap.focused && stateMap.focused.poly && stateMap.focused.pmcode==akapp.pmcode) { return false; } if (stateMap.selected && stateMap.selected.poly && stateMap.selected.pmcode==akapp.pmcode) { //console.log('give focus to selected ' + stateMap.selected.pmcode); stateMap.focused = akapp; return false; } if (!stateMap.selected && stateMap.focused && stateMap.focused.poly) { //console.log('remove focus from ' + stateMap.focused.pmcode); configMap.prmapoptions.strokeColor = configMap.prmapcolors[stateMap.focused.maker]; stateMap.focused.poly.setOptions(configMap.prmapoptions); } stateMap.focused = akapp; //if (!stateMap.focused || stateMap.focused.pmcode!=akapp.pmcode) { // stateMap.focused = akapp; akapp.poly.setOptions(configMap.prmapoptions_focused); //} }; blurPrMap =function (akapp) { //console.log('blur_pm'); //if (stateMap.selected && stateMap.selected.pmcode==akapp.pmcode) return false; //if (stateMap.focused && stateMap.focused.poly) { //stateMap.focused.poly.setOptions(configMap.prmapoptions); //console.log('blur from ' + akapp.pmcode + ' focused is ' + stateMap.focused.pmcode); if (!akapp.selected && akapp.poly) { if (akapp.cart) akapp.poly.setOptions(configMap.prmapoptions_cart); else { configMap.prmapoptions.strokeColor = configMap.prmapcolors[akapp.maker]; akapp.poly.setOptions(configMap.prmapoptions); } } //} stateMap.focused = null; /*akapp.poly.setOptions({ strokeColor: '#FF0000', strokeOpacity: 0.3, fillColor: '#FF0000', fillOpacity: 0.05 });*/ }; deselectPrMap = function () { var akapp = stateMap.selected; if (akapp===null) return false; akapp.selected = false; stateMap.selected = null; blurPrMap(akapp); } function showinfowindow(akapp) { if (infowindow) { infowindow.setMap(null); infowindow.close(); infowindow = null; } //info.push('선택위도: '+Geo.toLat(event.latLng.lat())); //info.push('선택경도: '+Geo.toLon(event.latLng.lng())); //info.push('선택품목: '+akapp.pmcode); $.getJSON('data.php?act=prinfo&q='+akapp.pmcode, function(response){ var row = response; var prinfo = ''; //info.push('판매코드: '+row.prcd); //info.push('분류: '+row.cacd); var info = []; info.push('축척: '+guimap.util.number_format(row.scale)); prinfo += '

'+info.join(' | ')+'

'; var info = []; info.push('발행처: '+row.maker); info.push('판차: '+row.edition); prinfo += '

'+info.join(' | ')+'

'; var info = []; info.push('가격: '+row.price); /* 20200714 추가 jhcho */ info.push('재고: '+((row.caid == '35' || row.jaego-row.quotsu>1) ? '재고있음' : '재고문의')); prinfo += '

'+info.join(' | ')+'

'; var contentString = '
'+ '
'+ /* 20200714 추가 jhcho */ ''+ ''+ '
'+ '
'+ '

'+akapp.pmcode+'

'+ '

'+row.prname+'

'+ '
'+ prinfo + '
'+ '
'+ '
'+ '' + '
'+ '
'+ '
'; infowindow = new google.maps.InfoWindow({ content: contentString }); google.maps.event.addListener(infowindow, 'closeclick', function(){ deselectPrMap(stateMap.selected); }); var latlngbounds = new google.maps.LatLngBounds(); var paths = akapp.poly.getPaths(); var path; for (var i=0; i'+info.join('

')+'

'); }); //info.push('관련품목: '+'
  • '+pm.join('
  • '))+'
'; } showPrLabel = function (event, akapp) { stateMap.label.setContent('' + akapp.pmcode + ' 축척 ' + guimap.util.number_format(akapp.scale)); stateMap.label.setPosition(event.latLng); stateMap.label.show(); }; hidePrLabel = function (event, akapp) { stateMap.label.hide(); }; updatePrLabel = function (event, akapp) { stateMap.label.setPosition(event.latLng); }; addPrMapListeners = function (poly, akapp) { google.maps.event.addListener(poly, 'mouseover', function(event) {onPrMouseOver(event, poly, akapp);}); google.maps.event.addListener(poly, 'mouseout', function(event) {onPrMouseOut(event, poly, akapp);}); //google.maps.event.addListener(poly, 'click', function(event) {chartmap_chart_jump(event, poly, kapp);}); //if (configMap.snap_to_border) google.maps.event.addListener(poly, 'mousemove', function(event) {onMouseMove(event, poly, akapp);}); google.maps.event.addListener(poly, 'mousemove', function(event) {onMouseMove(event, poly, akapp);}); google.maps.event.addListener(poly, 'click', function(event) {showPrInfo(akapp, false);}); }; // ---------- EVENT HANDLERS ---------- onPrMouseOver = function (event, poly, akapp) { focusPrMap(akapp); showPrLabel(event, akapp); }; onPrMouseOut = function (event, poly, akapp) { blurPrMap(akapp); hidePrLabel(event, akapp); }; function onMouseMove(event, poly, akapp) { updatePrLabel(event, akapp); if (configMap.snap_to_border) { focusPrMap(akapp); clearTimeout(timer); timer = setTimeout(onMouseStop, 300); curpos = event.latLng; } } function checkMouseStop(event) { clearTimeout(timer); timer = setTimeout(onMouseStop, 300); curpos = event.latLng; } function onMouseStop() { //console.log('onmousestop'); var bounds = stateMap.map.getBounds(); var boundsmn = bounds.getNorthEast().lat() - bounds.getSouthWest().lat(); var tolerance = boundsmn/200; //var tolerance = Math.pow(stateMap.map.getZoom(), -(stateMap.map.getZoom()/5)); var snap = []; for (var i=0;i0) focused = snap[0]; if (focused && (stateMap.focused==null || focused.pmcode!=stateMap.focused.pmcode)) { focusPrMap(focused); } clearTimeout(timer); } // ---------- PUBLIC METHODS ---------- initModule = function( option ) { setJqueryMap(); configMap.prty = option.prty; configMap.maker = option.maker; configMap.scale = option.scale; stateMap.cartcallback = option.cartcallback; //loadPrData(); //loadCart(); $(document).on('click', '.btnaddtocart', function(e){ e.preventDefault(); addToCart(); }); configMap.initialized = true; return true; }; loadCategory = function ( option ) { configMap.prty = option.prty; configMap.maker = option.maker; configMap.scale = option.scale; configMap.route = null; configMap.q = null; reloadPrData(); return true; }; getStatus = function () { return configMap.initialized; } getFocused = function () { return stateMap.focused; } getSelected = function () { return stateMap.selected; } searchPrByCode = function (option) { //if (!kapp || (configMap.prty!=option.prty || configMap.maker!=option.maker || configMap.scale!=option.scale || configMap.route!==null)) { configMap.prty = option.prty; configMap.maker = option.maker; configMap.scale = option.scale; configMap.route = null; configMap.q = option.q; reloadPrData(); //} var q = option.q; var result = []; for (var i=0;i