ADD Добавление в маршрут произвольных точек
This commit is contained in:
parent
a72b69a3f1
commit
01ee3ee34c
|
|
@ -13,6 +13,7 @@ var addPointInProcess = false;
|
|||
var layer;
|
||||
var layers = Array();
|
||||
var defaultZoom = 13;
|
||||
var rightCoords = [];
|
||||
|
||||
categories.im = L.icon({
|
||||
iconUrl: '/ico/man.png',
|
||||
|
|
@ -109,6 +110,19 @@ function init(lat, lng) {
|
|||
filter()
|
||||
});
|
||||
|
||||
// Добавление произвольной точки в маршрут по правому клику
|
||||
myMap.on('contextmenu',function(e){
|
||||
if (status == statusReady)
|
||||
{
|
||||
rightCoords = [e.latlng.lat, e.latlng.lng];
|
||||
popupContent = '<button type="button" class="btn btn-default" onclick="addToRoute(rightCoords)"><span class="glyphicon glyphicon-map-marker"></span> Добавить в маршрут</button>';
|
||||
popup = L.popup();
|
||||
popup.setContent(popupContent);
|
||||
popup.setLatLng(e.latlng);
|
||||
popup.openOn(myMap);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,18 @@ function buildRoute(fit)
|
|||
|
||||
$('#wayPoints div').each(function(i, el)
|
||||
{
|
||||
lat = points[$(el).attr('pointId')]._latlng.lat;
|
||||
lng = points[$(el).attr('pointId')]._latlng.lng;
|
||||
if ($(el).attr('pointId').length <= 10) {
|
||||
lat = points[$(el).attr('pointId')]._latlng.lat;
|
||||
lng = points[$(el).attr('pointId')]._latlng.lng;
|
||||
|
||||
wayPoints.push({latLng: points[$(el).attr('pointId')]._latlng});
|
||||
} else {
|
||||
coords = JSON.parse($(el).attr('pointId'));
|
||||
lat = coords[0];
|
||||
lng = coords[1];
|
||||
|
||||
wayPoints.push({latLng: {lat: lat, lng: lng}});
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
|
|
@ -26,8 +36,6 @@ function buildRoute(fit)
|
|||
if (lat > bounds[1][0]) bounds[1][0] = lat;
|
||||
if (lng > bounds[1][1]) bounds[1][1] = lng;
|
||||
}
|
||||
|
||||
wayPoints.push({latLng: points[$(el).attr('pointId')]._latlng});
|
||||
});
|
||||
|
||||
if (fit === true)
|
||||
|
|
@ -103,6 +111,10 @@ function loadRouteJSON(data)
|
|||
response = JSON.parse(data);
|
||||
for (var k in response)
|
||||
{
|
||||
if (response[k].length >= 10) {
|
||||
response[k] = JSON.parse(response[k]);
|
||||
}
|
||||
|
||||
addToRoute(response[k], false);
|
||||
}
|
||||
|
||||
|
|
@ -151,14 +163,30 @@ function deleteRoute(id)
|
|||
*/
|
||||
function addToRoute(id, build)
|
||||
{
|
||||
$('#wayPoints').append('<div pointid="' + id + '" class="wayPoint" onclick="showInfo('+ id +');"><span class="del" onclick="$(this).parent().remove();buildRoute();">×</span> '+ points[id].options.title + '</div>');
|
||||
closePopup();
|
||||
openBox('Route', true);
|
||||
if ($.isArray(id)) {
|
||||
n = (id[0]>=0) ? 'N'+id[0] : 'S'+Math.abs(id[0]);
|
||||
e = (id[1]>=0) ? 'E'+id[1] : 'W'+Math.abs(id[1]);
|
||||
|
||||
if (build !== false)
|
||||
buildRoute();
|
||||
coordsName = n.substring(0,10)+'° '+e.substring(0,10)+'°';
|
||||
$('#wayPoints').append('<div pointid="'+JSON.stringify(id)+'" class="wayPoint"><span class="del" onclick="$(this).parent().remove();buildRoute();">×</span> '+coordsName+'</div>');
|
||||
closePopup();
|
||||
openBox('Route', true);
|
||||
|
||||
return true;
|
||||
if (build !== false) {
|
||||
buildRoute();
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$('#wayPoints').append('<div pointid="' + id + '" class="wayPoint" onclick="showInfo('+ id +');"><span class="del" onclick="$(this).parent().remove();buildRoute();">×</span> '+ points[id].options.title + '</div>');
|
||||
closePopup();
|
||||
openBox('Route', true);
|
||||
|
||||
if (build !== false)
|
||||
buildRoute();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue