Logicify / jquery-locationpicker-plugin

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

Geolocation option #70

Open anantzoid opened 8 years ago

anantzoid commented 8 years ago

The option to geolocate the user seems to be missing right now. There can be google's crosshair icon on the top of the map for geolocation, and also an option while initialization, if user should be geolocated by default. Is the absence of this feature by design? If not, I can submit a PR shortly, as I've implemented it locally for my requirements. Thanks

Birdie9488 commented 8 years ago

I have been looking into using this with Geolocation in at the start but have so far failed to get it working how I'd like.

If you could add a PR for that it would be hugely appreciated.

twobob commented 7 years ago
    // quick and dirty example geo
      var  findgeo = function () {
            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(setPosition, showError);
            } else {
             // we failed - do something here when the browser totally does not support the method      
            }
        }

        function showError(error) {
    switch(error.code) {
        case error.PERMISSION_DENIED:
           $('#defaultCity').text( "You must allow Geolocation!");
            break;
        case error.POSITION_UNAVAILABLE:
           $('#defaultCity').text( "Location information is unavailable.");
            break;
        case error.TIMEOUT:
          $('#defaultCity').text( "The request to get user location timed out.");
            break;
        case error.UNKNOWN_ERROR:
          $('#defaultCity').text( "An unknown error occurred. boo");
            break;
         }
      }  

        var updatePosition = function () {
            var addressComponents = $('#us3').locationpicker('map').location.addressComponents;
            updateControls(addressComponents);
        }

        function setPosition(position) {
            $('#us3').locationpicker("location", {
                latitude: position.coords.latitude,
                longitude: position.coords.longitude
            });
            setTimeout(updatePosition, 250);
        }

image

HTML <img class="geoHolder" onclick="findgeo()" src="geotag.png">

memorx commented 5 years ago

Good day @anantzoid, were you able to commit your PR for this feature?