QWebView and Google Maps JS API v3
-
Oustanding find!! I'm using webkit with a standard webview widget. Using the app args API works for this string, under this scheme (4.7.3):
QApplication app(argc, argv);
// Work around for QT Webkit/Google Maps V3 API to allow map panning via touch control
app.setApplicationName(QString("Chrome"));
app.setApplicationVersion(QString("1.0")); -
[quote author="Yuvalal" date="1305973922"]Had to sign in to say thanks, you're a genius! I was struggling for weeks!
[/quote]I was struggeled also in that problem and have to say a lot of thanks for the C++ code. Now it works :-)
-
I have the same issue (Qt 4.7.2).
Adding “js?v=3.1&sensor=true” doesn't change the situation.
There is still no panning and zooming. I have tried this on my desktop and also on a linux board with touchscreen(the touchscreen works fine with Qt widgets ).Any idea ?
-
[quote author="rigelsg" date="1322153106"]I have the same issue (Qt 4.7.2).
Any idea ?[/quote]
There were 3 or so working solutions given already. Read the thread please. -
I can feel the pain above. I have been trying mouse dragging to work in a Webview with no luck. I have added my own buttons to my app and I can move the location but their operation needs a lot to be desiredc. Where can I get a project that has this working so I can use it as an example?
Ken
-
http://qt-project.org/forums/viewthread/19887
Working solution under windows
I did try to build webkit but even if setting touch to 0 didn't work (got a fews tests to do on that option to confirm) -
For what it's worth, my application using Qt 4.8.3 on Linux "just works" now when I delete the QWebPage::userAgentForUrl override. So my class now just has this:
@
QString ChromePage::userAgentForUrl(const QUrl & url) const
{
// Broken as of October 2012, but now default works?
//return QString("Chrome/1.0");
return QWebPage::userAgentForUrl(url);
}
@I am also specifying Maps API version 3.9 - I haven't played around with the newer versions, but it seems to work for me. I did dig into the 3.9 javascript, and the touch events check is now based on the operating system detected from the user agent rather than the browser type, so if things still aren't working for you, make sure your UA string reports "X11", "Windows" or "Macintosh" and it may fix things.
ETA: this also works with the 3.exp version of Google Maps. If you're interested in seeing the code in context, here are links to the viewer class and the web page on GitHub that I'm using:
https://github.com/asymworks/benthos/blob/master/src/controls/maplocationeditor.hpp
https://github.com/asymworks/benthos/blob/master/src/controls/maplocationeditor.cpp
https://github.com/asymworks/benthos/blob/master/res/mapview/locpick.html