One thing was always missing and that was the way back. For example how to read the current Lat Lon view position of the Google Maps view.
After some experiments I came to a simple timer based solution. The idea is that a timer function regularly polls the javascript document and parses the result.
First we take a look at the javascript code;
When the updateJavaFX() function is called the document variables (currentCenter for the position) are filled.
In the JavaFX code the following part (this part is called within an AnimationTimer) is used to retrieve the current lat lon position of the map.
Basically the trick is call the javascript document.updateJavaJX() function and then to read eg. the currentCenter javascript variable. I use the toString() function to convert it to a string and then parse it. The classcastexception is present when a different kind of map type is used eg. openstreetmap.
This all could result in the following application;
In the JavaFX code the following part (this part is called within an AnimationTimer) is used to retrieve the current lat lon position of the map.
Basically the trick is call the javascript document.updateJavaJX() function and then to read eg. the currentCenter javascript variable. I use the toString() function to convert it to a string and then parse it. The classcastexception is present when a different kind of map type is used eg. openstreetmap.
This all could result in the following application;
7 comments:
Hey man, thank you very much for your post. It helped me a lot. I am really a noob when it comes to JavaScript and JavaFX. I had everything working with GMaps but I could not retrieve the information from within the JavaScript code. Thanks to you I can go to sleep! Many thanks
Hey man, thank you very much for your post. It helped me a lot. I am really a noob when it comes to JavaScript and JavaFX. I had everything working with GMaps but I could not retrieve the information from within the JavaScript code. Thanks to you I can go to sleep! Many thanks
why you don't use the animation timer built in method in javaFX
please can you tell me what is the type of mCenterlat,mCenterlng and mZoom
can you tell me what is the type of mZoom ,mCenterlat and mCenterlng
They are all DoubleProperty
Post a Comment