I have a project and its driving me insane, I have code to do geolocation/directions and it works amazing on everthing BUT ios7 and I have done heaps of research and I understand that its an issue with the .click event, my code is below.
$(document).ready(function () {
var startingLocation;
var destination = "20 Papanui Rd, Christchurch Central, Christchurch 8011, New Zealand"; // replace this with any destination
$('.get-directions').click(function (e) {
e.preventDefault();
// check if browser supports geolocation
if (navigator.geolocation) {
// get user's current position
navigator.geolocation.getCurrentPosition(function (position) {
// get latitude and longitude
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
startingLocation = latitude + "," + longitude;
// send starting location and destination to goToGoogleMaps function
goToGoogleMaps(startingLocation, destination);
});
}
// fallback for browsers without geolocation
else {
// get manually entered postcode
startingLocation = $('.manual-location').val();
// if user has entered a starting location, send starting location and destination to goToGoogleMaps function
if (startingLocation != '') {
goToGoogleMaps(startingLocation, destination);
}
// else fade in the manual postcode field
else {
$('.no-geolocation').fadeIn();
}
}
// go to Google Maps function - takes a starting location and destination and sends the query to Google Maps
function goToGoogleMaps(startingLocation, destination) {
window.location = "https://maps.google.com/maps?saddr=" + startingLocation + "&daddr=" + destination;
}
});
});
HTML:
<!--#container -->
<div id="mapcontainer">
<div class="no-geolocation">
<p class="warning">Your browser does not support Geolocation. Please enter your postcode and click the button again.</p>
<input type="text" placeholder="Enter postcode or address" class="manual-location">
</div>
<a href="#" class="get-directions">Give me directions</a>
</div>
<!-- /#container -->
Now I had a play with Touche.
<script type='text/javascript' src="files/scripts/touche.min.js"></script>
<script>
$(document).ready(function() {
$('.get-directions').on('click', handleClicks);
});
</script>
And all I got was an error handleClicks is not defined
and a couple of other hacky scripts with no luck and i'm at my end of technical ability to fix the issue.