How to get google maps current location in web app?

Hi Team,


I need some help to get google maps current location in web app browser.


Regards,

Naga

Hi Naga,

You can try using HTML5 Geolocation feature to obtain the coordinates to use in the Google maps widget.


Cheers,

Tiago.

HTML5 Location will only works in HTTPS. 

Harlin Setiadarma wrote:

HTML5 Location will only works in HTTPS. 

Don't see it as a problem nowadays.


Yup, it was just for info.

Tiago Gafeira wrote:

Hi Naga,

You can try using HTML5 Geolocation feature to obtain the coordinates to use in the Google maps widget.


Cheers,

Tiago.

Hi Tiago Gafeira, I am not getting that how can I use this javascript code in Outsytems, Can you please explain to me how to use this HTML5 Geolocation in Outsystems in order to display the current location on the map in the Web application.

I have already implemented the map and the marker on it based on interest point.

Gautam sharma wrote:

Tiago Gafeira wrote:

Hi Naga,

You can try using HTML5 Geolocation feature to obtain the coordinates to use in the Google maps widget.


Cheers,

Tiago.

Hi Tiago Gafeira, I am not getting that how can I use this javascript code in Outsytems, Can you please explain to me how to use this HTML5 Geolocation in Outsystems in order to display the current location on the map in the Web application.

I have already implemented the map and the marker on it based on interest point.

Hi Gautam 

I believe that you wanted to get current location(lat and long). So this you can achieve through HTML5 Geolocation method.

Follow these steps :

1. Create a Webscreen 

2. go to the sidebar javascript option and add this js code over there : 

     if (navigator.geolocation) {
              navigator.geolocation.getCurrentPosition(getPosition);
          } else {
             x.innerHTML = "Geolocation is not supported by this browser.";
      }

      function getPosition(position) {
           var lat = position.coords.latitude;
           var long = position.coords.longitude;
            alert(lat +" and " + long);
       }

3. Now publish and check it. 




Nitesh Pandey wrote:

Gautam sharma wrote:

Tiago Gafeira wrote:

Hi Naga,

You can try using HTML5 Geolocation feature to obtain the coordinates to use in the Google maps widget.


Cheers,

Tiago.

Hi Tiago Gafeira, I am not getting that how can I use this javascript code in Outsytems, Can you please explain to me how to use this HTML5 Geolocation in Outsystems in order to display the current location on the map in the Web application.

I have already implemented the map and the marker on it based on interest point.

Hi Gautam 

I believe that you wanted to get current location(lat and long). So this you can achieve through HTML5 Geolocation method.

Follow these steps :

1. Create a Webscreen 

2. go to the sidebar javascript option and add this js code over there : 

     if (navigator.geolocation) {
              navigator.geolocation.getCurrentPosition(getPosition);
          } else {
             x.innerHTML = "Geolocation is not supported by this browser.";
      }

      function getPosition(position) {
           var lat = position.coords.latitude;
           var long = position.coords.longitude;
            alert(lat +" and " + long);
       }

3. Now publish and check it. 


Thank You so much @Nitesh  pandey




Nitesh Pandey wrote:

Gautam sharma wrote:

Tiago Gafeira wrote:

Hi Naga,

You can try using HTML5 Geolocation feature to obtain the coordinates to use in the Google maps widget.


Cheers,

Tiago.

Hi Tiago Gafeira, I am not getting that how can I use this javascript code in Outsytems, Can you please explain to me how to use this HTML5 Geolocation in Outsystems in order to display the current location on the map in the Web application.

I have already implemented the map and the marker on it based on interest point.

Hi Gautam 

I believe that you wanted to get current location(lat and long). So this you can achieve through HTML5 Geolocation method.

Follow these steps :

1. Create a Webscreen 

2. go to the sidebar javascript option and add this js code over there : 

     if (navigator.geolocation) {
              navigator.geolocation.getCurrentPosition(getPosition);
          } else {
             x.innerHTML = "Geolocation is not supported by this browser.";
      }

      function getPosition(position) {
           var lat = position.coords.latitude;
           var long = position.coords.longitude;
            alert(lat +" and " + long);
       }

3. Now publish and check it. 





Hi Nitesh,

I want to get the current location of the user and pass it as origin address to the Map to create route.

How can I do that?

Please give me some idea.

Thanks,

Preeti

Preeti Gupta wrote:

[… large wall of text .]


Hi Nitesh,

I want to get the current location of the user and pass it as origin address to the Map to create route.

How can I do that?

Please give me some idea.

Thanks,

Preeti

Google has an API that can help you: https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding

Microsoft also has this functionality: https://docs.microsoft.com/en-us/bingmaps/rest-services/locations/find-a-location-by-point


SyntaxEditor Code Snippet

"  
if (navigator.geolocation) {
              navigator.geolocation.getCurrentPosition(getPosition);
console.log('Testing1');
          } else {
             
      }

      function getPosition(position) {
console.log('Testing'2);
         '"+ Latitude +"'= position.coords.latitude;
           '"+ Longitude +"'= position.coords.longitude;
       
       }"


I have used this javascript in runjavascript action. Still the longitude and latitude value is not set. Please help me out