|
|
|
@ -1,31 +1,10 @@
|
|
|
|
|
function loadPoints(region) {
|
|
|
|
|
let points = [];
|
|
|
|
|
for (var p_idx in region.points) {
|
|
|
|
|
var point = region.points[p_idx];
|
|
|
|
|
var loc = point.gps.split(',');
|
|
|
|
|
var lat = parseFloat(loc[0].trim())
|
|
|
|
|
var lon = parseFloat(loc[1].trim())
|
|
|
|
|
points.push({
|
|
|
|
|
id: p_idx,
|
|
|
|
|
text: point.name + ' (' + point.description + ')',
|
|
|
|
|
location: [lat, lon],
|
|
|
|
|
tooltip: {
|
|
|
|
|
text: point.description,
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return points;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(() => {
|
|
|
|
|
let markersData = [];
|
|
|
|
|
let regions = [];
|
|
|
|
|
let markersData = [];
|
|
|
|
|
let regions = [];
|
|
|
|
|
let points = [];
|
|
|
|
|
const markerUrl = './img/map-marker.png';
|
|
|
|
|
|
|
|
|
|
/*regions.push({
|
|
|
|
|
id: -1,
|
|
|
|
|
name: "-- Все регионы --",
|
|
|
|
|
icon: 'airplane'
|
|
|
|
|
});*/
|
|
|
|
|
// Инициализация данных, подготовка массивов для загрузки в контролы
|
|
|
|
|
function initData() {
|
|
|
|
|
for (var r_idx in data['regions']) {
|
|
|
|
|
var region = data['regions'][r_idx]
|
|
|
|
|
regions.push({
|
|
|
|
@ -46,9 +25,29 @@ $(() => {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const markerUrl = './img/map-marker.png';
|
|
|
|
|
// Загрузка точек на карте из региона
|
|
|
|
|
function loadPoints(region) {
|
|
|
|
|
points = [];
|
|
|
|
|
for (var p_idx in region.points) {
|
|
|
|
|
var point = region.points[p_idx];
|
|
|
|
|
var loc = point.gps.split(',');
|
|
|
|
|
var lat = parseFloat(loc[0].trim())
|
|
|
|
|
var lon = parseFloat(loc[1].trim())
|
|
|
|
|
points.push({
|
|
|
|
|
id: p_idx,
|
|
|
|
|
text: point.name + ' (' + point.description + ')',
|
|
|
|
|
location: [lat, lon],
|
|
|
|
|
tooltip: {
|
|
|
|
|
text: point.description,
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Инициализация контрола карты
|
|
|
|
|
function initMap() {
|
|
|
|
|
const mapWidget = $('#map').dxMap({
|
|
|
|
|
provider: 'bing',
|
|
|
|
|
apiKey: {
|
|
|
|
@ -56,13 +55,36 @@ $(() => {
|
|
|
|
|
},
|
|
|
|
|
zoom: 11,
|
|
|
|
|
height: 440,
|
|
|
|
|
width: '100%',
|
|
|
|
|
width: 760,
|
|
|
|
|
controls: true,
|
|
|
|
|
markerIconSrc: markerUrl,
|
|
|
|
|
markers: markersData,
|
|
|
|
|
type: 'roadmap'
|
|
|
|
|
}).dxMap('instance');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Пересоздание списка точек указанного региона, для выбора мест к посещению
|
|
|
|
|
function rebuildRegionPointsList(region) {
|
|
|
|
|
loadPoints(region);
|
|
|
|
|
const listWidget = $('#regionPointsList').dxList({
|
|
|
|
|
dataSource: new DevExpress.data.DataSource({
|
|
|
|
|
store: new DevExpress.data.ArrayStore({
|
|
|
|
|
key: 'id',
|
|
|
|
|
data: points,
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
height: 400,
|
|
|
|
|
showSelectionControls: true,
|
|
|
|
|
selectionMode: 'all',
|
|
|
|
|
selectByClick: false,
|
|
|
|
|
onSelectionChanged() {
|
|
|
|
|
rebuildSelectedPointsList(listWidget.option('selectedItemKeys'));
|
|
|
|
|
},
|
|
|
|
|
}).dxList('instance');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Инициализация выпадающего списка с регионами
|
|
|
|
|
function initRegionDropDown() {
|
|
|
|
|
$('#one-section').dxDropDownButton({
|
|
|
|
|
text: 'Выбор региона',
|
|
|
|
|
icon: 'globe',
|
|
|
|
@ -73,25 +95,20 @@ $(() => {
|
|
|
|
|
keyExpr: 'id',
|
|
|
|
|
onItemClick(e) {
|
|
|
|
|
var region = data['regions'][e.itemData.id];
|
|
|
|
|
var points = loadPoints(region);
|
|
|
|
|
const listWidget = $('#simpleList').dxList({
|
|
|
|
|
dataSource: new DevExpress.data.DataSource({
|
|
|
|
|
store: new DevExpress.data.ArrayStore({
|
|
|
|
|
key: 'id',
|
|
|
|
|
data: points,
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
height: 400,
|
|
|
|
|
showSelectionControls: true,
|
|
|
|
|
selectionMode: 'all',
|
|
|
|
|
selectByClick: false,
|
|
|
|
|
|
|
|
|
|
onSelectionChanged() {
|
|
|
|
|
alert(listWidget.option('selectedItemKeys').join(', '));
|
|
|
|
|
},
|
|
|
|
|
}).dxList('instance');
|
|
|
|
|
rebuildRegionPointsList(region);
|
|
|
|
|
DevExpress.ui.notify(`${e.itemData.name}`, 'success', 600);
|
|
|
|
|
},
|
|
|
|
|
items: regions,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function rebuildSelectedPointsList(selectedPointsIndexes)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(() => {
|
|
|
|
|
initData();
|
|
|
|
|
initMap();
|
|
|
|
|
initRegionDropDown();
|
|
|
|
|
});
|