GPS Coordinates with JavaScript

I am using Javascript to get the GPS coordinates of the user. Now I want to send the coordinates back to the server by using REST API. Not able to achieve via Ajax call as CORS is blocked. What else I can do to send my GPS coordinates back to the server.

I am using Vaadin 14.

You can execute the JavaScript from the server.

then you’ll get the information back to the server

this is my code chunk. I am not good in Javascript. I am getting error of Typeerror: cannot read properties of undefined
message.txt (1.96 KB)

You cannot use ClientCallable in your view:
Read the documentiation: You can use it anywhere in your client-side Polymer class implementation

You have to create component

I’ve sent you the wrong link

page.executeJs("return <the JS mehod>()").then(String.class, 
   response -> {

in the then method you will get the value

Do you mean you are trying to use the geolocation API from the browser and share that location to the server side code? Here is a link to an example that does exactly that. It uses v23 and shows to location on the Map component, but you can probably figure out the principle: maptesting/src/main/java/com/example/application/ at main · mstahv/maptesting · GitHub

And upvote this feature proposal I recently created :sunglasses: Add support for Geolocation APIs · vaadin · Discussion #3211 · GitHub