PythonHelp
1st March 2017, 21:51
So i'm using the Google Maps API to work out the straight-line distance between 2 points on the map.
gmaps="""
***generic google maps HTML api stuff first, then:***
overalldist=calcDistance(firstcoord, secondcoord);
alert(overalldist)
//calculates distance between two points in km's
function calcDistance(firstcoord, secondcoord) {
return (google.maps.geometry.spherical.computeDistanceBet ween(firstcoord, secondcoord) / 1000).toFixed(2);
"""
This is within the script section of my HTML code which is all placed within a simple string in Python. The string is called by:
self.webView.setHtml(gmaps)
Where gmaps is the string name that contains the HTML and webView is the name of the HTML viewer in my PyQt GUI.
The outcome is a popup box outputting the correct distance.
My issue is that I cannot extract the variable 'overalldist' from the HTML. The alert pops up with the correct distance but I then cannot move this into my Python code.
Please advise.
Any further ideas?
It is the function calcDistance I am attempting to retrieve from the HTML code to use in my Python code.
gmaps="""
***generic google maps HTML api stuff first, then:***
overalldist=calcDistance(firstcoord, secondcoord);
alert(overalldist)
//calculates distance between two points in km's
function calcDistance(firstcoord, secondcoord) {
return (google.maps.geometry.spherical.computeDistanceBet ween(firstcoord, secondcoord) / 1000).toFixed(2);
"""
This is within the script section of my HTML code which is all placed within a simple string in Python. The string is called by:
self.webView.setHtml(gmaps)
Where gmaps is the string name that contains the HTML and webView is the name of the HTML viewer in my PyQt GUI.
The outcome is a popup box outputting the correct distance.
My issue is that I cannot extract the variable 'overalldist' from the HTML. The alert pops up with the correct distance but I then cannot move this into my Python code.
Please advise.
Any further ideas?
It is the function calcDistance I am attempting to retrieve from the HTML code to use in my Python code.