BIG FIX - новая версия библиотеки с роутингом

This commit is contained in:
Krivchikov Dmitry 2016-10-10 22:18:47 +03:00
parent 50117d12b4
commit 98ccd3c334
3 changed files with 723 additions and 388 deletions

File diff suppressed because it is too large Load Diff

View File

@ -191,8 +191,10 @@ function constructPoint(data)
} else {
history.pushState({pointId: id}, document.title, "/?point=" + e.target.options.id);
document.title = e.target.options.title;
if (typeof yaCounter24682772 != 'undefined') {
yaCounter24682772.hit("/?point=" + e.target.options.id);
}
}
});
return points[id];
@ -377,8 +379,10 @@ function drawInfoPopup(id, showPopup, doNotPushToHistory) {
if (!doNotPushToHistory) {
history.pushState({pointId: id}, document.title, "/?point=" + id);
if (typeof yaCounter24682772 != 'undefined') {
yaCounter24682772.hit("/?point=" + id);
}
}
document.title = marker.options.title + ' wikipoints.ru';
});
@ -389,11 +393,15 @@ function drawInfoPopup(id, showPopup, doNotPushToHistory) {
}
}, 200);
if (typeof yaCounter24682772 != 'undefined') {
yaCounter24682772.reachGoal('VIEW_POINT');
}
if (data.isPaid == true) {
if (typeof yaCounter24682772 != 'undefined') {
yaCounter24682772.reachGoal('VIEW_PAID_POINT');
}
}
return true;
}

View File

@ -9,8 +9,6 @@
function buildRoute(fit)
{
wayPoints = Array();
if (route)
myMap.removeLayer(route);
$('#wayPoints div').each(function(i, el)
{
@ -32,49 +30,48 @@ function buildRoute(fit)
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)
{
L.Routing.osrm().route(wayPoints, function(err, routes) {
if (err) {
console.error(err);
alert('Произошла ошибка. Вероятно построить маршрут по выбранным точкам невозможно.');
} else {
route = L.Routing.line(routes[0], {styles:[
if (route) {
route.setWaypoints([])
}
route = L.Routing.control({waypoints: wayPoints,
lineOptions:
{styles: [
{color: 'black', opacity: 0.5, weight: 9},
{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> км.');
route.addTo(myMap);
}
route.hide();
});
route.on('routingerror', function (e) {
alert('Произошла ошибка. Вероятно построить маршрут по выбранным точкам невозможно.');
});
if (typeof yaCounter24682772 != 'undefined') {
yaCounter24682772.reachGoal('BUILD_ROUTE');
}
routeToURL();
}
}
/**
* Сохраняет маршрут на сервере.
* @returns {undefined}