[Qt-interest] Unable to load Google maps in Qt widgets through QWebview and evaluateJavaScript function
Anisha Kaul
born.rebel.83 at gmail.com
Fri May 27 10:52:39 CEST 2011
Found the answer!
Any Javascript function which has to be called from function *
evaluateJavaScript* is supposed to defined in an html file read by the C++
source as shown below:
Now instead of creating a new add marker function, I have added its code in
the Open function defined below:
---------------------------
var map;
function initialize()
{
if (GBrowserIsCompatible())
{
map = new GMap2(document.getElementById("map"));
map.setCenter( new GLatLng(0,0),1 );
}
}
function Open (x,y)
{
map.setCenter (new GLatLng(x,y), 13);
var point = new GLatLng (x,y);
map.addOverlay (new GMarker(point));
}
On 27 May 2011 11:56, Anisha Kaul <born.rebel.83 at gmail.com> wrote:
> I have identified the problem this time. There is a flaw in the way I am
> passing the Javascript code to the evaluatejavascript func. of QWebView.
>
> Using Google maps's API, when I click a pushButton attached to the slot
> holding the below code
>
> this->page()->mainFrame()->evaluateJavaScript (QString ("Open(%1,2)").arg (
> point.x ()).arg (point.y ()) );
>
> the map pertaining to the location in question gets displayed.
>
> Now if I want to add a marker to a particular coordinate, I do:
>
> this->page()->mainFrame()->evaluateJavaScript (QString ("addMarker (%1, %2)").arg (point.x ()).arg (point.y ()) );
>
> This code doesn't execute. Any ideas?
>
> Besides this, what is the way to add a *user defined* function to *
> evaluateJavaScript* for evaluation?
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110527/d457d0c7/attachment.html
More information about the Qt-interest-old
mailing list