function hideModalDialog() {
$("#modalDialog").modal('hide');
}
function showModalDialog(title, message) {
showModalDialog(title, message, null, 1500);
}
function showModalDialog(title, message, func) {
showModalDialog(title, message, func, 1500);
}
function showModalDialog(title, message, func, time) {
$("#modalDialog").find("#modalDialogTitle").text(title);
$("#modalDialog").find("#modalDialogMessage").html(message);
$("#modalDialog").modal('show');
if (func == null)
return;
window.setTimeout(func, time);
}
function prepareWindowLocker() {
if ($("#" + getLockerDefaultName()).length == 0) {
var lockerName = getLockerDefaultName();
$("#divLocker").html("
")
var locker = $("#" + lockerName + "");
locker.attr("style", "display: none; justify-content: center; align-items: center; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 9999; color: white;");
}
}
function getLockerDefaultName() {
return "locker";
}
var windowLockerCanceled = false;
function showWindowLocker() {
showWindowLocker(500);
}
function showWindowLocker(afterTime) {
afterTime = afterTime == null ? 500 : afterTime;
windowLockerCanceled = false;
var lockerName = getLockerDefaultName();
var locker = $("#" + lockerName + "");
window.setTimeout(function () { if (!windowLockerCanceled) locker.css('display', 'flex'); }, afterTime);
}
function hideWindowLocker() {
var lockerName = getLockerDefaultName();
var locker = $("#" + lockerName + "");
locker.css('display', 'none');
windowLockerCanceled = true;
}
function numberWithSeparator(x, separator) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, separator);
}
function loadPolygons(map) {
const infoWindow = new google.maps.InfoWindow(); // Crear un InfoWindow global para reutilizar
$.each($("input[id^='hdn_orderzone_polygon_']"), function (index, element) {
const coordinates = JSON.parse(element.value);
const color = $(element).data("color");
const name = $(element).siblings("strong").text(); // Obtener el nombre de la zona
const value = $(element).closest("tr").find("td:nth-child(3)").text(); // Costo de envío
const polygon = new google.maps.Polygon({
paths: coordinates,
strokeColor: color,
strokeOpacity: 0.7,
fillColor: color,
fillOpacity: 0.3,
strokeWeight: 1,
});
polygon.setMap(map);
// Agregar evento de clic para mostrar el InfoWindow
google.maps.event.addListener(polygon, 'click', function (event) {
const content = `
Zona: ${name}
Costo de envío: ${value}
`;
infoWindow.setContent(content);
infoWindow.setPosition(event.latLng); // Usar la posición del clic
infoWindow.open(map);
});
});
map.addListener("click", () => {
infoWindow.close();
});
}
function loadPolygonsStore(map) {
const infoWindow = new google.maps.InfoWindow(); // Crear un InfoWindow global para reutilizar
$.each($("input[id^='hdn_orderzone_polygon_']"), function (index, element) {
const coordinates = JSON.parse(element.value);
const color = $(element).data("color");
const polygon = new google.maps.Polygon({
paths: coordinates,
strokeColor: color,
strokeOpacity: 0.7,
fillColor: color,
fillOpacity: 0.3,
strokeWeight: 1,
});
polygon.setMap(map);
});
}