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

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
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?
yes tell me how to know that one
You'll need to use the Geolocation API for that :

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?

Yes - you have to write the information to the geolocation field, through JavaScript.
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?
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 :)
thank you bob_buzzard
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>
function geoFindMe() {
  var output = document.getElementById("out");

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

  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);
<apex:form id="form">
latitude :<apex:inputField id="lati" value="{!Candidate__c.SSN__c}" />
longitude :<apex:inputField id="long" value="{!Candidate__c.Street__c}" />

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...