Logicify / jquery-locationpicker-plugin

JQuery Location Picker plugin
MIT License
389 stars 260 forks source link

how to check if my current location is inside the radius circle of Picker? #87

Closed acitjazz closed 7 years ago

acitjazz commented 8 years ago

hi,, great plugin ,, thanks. but i have a question.. . how to check if my current location is inside the radius circle of Picker?

Sumragen commented 8 years ago

@acitjazz hi! You can write something like that

if(navigator.geolocation){
    navigator.geolocation.getCurrentPosition(function (position) {
        var location = $('#us3').locationpicker('location');
        var from = new google.maps.LatLng(location.latitude, location.longitude);
        var to = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
        alert(google.maps.geometry.spherical.computeDistanceBetween(from, to) <= location.radius);
    })
}

That must help you.

acitjazz commented 7 years ago

its work!! thankss...!!