In my mobile app, I've got users geolocation using the following code. I also have a geolocaion (latitude, longitude) of nearby cities. I can put the geolocation data of cities in array or SQLite database. How do I get and display the 3 closest cities near the users location using jQuery or JavaScript. I'm not using Google Maps.
$(document).ready(function() {
var Geo={};
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
}
//Get the latitude and the longitude;
function success(position) {
Geo.lat = position.coords.latitude;
Geo.lng = position.coords.longitude;
}
function error(){
console.log("Geocoder failed");
}
function populateHeader(lat, lng){
$('#myPopup').append('<p>Lattitude: ' + lat);
$('#myPopup').append('<br />Longitude: ' + lng + '</p>');
}
});
Thanks
Joe
Aucun commentaire:
Enregistrer un commentaire