|
|
@ -1,6 +1,8 @@
|
|
|
|
let markersData = [];
|
|
|
|
let markersData = [];
|
|
|
|
let regions = [];
|
|
|
|
let regions = [];
|
|
|
|
let points = [];
|
|
|
|
let points = [];
|
|
|
|
|
|
|
|
var regionPointsWidget;
|
|
|
|
|
|
|
|
var selectedPointsWidget;
|
|
|
|
const markerUrl = './img/map-marker.png';
|
|
|
|
const markerUrl = './img/map-marker.png';
|
|
|
|
|
|
|
|
|
|
|
|
// Инициализация данных, подготовка массивов для загрузки в контролы
|
|
|
|
// Инициализация данных, подготовка массивов для загрузки в контролы
|
|
|
@ -37,7 +39,8 @@ function loadPoints(region) {
|
|
|
|
var lon = parseFloat(loc[1].trim())
|
|
|
|
var lon = parseFloat(loc[1].trim())
|
|
|
|
points.push({
|
|
|
|
points.push({
|
|
|
|
id: p_idx,
|
|
|
|
id: p_idx,
|
|
|
|
text: point.name + ' (' + point.description + ')',
|
|
|
|
text: point.name,
|
|
|
|
|
|
|
|
description: point.description,
|
|
|
|
location: [lat, lon],
|
|
|
|
location: [lat, lon],
|
|
|
|
tooltip: {
|
|
|
|
tooltip: {
|
|
|
|
text: point.description,
|
|
|
|
text: point.description,
|
|
|
@ -65,8 +68,13 @@ function initMap() {
|
|
|
|
|
|
|
|
|
|
|
|
// Пересоздание списка точек указанного региона, для выбора мест к посещению
|
|
|
|
// Пересоздание списка точек указанного региона, для выбора мест к посещению
|
|
|
|
function rebuildRegionPointsList(region) {
|
|
|
|
function rebuildRegionPointsList(region) {
|
|
|
|
loadPoints(region);
|
|
|
|
if (regionPointsWidget) {
|
|
|
|
const listWidget = $('#regionPointsList').dxList({
|
|
|
|
regionPointsWidget.dispose();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectedPointsWidget) {
|
|
|
|
|
|
|
|
selectedPointsWidget.dispose();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
regionPointsWidget = $('#regionPointsList').dxList({
|
|
|
|
dataSource: new DevExpress.data.DataSource({
|
|
|
|
dataSource: new DevExpress.data.DataSource({
|
|
|
|
store: new DevExpress.data.ArrayStore({
|
|
|
|
store: new DevExpress.data.ArrayStore({
|
|
|
|
key: 'id',
|
|
|
|
key: 'id',
|
|
|
@ -74,12 +82,19 @@ function rebuildRegionPointsList(region) {
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
height: 400,
|
|
|
|
height: 400,
|
|
|
|
|
|
|
|
showScrollbar: 'always',
|
|
|
|
showSelectionControls: true,
|
|
|
|
showSelectionControls: true,
|
|
|
|
selectionMode: 'all',
|
|
|
|
selectionMode: 'all',
|
|
|
|
selectByClick: false,
|
|
|
|
selectByClick: false,
|
|
|
|
onSelectionChanged() {
|
|
|
|
onSelectionChanged() {
|
|
|
|
rebuildSelectedPointsList(listWidget.option('selectedItemKeys'));
|
|
|
|
rebuildSelectedPointsList(regionPointsWidget.option('selectedItemKeys'));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
itemTemplate(data) {
|
|
|
|
|
|
|
|
const result = $('<div>').addClass('region-point');
|
|
|
|
|
|
|
|
$('<h3>').text(data.text).appendTo(result);
|
|
|
|
|
|
|
|
$('<i>').text(data.description).appendTo(result);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
}).dxList('instance');
|
|
|
|
}).dxList('instance');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -95,6 +110,7 @@ function initRegionDropDown() {
|
|
|
|
keyExpr: 'id',
|
|
|
|
keyExpr: 'id',
|
|
|
|
onItemClick(e) {
|
|
|
|
onItemClick(e) {
|
|
|
|
var region = data['regions'][e.itemData.id];
|
|
|
|
var region = data['regions'][e.itemData.id];
|
|
|
|
|
|
|
|
loadPoints(region);
|
|
|
|
rebuildRegionPointsList(region);
|
|
|
|
rebuildRegionPointsList(region);
|
|
|
|
DevExpress.ui.notify(`${e.itemData.name}`, 'success', 600);
|
|
|
|
DevExpress.ui.notify(`${e.itemData.name}`, 'success', 600);
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -102,13 +118,69 @@ function initRegionDropDown() {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function rebuildSelectedPointsList(selectedPointsIndexes)
|
|
|
|
// Перестроение списка выбранных точек
|
|
|
|
{
|
|
|
|
function rebuildSelectedPointsList(selectedPointsIndexes) {
|
|
|
|
|
|
|
|
let selected = [];
|
|
|
|
|
|
|
|
for (const p_idx in points) {
|
|
|
|
|
|
|
|
if (p_idx in selectedPointsIndexes) {
|
|
|
|
|
|
|
|
selected.push(points[p_idx]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectedPointsWidget) {
|
|
|
|
|
|
|
|
selectedPointsWidget.dispose();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
selectedPointsWidget = $("#selectedPointsList").dxList({
|
|
|
|
|
|
|
|
dataSource: selected,
|
|
|
|
|
|
|
|
keyExpr: 'id',
|
|
|
|
|
|
|
|
height: 400,
|
|
|
|
|
|
|
|
showScrollbar: 'always',
|
|
|
|
|
|
|
|
itemDragging: {
|
|
|
|
|
|
|
|
allowReordering: true,
|
|
|
|
|
|
|
|
data: selected,
|
|
|
|
|
|
|
|
group: 'selected',
|
|
|
|
|
|
|
|
onDragStart(e) {
|
|
|
|
|
|
|
|
e.itemData = e.fromData[e.fromIndex];
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onAdd(e) {
|
|
|
|
|
|
|
|
e.toData.splice(e.toIndex, 0, e.itemData);
|
|
|
|
|
|
|
|
e.component.reload();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onRemove(e) {
|
|
|
|
|
|
|
|
e.fromData.splice(e.fromIndex, 1);
|
|
|
|
|
|
|
|
e.component.reload();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onReorder({
|
|
|
|
|
|
|
|
fromIndex,
|
|
|
|
|
|
|
|
toIndex,
|
|
|
|
|
|
|
|
fromData,
|
|
|
|
|
|
|
|
component,
|
|
|
|
|
|
|
|
}) {
|
|
|
|
|
|
|
|
[fromData[fromIndex], fromData[toIndex]] = [fromData[toIndex], fromData[fromIndex]];
|
|
|
|
|
|
|
|
component.reload();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}).dxList('instance');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function initRecalculateWaypointsButton(){
|
|
|
|
|
|
|
|
$('#recalculateWaypointsButton').dxButton({
|
|
|
|
|
|
|
|
stylingMode: 'contained',
|
|
|
|
|
|
|
|
text: 'Рассчитать маршрут',
|
|
|
|
|
|
|
|
type: 'default',
|
|
|
|
|
|
|
|
width: 220,
|
|
|
|
|
|
|
|
onClick() {
|
|
|
|
|
|
|
|
recalculateWaypoints();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function recalculateWaypoints(){
|
|
|
|
|
|
|
|
DevExpress.ui.notify('The Text button was clicked');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$(() => {
|
|
|
|
$(() => {
|
|
|
|
initData();
|
|
|
|
initData();
|
|
|
|
initMap();
|
|
|
|
initMap();
|
|
|
|
initRegionDropDown();
|
|
|
|
initRegionDropDown();
|
|
|
|
|
|
|
|
initRecalculateWaypointsButton();
|
|
|
|
});
|
|
|
|
});
|