I am using webkit2gtk-4.0 in my Vala appication to display Google Maps. And I need to get marker coordinates on button click. How can I manage it?
I figured out how to run javascript using run_javascript()
, but I can't understand hot to get the results of it.
Ordinarily you would need to use Vala's async functions to do this, I believe like so:
This is equivalent to the C function
webkit_web_view_run_javascript_finish()
.Unfortunately you can't take the next step shown at that link in Vala, as you need to use the JavaScriptCore API to get at the return value and that API isn't available in Vala.
There are a couple of dirty tricks that you can resort to in this case. One such trick is setting the window title at the end of your Javascript script, and watching for notifications on the webview's
title
property in Vala.However, you may be better off writing a small bit of code in C that you compile into your Vala application.