i have a javaFx webview map with ” open Street Map ” , i want to get the latitude and longitude from js to Java , but it shows me this error :
Caused by: netscape.javascript.JSException: ReferenceError: Can't find variable: lat
Java
url = this.getClass().getResource("map/index.html");
webengine.load(url.toString());
String fullName = (String) webview.getEngine().executeScript("lat");
System.out.println("Lat: " + fullName);
Java Script
let lat;
let lon;
map.on('click', function (e) {
lat=e.latlng.lat;
lon = e.latlng.lng;
lati=document.getElementById('latitude').textContent = lat;
loni=document.getElementById('longitude').textContent = lon;
});
i want to get the lat from js to java , Anyy Solution ?