jquery-latitude-longitude-picker-gmaps
                                
                                
                                
                                    jquery-latitude-longitude-picker-gmaps copied to clipboard
                            
                            
                            
                        More of a suggestion
How hard would it be to default the map to the browsers location(assuming the browser supported it), if the initial values for lat and long are simply omitted? I dug through the javascript(not a js programmer :() and I didn't see an obvious solution. The navigator.geolocation.getcurrentposition call appears to be an async call, so when I tried to use it, the map was drawn before the values returned. Not being a js programmer, I wasn't sure how to do await navigator.geolocation.getcurrentposition...
After wasting some time I decided I should ask as I am probably missing something very obvious? All I want to do is use your plugin with the default location being somewhere in the ballpark of the users location if they browser supports it. It not, I will just end up setting a default somewhere close to the area I expect the most users from. Not a deal breaker either way.
Using the browser's location features (and assuming that the ".gllpLatlonPicker" class name makes sense in your case), you can do something like:
if (navigator && navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(location) {
        if ( !$(".gllpLatlonPicker .gllpLatitude").val() || !$(".gllpLatlonPicker .gllpLongitude").val() ) {
            $(".gllpLatlonPicker .gllpLatitude").val(location.coords.latitude);
            $(".gllpLatlonPicker .gllpLongitude").val(location.coords.longitude);
            $(document).trigger("gllp_update_fields");
        }
    }, function() {});
}
                                    
                                    
                                    
                                
Oh wow, I was missing something obvious for sure! I guess I don't understand how classes work in javascript very well, which is to be expected from a c# developer :) I'll play around with this and see how it works for me and let you know, but my initial copy and past pretty much gives me exactly what I was looking for, so unless I find edge cases I don't see any issues here.
Thanks for pointing me in the right direction!
Hi! Firstly, I would like to implement exactly same thing in my project, i tried the codes above but it's not working for me...I think am wrongly attaching the code, please where in the original code should insert the above code?
Secondly, i would like to create another latitude and longitude box which reads in the coordinates of the movement of the mouse from the map...
I am a newbie to coding, trying to learn by practice...Thanks in advance!!!
sankareb, just try adding it to it's own script tag at the bottom of your page and it should work. It doesn't go in the original code.