Commit 3e6dcd8b authored by pixhawk's avatar pixhawk

GOOGLE EARTH WORKS ON WINDOWS! FULL SUPPORT NOW!

parent 4008102c
......@@ -110,11 +110,13 @@ function setDraggingAllowed(allowed)
function setNewWaypointPending(pending)
{
newWaypointPending = pending;
document.getElementById('JScript_newWaypointPending').setAttribute('value',pending);
}
function setDragWaypointPending(pending)
{
dragWaypointPending = pending;
document.getElementById('JScript_dragWaypointPending').setAttribute('value',pending);
}
function isInitialized()
......@@ -164,10 +166,15 @@ google.earth.addEventListener(ge.getGlobe(), 'mousemove', function(event)
point.setLongitude(event.getLongitude());
dragInfo.dragged = true;
dragWaypointIndex = dragInfo.placemark.getDescription();
document.getElementById('JScript_dragWaypointIndex').setAttribute('value',dragWaypointIndex);
dragWaypointLatitude = event.getLatitude();
dragWaypointLongitude = event.getLongitude();
dragWaypointAltitude = point.getAltitude();
dragWaypointPending = true;
document.getElementById('JScript_dragWaypointLatitude').setAttribute('value',dragWaypointLatitude);
document.getElementById('JScript_dragWaypointLongitude').setAttribute('value',dragWaypointLongitude);
document.getElementById('JScript_dragWaypointAltitude').setAttribute('value',dragWaypointAltitude);
document.getElementById('JScript_dragWaypointPending').setAttribute('value',true);
}
}
});
......@@ -184,11 +191,16 @@ google.earth.addEventListener(ge.getWindow(), 'mouseup', function(event)
event.preventDefault();
// Get drag end location
dragWaypointIndex = dragInfo.placemark.getDescription();
document.getElementById('JScript_dragWaypointIndex').setAttribute('value',dragWaypointIndex);
var point = dragInfo.placemark.getGeometry();
dragWaypointLatitude = event.getLatitude();
dragWaypointLongitude = event.getLongitude();
dragWaypointAltitude = point.getAltitude();
dragWaypointPending = true;
document.getElementById('JScript_dragWaypointLatitude').setAttribute('value',dragWaypointLatitude);
document.getElementById('JScript_dragWaypointLongitude').setAttribute('value',dragWaypointLongitude);
document.getElementById('JScript_dragWaypointAltitude').setAttribute('value',dragWaypointAltitude);
document.getElementById('JScript_dragWaypointPending').setAttribute('value',true);
}
dragInfo = null;
......@@ -206,6 +218,10 @@ google.earth.addEventListener(ge.getGlobe(), 'dblclick', function(event){
newWaypointLongitude = event.getLongitude();
newWaypointAltitude = ge.getGlobe().getGroundAltitude(newWaypointLatitude, newWaypointLongitude);
newWaypointPending = true;
document.getElementById('JScript_newWaypointLatitude').setAttribute('value',newWaypointLatitude);
document.getElementById('JScript_newWaypointLongitude').setAttribute('value',newWaypointLongitude);
document.getElementById('JScript_newWaypointAltitude').setAttribute('value',newWaypointAltitude);
document.getElementById('JScript_newWaypointPending').setAttribute('value',true);
}
});
}
......@@ -447,7 +463,7 @@ function initCallback(object)
ge.getLayerRoot().enableLayerById(ge.LAYER_TREES, true);
enableEventListener();
document.getElementById('JScript_initialized').setAttribute('value','true')
document.getElementById('JScript_initialized').setAttribute('value','true');
initialized = true;
}
......@@ -602,7 +618,15 @@ function failureCallback(object)
<center>
<div id='map3d' style='margin: 0; spacing: 0; height: 100%; width: 100%'></div>
</center>
<input type="hidden" id="JScript_initialized" value="false"/>
<input type="hidden" id="JScript_dragWaypointIndex" value="581" />
<input type="hidden" id="JScript_initialized" value="false" />
<input type="hidden" id="JScript_dragWaypointIndex" value="0" />
<input type="hidden" id="JScript_dragWaypointLatitude" value="0" />
<input type="hidden" id="JScript_dragWaypointLongitude" value="0" />
<input type="hidden" id="JScript_dragWaypointAltitude" value="0" />
<input type="hidden" id="JScript_dragWaypointPending" value="false" />
<input type="hidden" id="JScript_newWaypointLatitude" value="0" />
<input type="hidden" id="JScript_newWaypointLongitude" value="0" />
<input type="hidden" id="JScript_newWaypointAltitude" value="0" />
<input type="hidden" id="JScript_newWaypointPending" value="false" />
</body>
</html>
......@@ -388,7 +388,7 @@ void QGCGoogleEarthView::showEvent(QShowEvent* event)
// Reloading the webpage, this resets Google Earth
gEarthInitialized = false;
QTimer::singleShot(10000, this, SLOT(initializeGoogleEarth()));
QTimer::singleShot(3000, this, SLOT(initializeGoogleEarth()));
}
else
{
......@@ -404,7 +404,7 @@ void QGCGoogleEarthView::printWinException(int no, QString str1, QString str2, Q
QVariant QGCGoogleEarthView::javaScript(QString javaScript)
{
#ifdef Q_OS_MAC
if (!gEarthInitialized)
if (!jEarthInitialized)
{
return QVariant(false);
}
......@@ -461,22 +461,33 @@ QVariant QGCGoogleEarthView::documentElement(QString name)
documentWin->queryInterface( IID_IHTMLDocument3, (void**)&doc);
params.append(name);
IHTMLElement* element = NULL;
HRESULT res = doc->getElementById(L"JScript_dragWaypointIndex", &element);
// Append alias
name.prepend("JScript_");
HRESULT res = doc->getElementById(QStringToBSTR(name), &element);
//BSTR elemString;
if (element)
{
//element->get_innerHTML(&elemString);
VARIANT value;
element->getAttribute(L"value", 0, &value);
QVariant qtValue;
bool success = QVariantToVARIANT(qtValue, value);
qDebug() << "Convert MS VARIANT to QVariant:" << success;
if (success)
VARIANT var;
var.vt = VT_BSTR;
HRESULT res = element->getAttribute(L"value", 0, &var);
if (SUCCEEDED(res) && (var.vt != VT_NULL))
{
//VariantChangeType(&var, &var, 0, VT_BSTR);
//qDebug() << "GOT ATTRIBUTE";
//_bstr_t bstrHello(var.bstrVal); // passing true means
// you should not call
// SysFreeString
//qDebug() << "BSTR:" << LPCSTR(bstrHello);
}
else
{
qDebug() << "initialized is:"<< qtValue.toInt();
return qtValue;
qDebug() << "JAVASCRIPT ATTRIBUTE" << name << "NOT FOUND";
}
QByteArray typeName;
QVariant qtValue = VARIANTToQVariant(var,typeName);
return qtValue;
//element->toString(&elemString);
......@@ -543,15 +554,15 @@ void QGCGoogleEarthView::initializeGoogleEarth()
qDebug() << "COULD NOT GET DOCUMENT OBJECT! Aborting";
}
#endif
QTimer::singleShot(2500, this, SLOT(initializeGoogleEarth()));
QTimer::singleShot(1500, this, SLOT(initializeGoogleEarth()));
return;
}
if (!gEarthInitialized)
{
if (0 == 1)//(!javaScript("isInitialized();").toBool())
if (!documentElement("initialized").toBool())
{
QTimer::singleShot(500, this, SLOT(initializeGoogleEarth()));
QTimer::singleShot(300, this, SLOT(initializeGoogleEarth()));
qDebug() << "NOT INITIALIZED, WAITING";
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment