Map: add nearby function on Current button
This commit is contained in:
parent
4595acdf92
commit
cbaf976ba3
|
|
@ -936,45 +936,9 @@ function popup(){
|
||||||
|
|
||||||
|
|
||||||
jQuery(".btn-current").click(function(e){
|
jQuery(".btn-current").click(function(e){
|
||||||
onLoading();
|
inqCurrent();
|
||||||
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.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
jQuery(".btn-routeplanner").click(function(e){
|
jQuery(".btn-routeplanner").click(function(e){
|
||||||
jQuery("#routePlannerModal #addressList").html('<p class="text-center">Loading...</p>');
|
jQuery("#routePlannerModal #addressList").html('<p class="text-center">Loading...</p>');
|
||||||
|
|
||||||
|
|
@ -1559,7 +1523,7 @@ function popup(){
|
||||||
|
|
||||||
// Nearby 반경 원 생성 및 추가 함수
|
// Nearby 반경 원 생성 및 추가 함수
|
||||||
var circle;
|
var circle;
|
||||||
function addCircle() {
|
function addCircle(center) {
|
||||||
circle = new google.maps.Circle({
|
circle = new google.maps.Circle({
|
||||||
strokeColor: '#FF0000', // 원의 선 색상
|
strokeColor: '#FF0000', // 원의 선 색상
|
||||||
strokeOpacity: 0.8, // 원의 선 불투명도
|
strokeOpacity: 0.8, // 원의 선 불투명도
|
||||||
|
|
@ -1713,9 +1677,12 @@ function popup(){
|
||||||
marker[i] = new google.maps.Marker({
|
marker[i] = new google.maps.Marker({
|
||||||
position: location,
|
position: location,
|
||||||
map: map,
|
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
|
// Add an info window with company information
|
||||||
markerwindow[i] = new google.maps.InfoWindow({
|
markerwindow[i] = new google.maps.InfoWindow({
|
||||||
content: `<strong>`+json.result[i]['name']+`</strong><br>Est. Quantity : `+json.result[i]['estqty']
|
content: `<strong>`+json.result[i]['name']+`</strong><br>Est. Quantity : `+json.result[i]['estqty']
|
||||||
|
|
@ -1821,8 +1788,8 @@ function popup(){
|
||||||
document.addEventListener('mouseup', endDrag);
|
document.addEventListener('mouseup', endDrag);
|
||||||
document.addEventListener('touchend', endDrag, { passive: false });
|
document.addEventListener('touchend', endDrag, { passive: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 깃발 모양 마커 아이콘 생성 함수에 16진수 색상 코드 사용
|
// 깃발 모양 마커 아이콘 생성 함수에 16진수 색상 코드 사용
|
||||||
function getFlagIcon(color) {
|
function getFlagIcon(color) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -2054,6 +2021,85 @@ function popup(){
|
||||||
var rstInqShortNotice = function(json) {
|
var rstInqShortNotice = function(json) {
|
||||||
jQuery("#map-modal-note #r_note").val(json.result['rnote']).attr("disabled",false);
|
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){
|
function inqNearby(coord){
|
||||||
removeCircle();
|
removeCircle();
|
||||||
|
|
@ -2067,11 +2113,15 @@ function popup(){
|
||||||
|
|
||||||
jQuery(".qty").prop("checked",true);
|
jQuery(".qty").prop("checked",true);
|
||||||
|
|
||||||
|
if (currentMarker) {
|
||||||
|
currentMarker.setMap(null); // Remove existing marker
|
||||||
|
}
|
||||||
|
|
||||||
let coordArr = coord.split(":");
|
let coordArr = coord.split(":");
|
||||||
center = { lat: parseFloat(coordArr[0]), lng: parseFloat(coordArr[1]) };
|
center = { lat: parseFloat(coordArr[0]), lng: parseFloat(coordArr[1]) };
|
||||||
map.setCenter(center);
|
map.setCenter(center);
|
||||||
|
|
||||||
addCircle();
|
addCircle(center);
|
||||||
|
|
||||||
let quantity_array = [];
|
let quantity_array = [];
|
||||||
for(let i=0; i < jQuery(".qty").length; i++) {
|
for(let i=0; i < jQuery(".qty").length; i++) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue