mirror of
https://github.com/medialab-prado/datamad2017.git
synced 2024-12-26 12:41:23 +01:00
Merge pull request #56 from gdgistanbul/auto-directions
Auto Directions in Logistics page
This commit is contained in:
commit
e7d6a968cd
4 changed files with 19 additions and 10 deletions
|
@ -215,6 +215,7 @@ findWayTransit: "TRANSIT"
|
|||
findWayFindFlight: "Find Flight"
|
||||
logisticsMapCenterCoordinates: "49.056728, 3.117289"
|
||||
logisticsMapMobileCenterCoordinates: "48.335365, 23.711648"
|
||||
logisticsMapAutoDirections: true
|
||||
|
||||
# Logistics Direction Details Block
|
||||
directionDetailsImage: "direction-details.jpg"
|
||||
|
|
|
@ -53,6 +53,9 @@ layout: compress
|
|||
</script>
|
||||
{% elsif page.permalink == '/logistics/' %}
|
||||
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places,geometry"></script>
|
||||
<script type="text/javascript">
|
||||
var autoDirectionEnabled = {% if site.logisticsMapAutoDirections %} true {% else %} false {% endif %};
|
||||
</script>
|
||||
{% endif %}
|
||||
<script>
|
||||
Waves.displayEffect();
|
||||
|
|
|
@ -483,6 +483,15 @@
|
|||
setDirectionInput(origin);
|
||||
$('#find-way h3').removeClass('fadeInUp').addClass('fadeOutDown');
|
||||
}
|
||||
|
||||
function calcRouteFromMyLocation() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(function(position) {
|
||||
origin = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
|
||||
calcRoute(origin, 'TRANSIT');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function makeMarker(position) {
|
||||
var directionMarker = new google.maps.Marker({
|
||||
|
@ -542,15 +551,7 @@
|
|||
calcRoute(origin, selectedMode);
|
||||
});
|
||||
|
||||
|
||||
$("#direction-locate").click(function() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(function(position) {
|
||||
origin = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
|
||||
calcRoute(origin, 'TRANSIT');
|
||||
});
|
||||
}
|
||||
});
|
||||
$("#direction-locate").click(calcRouteFromMyLocation);
|
||||
|
||||
$("#direction-cancel").click(function() {
|
||||
$('#find-way').removeClass('location-active');
|
||||
|
@ -570,6 +571,10 @@
|
|||
smoothZoom(5);
|
||||
$('#find-way h3').removeClass('fadeOutDown').addClass('fadeInUp');
|
||||
});
|
||||
|
||||
if (autoDirectionEnabled) {
|
||||
calcRouteFromMyLocation();
|
||||
}
|
||||
}
|
||||
|
||||
google.maps.event.addDomListener(window, 'load', initialize);
|
||||
|
|
2
js/scripts.min.js
vendored
2
js/scripts.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue