Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2615279

Browse files
committed
Merge pull request #57 from gdg-x/develop
Added a configuration for Jekyll to enable/disable auto directions on Logistics page
2 parents 9ec3cc6 + e7d6a96 commit 2615279

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ findWayTransit: "TRANSIT"
215215
findWayFindFlight: "Find Flight"
216216
logisticsMapCenterCoordinates: "49.056728, 3.117289"
217217
logisticsMapMobileCenterCoordinates: "48.335365, 23.711648"
218+
logisticsMapAutoDirections: true
218219

219220
# Logistics Direction Details Block
220221
directionDetailsImage: "direction-details.jpg"

_layouts/default.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
</script>
5454
{% elsif page.permalink == '/logistics/' %}
5555
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places,geometry"></script>
56+
<script type="text/javascript">
57+
var autoDirectionEnabled = {% if site.logisticsMapAutoDirections %} true {% else %} false {% endif %};
58+
</script>
5659
{% endif %}
5760
<script>
5861
Waves.displayEffect();

js/scripts.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,15 @@
483483
setDirectionInput(origin);
484484
$('#find-way h3').removeClass('fadeInUp').addClass('fadeOutDown');
485485
}
486+
487+
function calcRouteFromMyLocation() {
488+
if (navigator.geolocation) {
489+
navigator.geolocation.getCurrentPosition(function(position) {
490+
origin = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
491+
calcRoute(origin, 'TRANSIT');
492+
});
493+
}
494+
}
486495

487496
function makeMarker(position) {
488497
var directionMarker = new google.maps.Marker({
@@ -542,15 +551,7 @@
542551
calcRoute(origin, selectedMode);
543552
});
544553

545-
546-
$("#direction-locate").click(function() {
547-
if (navigator.geolocation) {
548-
navigator.geolocation.getCurrentPosition(function(position) {
549-
origin = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
550-
calcRoute(origin, 'TRANSIT');
551-
});
552-
}
553-
});
554+
$("#direction-locate").click(calcRouteFromMyLocation);
554555

555556
$("#direction-cancel").click(function() {
556557
$('#find-way').removeClass('location-active');
@@ -570,6 +571,10 @@
570571
smoothZoom(5);
571572
$('#find-way h3').removeClass('fadeOutDown').addClass('fadeInUp');
572573
});
574+
575+
if (autoDirectionEnabled) {
576+
calcRouteFromMyLocation();
577+
}
573578
}
574579

575580
google.maps.event.addDomListener(window, 'load', initialize);

0 commit comments

Comments
 (0)