Merge pull request #56 from gdgistanbul/auto-directions

Auto Directions in Logistics page
This commit is contained in:
Oleh Zasadnyy 2015-02-20 23:43:30 +02:00
commit e7d6a968cd
4 changed files with 19 additions and 10 deletions

View file

@ -215,6 +215,7 @@ findWayTransit: "TRANSIT"
findWayFindFlight: "Find Flight" findWayFindFlight: "Find Flight"
logisticsMapCenterCoordinates: "49.056728, 3.117289" logisticsMapCenterCoordinates: "49.056728, 3.117289"
logisticsMapMobileCenterCoordinates: "48.335365, 23.711648" logisticsMapMobileCenterCoordinates: "48.335365, 23.711648"
logisticsMapAutoDirections: true
# Logistics Direction Details Block # Logistics Direction Details Block
directionDetailsImage: "direction-details.jpg" directionDetailsImage: "direction-details.jpg"

View file

@ -53,6 +53,9 @@ layout: compress
</script> </script>
{% elsif page.permalink == '/logistics/' %} {% elsif page.permalink == '/logistics/' %}
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places,geometry"></script> <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 %} {% endif %}
<script> <script>
Waves.displayEffect(); Waves.displayEffect();

View file

@ -484,6 +484,15 @@
$('#find-way h3').removeClass('fadeInUp').addClass('fadeOutDown'); $('#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) { function makeMarker(position) {
var directionMarker = new google.maps.Marker({ var directionMarker = new google.maps.Marker({
position: position, position: position,
@ -542,15 +551,7 @@
calcRoute(origin, selectedMode); calcRoute(origin, selectedMode);
}); });
$("#direction-locate").click(calcRouteFromMyLocation);
$("#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-cancel").click(function() { $("#direction-cancel").click(function() {
$('#find-way').removeClass('location-active'); $('#find-way').removeClass('location-active');
@ -570,6 +571,10 @@
smoothZoom(5); smoothZoom(5);
$('#find-way h3').removeClass('fadeOutDown').addClass('fadeInUp'); $('#find-way h3').removeClass('fadeOutDown').addClass('fadeInUp');
}); });
if (autoDirectionEnabled) {
calcRouteFromMyLocation();
}
} }
google.maps.event.addDomListener(window, 'load', initialize); google.maps.event.addDomListener(window, 'load', initialize);

2
js/scripts.min.js vendored

File diff suppressed because one or more lines are too long