From 39c7abe7611f9166e5fb30e0620ef1a9620e3441 Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Wed, 2 Jul 2014 14:47:33 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BF=D0=B8=D1=81=D1=8B=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B0=D1=80=D1=88=D1=80=D1=83=D1=82?= =?UTF-8?q?=D0=B0=20=D0=B2=20=D1=8D=D0=BA=D1=80=D0=B0=D0=BD;=20=D0=9D?= =?UTF-8?q?=D0=BE=D0=B2=D1=8B=D0=B9=20=D1=86=D0=B2=D0=B5=D1=82=20=D0=BC?= =?UTF-8?q?=D0=B0=D1=80=D1=88=D1=80=D1=83=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/route.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/public/js/route.js b/public/js/route.js index e881f11..13a6a4e 100644 --- a/public/js/route.js +++ b/public/js/route.js @@ -14,6 +14,19 @@ function buildRoute() $('#wayPoints div').each(function(i, el) { + lat = points[$(el).attr('pointId')]._latlng.lat; + lng = points[$(el).attr('pointId')]._latlng.lng; + + 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; + } + wayPoints.push({latLng: points[$(el).attr('pointId')]._latlng}); }); @@ -27,10 +40,19 @@ function buildRoute() route = L.Routing.line(routes[0]); distance = Math.round(routes[0].summary.totalDistance / 1000); $('#routeDistance').html('Протяженность ' + distance + ' км.'); + + route.options.styles = [ + {color: 'black', opacity: 0.5, weight: 9}, + {color: 'green', opacity: 0.7, weight: 7}, + {color: 'orange', opacity: 1, weight: 3} + ]; + route.addTo(myMap); } }); + myMap.fitBounds(bounds).zoomOut(); + routeToURL(); } }