jquery-locationpicker-plugin icon indicating copy to clipboard operation
jquery-locationpicker-plugin copied to clipboard

Geolocation option

Open anantzoid opened this issue 9 years ago • 3 comments

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

anantzoid avatar Jun 13 '16 12:06 anantzoid

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.

Birdie9488 avatar Aug 31 '16 15:08 Birdie9488

    // 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">

twobob avatar Jun 15 '17 01:06 twobob

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

memorx avatar Jul 09 '19 16:07 memorx