Closed renege closed 10 years ago
Why isn't the following working:
<input type="number" id="distance" value="10"> <input type="text" id="userLatitude" value="52.880709"> <input type="text" id="userLongitude" value="5.4560155"> <button id="search">go</button>
$(document).on('click', '#search', function(){ var userLatitude = $('#userLatitude').val(); var userLongitude = $('#userLongitude').val(); var user = { latitude: userLatitude, longitude: userLongitude }; var distance = parseInt($('#distance').val()) * 100; console.log(distance); $('.user').hide(); $('.user').each(function(index, value) { var talent = $(this).data('talent'); var lat = $(this).data('latitude'); var lng = $(this).data('longitude'); var current = { latitude: lat, longitude: lng }; var calculated = geolib.isPointInCircle( current, user, distance ); if(calculated){ $(this).show(); } console.log(calculated); }); return false; });
How to order this all by Distance? So the closest one shows first.
There are two methods: geolib.orderByDistance() and geolib.findNearest()
geolib.orderByDistance()
geolib.findNearest()
They will probably do exactly what you're trying to do.
Why isn't the following working:
How to order this all by Distance? So the closest one shows first.