BIG FIX - новая версия библиотеки с роутингом
This commit is contained in:
parent
50117d12b4
commit
98ccd3c334
File diff suppressed because it is too large
Load Diff
|
|
@ -191,8 +191,10 @@ function constructPoint(data)
|
||||||
} else {
|
} else {
|
||||||
history.pushState({pointId: id}, document.title, "/?point=" + e.target.options.id);
|
history.pushState({pointId: id}, document.title, "/?point=" + e.target.options.id);
|
||||||
document.title = e.target.options.title;
|
document.title = e.target.options.title;
|
||||||
|
if (typeof yaCounter24682772 != 'undefined') {
|
||||||
yaCounter24682772.hit("/?point=" + e.target.options.id);
|
yaCounter24682772.hit("/?point=" + e.target.options.id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return points[id];
|
return points[id];
|
||||||
|
|
@ -377,8 +379,10 @@ function drawInfoPopup(id, showPopup, doNotPushToHistory) {
|
||||||
|
|
||||||
if (!doNotPushToHistory) {
|
if (!doNotPushToHistory) {
|
||||||
history.pushState({pointId: id}, document.title, "/?point=" + id);
|
history.pushState({pointId: id}, document.title, "/?point=" + id);
|
||||||
|
if (typeof yaCounter24682772 != 'undefined') {
|
||||||
yaCounter24682772.hit("/?point=" + id);
|
yaCounter24682772.hit("/?point=" + id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
document.title = marker.options.title + ' – wikipoints.ru';
|
document.title = marker.options.title + ' – wikipoints.ru';
|
||||||
});
|
});
|
||||||
|
|
@ -389,11 +393,15 @@ function drawInfoPopup(id, showPopup, doNotPushToHistory) {
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|
||||||
|
if (typeof yaCounter24682772 != 'undefined') {
|
||||||
yaCounter24682772.reachGoal('VIEW_POINT');
|
yaCounter24682772.reachGoal('VIEW_POINT');
|
||||||
|
}
|
||||||
|
|
||||||
if (data.isPaid == true) {
|
if (data.isPaid == true) {
|
||||||
|
if (typeof yaCounter24682772 != 'undefined') {
|
||||||
yaCounter24682772.reachGoal('VIEW_PAID_POINT');
|
yaCounter24682772.reachGoal('VIEW_PAID_POINT');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@
|
||||||
function buildRoute(fit)
|
function buildRoute(fit)
|
||||||
{
|
{
|
||||||
wayPoints = Array();
|
wayPoints = Array();
|
||||||
if (route)
|
|
||||||
myMap.removeLayer(route);
|
|
||||||
|
|
||||||
$('#wayPoints div').each(function(i, el)
|
$('#wayPoints div').each(function(i, el)
|
||||||
{
|
{
|
||||||
|
|
@ -32,47 +30,46 @@ function buildRoute(fit)
|
||||||
markers.addLayer(points[costomPointName]);
|
markers.addLayer(points[costomPointName]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
bounds = [[lat, lng],[lat, lng]];
|
|
||||||
} else {
|
|
||||||
if (lat < bounds[0][0]) bounds[0][0] = lat;
|
|
||||||
if (lng < bounds[0][1]) bounds[0][1] = lng;
|
|
||||||
if (lat > bounds[1][0]) bounds[1][0] = lat;
|
|
||||||
if (lng > bounds[1][1]) bounds[1][1] = lng;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (fit === true)
|
|
||||||
{
|
|
||||||
myMap.fitBounds(bounds).zoomOut();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wayPoints.length > 1)
|
if (wayPoints.length > 1)
|
||||||
{
|
{
|
||||||
L.Routing.osrm().route(wayPoints, function(err, routes) {
|
if (route) {
|
||||||
if (err) {
|
route.setWaypoints([])
|
||||||
console.error(err);
|
}
|
||||||
alert('Произошла ошибка. Вероятно построить маршрут по выбранным точкам невозможно.');
|
|
||||||
} else {
|
route = L.Routing.control({waypoints: wayPoints,
|
||||||
route = L.Routing.line(routes[0], {styles:[
|
lineOptions:
|
||||||
|
{styles: [
|
||||||
{color: 'black', opacity: 0.5, weight: 9},
|
{color: 'black', opacity: 0.5, weight: 9},
|
||||||
{color: 'green', opacity: 0.7, weight: 7},
|
{color: 'green', opacity: 0.7, weight: 7},
|
||||||
{color: 'orange', opacity: 1, weight: 3}
|
{color: 'orange', opacity: 1, weight: 3}]},
|
||||||
]});
|
fitSelectedRoutes: (fit === true),
|
||||||
|
createMarker: function () {
|
||||||
|
return null;
|
||||||
|
}});
|
||||||
|
|
||||||
distance = Math.round(routes[0].summary.totalDistance / 1000);
|
|
||||||
|
route.on('routesfound', function (e) {
|
||||||
|
distance = Math.round(e.routes[0].summary.totalDistance / 1000);
|
||||||
$('#routeDistance').html('Протяженность <b>' + distance + '</b> км.');
|
$('#routeDistance').html('Протяженность <b>' + distance + '</b> км.');
|
||||||
|
|
||||||
route.addTo(myMap);
|
route.addTo(myMap);
|
||||||
}
|
route.hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
route.on('routingerror', function (e) {
|
||||||
|
alert('Произошла ошибка. Вероятно построить маршрут по выбранным точкам невозможно.');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (typeof yaCounter24682772 != 'undefined') {
|
||||||
yaCounter24682772.reachGoal('BUILD_ROUTE');
|
yaCounter24682772.reachGoal('BUILD_ROUTE');
|
||||||
}
|
}
|
||||||
|
|
||||||
routeToURL();
|
routeToURL();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue