have looked everywhere and got no assistance. is it possible to embed Google earth into a qt application? I am very new to qt and visual C++ in general. I got a sample that connected to Google maps. It works fine except I am unable to pan the map. can you please assist me. I know solutions are never given without my showing that I have tried and failed. I do not even know where to start. the code I have is below:
I basically want to to get on my desktop application what you get when you visit https://maps.google.com/
#include <QWebFrame>
#include <QWebPage>
#include "GoogleMaps.h"
#define MAP_HTML \
"<html>"\
" <head>"\
" <script type=\"text/javascript\""\
" src=\"https://maps.google.com/maps/api/js?v=3.1&sensor=true\">"\
" </script>"\
" "\
" <script type=\"text/javascript\">"\
" var map; function init(lat, lng) {"\
" var latLng = new google.maps.LatLng(lat, lng);"\
" var myOptions = {"\
" zoom: 18,"\
" center: latLng,"\
" mapTypeId: google.maps.MapTypeId.ROADMAP,"\
" };"\
" map = new google.maps.Map(document.getElementById(\"map_canvas\"),"\
" myOptions);"\
" var marker = new google.maps.Marker({"\
" map: map,"\
" position: myLatLng"\
" });"\
" }"\
" </script>"\
" "\
" </head>"\
""\
""\
"<body style=\"margin:0px; padding:0px;\" onload=\"init(-29.31418630,27.48326330);\">"\
""\
" <div id=\"map_canvas\" style=\"width:100%; height:100%\">"\
" </div>"\
""\
"</body>"\
""\
"</html>"\
class CWebPage : public QWebPage
{
virtual QString userAgentForUrl
(const QUrl
& url
) const {
Q_UNUSED(url);
//fix for dragging and zooming Google Maps.
//It disables touch events so drag and zoom actions are handled by
//Google Maps in a proper way.
return "Chrome/1.0";
}
};
GoogleMapsViewer
::GoogleMapsViewer(QWidget* parent
) : QWebView(parent)
{
CWebPage* page = new CWebPage();
page->mainFrame()->setHtml(content);
setPage(page);
}
#include <QWebFrame>
#include <QWebPage>
#include "GoogleMaps.h"
#define MAP_HTML \
"<html>"\
" <head>"\
" <script type=\"text/javascript\""\
" src=\"https://maps.google.com/maps/api/js?v=3.1&sensor=true\">"\
" </script>"\
" "\
" <script type=\"text/javascript\">"\
" var map; function init(lat, lng) {"\
" var latLng = new google.maps.LatLng(lat, lng);"\
" var myOptions = {"\
" zoom: 18,"\
" center: latLng,"\
" mapTypeId: google.maps.MapTypeId.ROADMAP,"\
" };"\
" map = new google.maps.Map(document.getElementById(\"map_canvas\"),"\
" myOptions);"\
" var marker = new google.maps.Marker({"\
" map: map,"\
" position: myLatLng"\
" });"\
" }"\
" </script>"\
" "\
" </head>"\
""\
""\
"<body style=\"margin:0px; padding:0px;\" onload=\"init(-29.31418630,27.48326330);\">"\
""\
" <div id=\"map_canvas\" style=\"width:100%; height:100%\">"\
" </div>"\
""\
"</body>"\
""\
"</html>"\
class CWebPage : public QWebPage
{
virtual QString userAgentForUrl(const QUrl& url) const
{
Q_UNUSED(url);
//fix for dragging and zooming Google Maps.
//It disables touch events so drag and zoom actions are handled by
//Google Maps in a proper way.
return "Chrome/1.0";
}
};
GoogleMapsViewer::GoogleMapsViewer(QWidget* parent)
: QWebView(parent)
{
QString content = MAP_HTML;
CWebPage* page = new CWebPage();
page->mainFrame()->setHtml(content);
setPage(page);
}
To copy to clipboard, switch view to plain text mode
P.S
I am using QT 4 on ubuntu 12.04
Bookmarks