-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapFunctions.js
More file actions
41 lines (33 loc) · 1.38 KB
/
MapFunctions.js
File metadata and controls
41 lines (33 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//$(document).ready(function() {
// Enter necessary functions here
$('#gmap-3').live("pageshow", function() {
//$('#map_canvas_2').gmap('refresh');
$('#map_canvas_1').gmap('getCurrentPosition', function(position, status) {
if ( status === 'OK' ) {
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude)
$('#map_canvas_1').gmap('get', 'map').panTo(latlng);
$('#map_canvas_1').gmap('search', { 'location': latlng }, function(results, status) {
if ( status === 'OK' ) {
$('#from').val(results[0].formatted_address);
}
});
} else {
alert('Unable to get current position');
}
});
});
// To stop the click from looping into nonsense
$('#gmap-3').live("pagecreate", function() {
$('#map_canvas_1').gmap({'center': '59.3426606750, 18.0736160278'});
$('#submit').click(function() {
$('#map_canvas_1').gmap('displayDirections', { 'origin': $('#from').val(), 'destination': $('#to').val(), 'travelMode': google.maps.DirectionsTravelMode.DRIVING }, { 'panel': document.getElementById('directions')}, function(success, response) {
if ( success ) {
$('#results').show();
} else {
$('#results').hide();
}
});
return false;
});
});
//});