function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
srilakshmi1.387861669756762E12srilakshmi1.387861669756762E12 

how to get current location of user in sales force

i think in Manage Users->users->Locale Settings->Locale is the current location of sales force user can ant one suggest is it corret or not please
bob_buzzardbob_buzzard
Locale doesn't necessarily refer to location - it defines the language, currency, number format etc.  Can you clarify what you mean by current location - for example, do you want to know where the user is physically located?
srilakshmi1.387861669756762E12srilakshmi1.387861669756762E12
yes tell me how to know that one
bob_buzzardbob_buzzard
You'll need to use the Geolocation API for that : 

https://developer.mozilla.org/en/docs/WebAPI/Using_geolocation

srilakshmi1.387861669756762E12srilakshmi1.387861669756762E12
so i have to create a filed with Geolocation type  ,later i have to give any location name to that field.finally that is the location of sales force user  am i correct?

bob_buzzardbob_buzzard
Yes - you have to write the information to the geolocation field, through JavaScript.
srilakshmi1.387861669756762E12srilakshmi1.387861669756762E12
ok ,so Find the longitude and latitude of the current location and display it in a field  for this question explain the process what i have to do?
bob_buzzardbob_buzzard
Geolocation is a JavaScript API, so you'll have to have a Visualforce page, sidebar component or mobile application which the user opens to capture their current location.  Having captured it in JavaScript, you'll then need to write it back to the Salesforce server.  There's a recipe for this in my book (Visualforce Development Cookbook, available from all good booksellers :)
srilakshmi1.387861669756762E12srilakshmi1.387861669756762E12
thank you bob_buzzard
srilakshmi1.387861669756762E12srilakshmi1.387861669756762E12
i got solution for my question .thank you so much bob_buzzard.
any one see this code may be helpfull to you 

<apex:page standardController="Candidate__c" id="page">
<p><button onclick="geoFindMe()">Show my location</button></p>
<p id="out"></p>
<script>
function geoFindMe() {
  var output = document.getElementById("out");

  if (!navigator.geolocation){
    output.innerHTML = "<p>Geolocation is not supported by your browser</p>";
    return;
  }

  function success(position) {
    var latitude  = position.coords.latitude;
    var longitude = position.coords.longitude;
    document.getElementById('page:form:lati').value = latitude  ;
    document.getElementById('page:form:long').value = longitude  ;  
   
   
  };

  function error() {
    output.innerHTML = "Unable to retrieve your location";
  };

  navigator.geolocation.getCurrentPosition(success, error);
}
</script>
<apex:form id="form">
latitude :<apex:inputField id="lati" value="{!Candidate__c.SSN__c}" />
longitude :<apex:inputField id="long" value="{!Candidate__c.Street__c}" />
</apex:form>

</apex:page>
Roman Savinuik 9Roman Savinuik 9
Thank you srilakshmi1.387861669756762E12
Sergey OzherowskySergey Ozherowsky
Guys ok) But how to get user's city using current position (latitude, longitude)? Have you examples? I break my head...