From cbaf976ba311f621a5976a8f9820090eba2adff7 Mon Sep 17 00:00:00 2001 From: "Jaeeun.Cho" Date: Fri, 7 Nov 2025 14:51:39 -0500 Subject: [PATCH] Map: add nearby function on Current button --- public_html/doc/map.php | 134 +++++++++++++++++++++++++++------------- 1 file changed, 92 insertions(+), 42 deletions(-) diff --git a/public_html/doc/map.php b/public_html/doc/map.php index bc07870..8ac5967 100644 --- a/public_html/doc/map.php +++ b/public_html/doc/map.php @@ -936,45 +936,9 @@ function popup(){ jQuery(".btn-current").click(function(e){ - onLoading(); - if (currentMarker) { - currentMarker.setMap(null); // Remove existing marker - currentMarker = null; - offLoading(); - }else{ - if (navigator.geolocation) { - navigator.geolocation.getCurrentPosition(function(position) { - const currentPosition = { - lat: position.coords.latitude, - lng: position.coords.longitude - }; - - if (currentMarker) { - currentMarker.setMap(null); // Remove existing marker - } - - currentMarker = new google.maps.Marker({ - position: currentPosition, - map: map, - icon: getCurrentIcon('#dc3545'), - title: "Current Location" - }); - - map.setCenter(currentPosition); - smoothZoom(map, 14, map.getZoom()); - offLoading(); - }, function() { - offLoading(); - alert("Unable to retrieve your location."); - }); - } else { - offLoading(); - alert("Geolocation is not supported by this browser."); - } - } + inqCurrent(); }); - - + jQuery(".btn-routeplanner").click(function(e){ jQuery("#routePlannerModal #addressList").html('

Loading...

'); @@ -1559,7 +1523,7 @@ function popup(){ // Nearby 반경 원 생성 및 추가 함수 var circle; - function addCircle() { + function addCircle(center) { circle = new google.maps.Circle({ strokeColor: '#FF0000', // 원의 선 색상 strokeOpacity: 0.8, // 원의 선 불투명도 @@ -1713,9 +1677,12 @@ function popup(){ marker[i] = new google.maps.Marker({ position: location, map: map, - icon: icon + icon: icon, + animation: (property.rnote && /\S/.test(property.rnote))? google.maps.Animation.BOUNCE : null // google.maps.Animation.DROP }); + marker[i].customType = property.type; //'flag' 또는 'map-marker' + // Add an info window with company information markerwindow[i] = new google.maps.InfoWindow({ content: ``+json.result[i]['name']+`
Est. Quantity : `+json.result[i]['estqty'] @@ -1821,8 +1788,8 @@ function popup(){ document.addEventListener('mouseup', endDrag); document.addEventListener('touchend', endDrag, { passive: false }); } + - // 깃발 모양 마커 아이콘 생성 함수에 16진수 색상 코드 사용 function getFlagIcon(color) { return { @@ -2054,6 +2021,85 @@ function popup(){ var rstInqShortNotice = function(json) { jQuery("#map-modal-note #r_note").val(json.result['rnote']).attr("disabled",false); } + + function inqCurrent() { + onLoading(); + removeCircle(); + + //set to init + jQuery(".chk-ordered").prop("checked",true); + jQuery(".chk-scheduled").prop("checked",false); + jQuery(".chk-requested").prop("checked",false); + jQuery("#search-keyword").val(""); + jQuery(".qty").prop("checked", true); + + if (currentMarker) { + currentMarker.setMap(null); // Remove existing marker + currentMarker = null; + + // map-marker만 제거 + marker.forEach(marker => { + if (marker.customType === 'map-marker') { + marker.setMap(null); + } + }); + + offLoading(); + }else{ + if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(function(position) { + const currentPosition = { + lat: position.coords.latitude, + lng: position.coords.longitude + }; + + if (currentMarker) { + currentMarker.setMap(null); // Remove existing marker + } + + currentMarker = new google.maps.Marker({ + position: currentPosition, + map: map, + icon: getCurrentIcon('#dc3545'), + title: "Current Location" + }); + + map.setCenter(currentPosition); + addCircle(currentPosition); + + let quantity_array = []; + for(let i=0; i < jQuery(".qty").length; i++) { + quantity_array.push( + { + "checked" : jQuery(".qty:eq("+i+")").is(":checked"), + "min" : jQuery(".qty-min:eq("+i+")").val(), + "max" : jQuery(".qty-max:eq("+i+")").val() + } + ); + } + + let data = { + "center_lat" : currentPosition.lat, + "center_lon" : currentPosition.lng, + "search_date" : jQuery("#orderdate").val(), + "driver" : jQuery("#driver").val(), + "quantity" : quantity_array + } + + api('inqNearby', data, rstInqPoint); + + smoothZoom(map, 14, map.getZoom()); + offLoading(); + }, function() { + offLoading(); + alert("Unable to retrieve your location."); + }); + } else { + offLoading(); + alert("Geolocation is not supported by this browser."); + } + } + } function inqNearby(coord){ removeCircle(); @@ -2067,11 +2113,15 @@ function popup(){ jQuery(".qty").prop("checked",true); + if (currentMarker) { + currentMarker.setMap(null); // Remove existing marker + } + let coordArr = coord.split(":"); center = { lat: parseFloat(coordArr[0]), lng: parseFloat(coordArr[1]) }; map.setCenter(center); - addCircle(); + addCircle(center); let quantity_array = []; for(let i=0; i < jQuery(".qty").length; i++) {