ruby on rails 4 - Access current location of user using IP address -


is there solution can access user current location,

i use geocoder gem

@request = request.location 

but give reserved or nil entry

first of put code in html page

<script> var x = document.getelementbyid("demo"); function getlocation() {     if (navigator.geolocation) {         navigator.geolocation.getcurrentposition(showposition);     } else {         x.innerhtml = "geolocation not supported browser.";     } } function showposition(position) {     x.innerhtml = "latitude: " + position.coords.latitude +      "<br>longitude: " + position.coords.longitude;  } </script> 

you latitude & longitude of location code.then after use value of latitude & longitude geocoder gem. able find address of location.

you can see here. http://www.w3schools.com/html/html5_geolocation.asp


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -