Hi currently i am working on sharePoint online, Where i need to fetch the Current location (city) of the user and on the basis of that i want to get the temperature of that city. using JScript . Please help.

  • Are you managing user's location in Active Directory? Or you just mean the location from where users are browsing site? Feb 22, 2016 at 11:33

2 Answers 2


You can use below code to get current location if:

  1. User's browser supports HTML5 geolocation API; and
  2. User allows to share his/her location to your Application

        function onLocationUpdate(location) {
            var lat = location.coords.latitude;
            var lng = location.coords.longitude;
            console.log("Current location: " + lat + " " + lng);
        if(navigator.geolocation) {
        else {
            console.log("navigator.geolocation is not available");

As a fallback, you can use this API to get the Longitude and Latitude from user's IP address.

Once you've got the location, you can make a call to below API passing the Longitude and Latitude you've found:


You will get weather data in JSON format, which you can parse temperature data.


Try this SPServices method:

var thisUserID = $().SPServices.SPGetCurrentUser({
    fieldName: "Office",
    debug: false

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.