Google Earth API Javascript Tour animation - google-earth

I'm trying to implement Google Earth API tour in javascript. I tried parsekml method, but i couldn't make any tour. I have one question... Does javascript with Google Earth API support tour? I don't want use fetchkml or import from any other link. Here I have enclosed my sample code. Any help...?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Google Earth-Practice</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<style type="text/css">#import "static/examples.css";</style>
<style type="text/css">#import "static/prettify/prettify.css";</style>
<script type="text/javascript" src="static/prettify/prettify.js"></script>
<script type="text/javascript" src="http://www.google.com/jsapi?hl=en&key=ABQIAAAAwbkbZLyhsmTCWXbTcjbgbRSzHs7K5SvaUdm8ua-Xxy_-2dYwMxQMhnagaawTo7L1FE1-amhuQxIlXw"></script>
<script type="text/javascript">
/* <![CDATA[ */
var ge;
var i=1;;
var l=1;
var Excel;
var value;
google.load("earth", "1");
function init() {
google.earth.createInstance('map3d', initCB, failureCB);
}
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
// add a navigation control
ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
// add some layers
// ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
// ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);
document.getElementById('installed-plugin-version').innerHTML =ge.getPluginVersion().toString();
}
function failureCB(errorCode) {
}
function my_function()
{
return Excel.Workbooks.Open("C:/TEST.xls").ActiveSheet.Cells(l,i).Value;
}
//where l is number of rows and i are columns...
function DrawVector()
{
//where l is number of rows and i are columns...
//var i=1;
//var l=1;
var z=1;
var line=[];
document.getElementById('loadingImage').style.visibility='visible';
document.getElementById('Fly').style.visibility='visible'
Excel = new ActiveXObject("Excel.Application");
Excel.Visible = false;
do
{
a=my_function()
if (a!=null)
{
//var t=prompt("hello");
line[z]=a;
z++;
i++;
}
else
{
l++;
i=1;
//document.write("<br />");
}
b = my_function()
}while(a!=null || b!=null);
var lineStringPlacemark = ge.createPlacemark('');
var lineString = ge.createLineString('');
lineStringPlacemark.setGeometry(lineString);
lineString.setExtrude(true);
lineString.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND);
// Add LineString points
for(i=1;i<z;i=i+4)
{
var placemark = ge.createPlacemark('');
var icon = ge.createIcon('');
icon.setHref('https://cdn1.iconfinder.com/data/icons/Map-Markers-Icons-Demo-PNG/256/Map-Marker-Flag--Right-Chartreuse.png');
var style = ge.createStyle(''); //create a new style
style.getIconStyle().setIcon(icon);
style.getIconStyle().setScale(3.0); //apply the icon to the style
//style.getColor().set('ffffffff');
placemark.setStyleSelector(style); //apply the style to the placemark
// Set the placemark's location.
var point = ge.createPoint('');
point.setLatitude(line[i+1]);
point.setLongitude(line[i+2]);
point.setAltitude(line[i+3]);
point.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND);
placemark.setGeometry(point);
placemark.setName(line[i]);
// Add the placemark to Earth.
ge.getFeatures().appendChild(placemark);
lineString.getCoordinates().pushLatLngAlt(line[i+1],line[i+2],line[i+3]);
}// lineString.getCoordinates().pushLatLngAlt(38.885278,-77.701944,1900);
// lineString.getCoordinates().pushLatLngAlt(38.769167,-77.901944,2700);
// Create a style and set width and color of line
lineStringPlacemark.setStyleSelector(ge.createStyle(''));
var lineStyle = lineStringPlacemark.getStyleSelector().getLineStyle();
lineStyle.setWidth(4);
var polyColor = lineStringPlacemark.getStyleSelector().getPolyStyle().getColor();
//polyColor.set('ffffffff');
polyColor.setA(127);
polyColor.setB(0);
polyColor.setG(255);
polyColor.setR(0);
//lineStyle.polystyle.color = '990000ff';
lineStyle.getColor().set('ffffffff'); // aabbggrr format
//polystyle color = 66FFF700;
//lineString.getPolyStyle(polystyle);// Add the feature to Earth
ge.getFeatures().appendChild(lineStringPlacemark);
document.getElementById('loadingImage').style.visibility='hidden';
}
function showSun() {
ge.getSun().setVisibility(true);
ge.getTime().getControl().setVisibility(ge.VISIBILITY_SHOW);
}
function KmlView()
{ DrawVector();
var name='start';
var kmlString = ''
+ '<?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">'
+ ' <Document>'
+'<Camera> <altitudeMode>relativeToGround</altitudeMode>'
+ ' <longitude>-77.451111</longitude>'
+ ' <latitude>38.935278</latitude>'
+ ' <altitude>10000 </altitude>'
+ ' <heading>-105.948935</heading>'
+ ' <tilt>93</tilt>'
+ '<range>50</range>'
+ ' </Camera>'
+ ' <open>1</open> '
+ ' <gx:Tour> '
+ ' <name>Play me</name> '
+ ' <gx:Playlist> '
+ ' <gx:FlyTo> '
+ ' <gx:duration>2.0</gx:duration> '
+ ' <gx:flyToMode>bounce</gx:flyToMode> '
+ ' <LookAt> '
+ ' <longitude>-77.451111</longitude> '
+ ' <latitude> 38.935278</latitude> '
+ ' <altitude>900</altitude> '
+ ' <heading>-123.948935</heading> '
+ ' <tilt>63.0957450</tilt> '
+ ' <range>469.850414</range> '
+ ' <gx:altitudeMode>relativeToGround </gx:altitudeMode> '
+ ' </LookAt> '
+ ' </gx:FlyTo> '
+ ' <gx:AnimatedUpdate> '
+ ' <gx:duration>0.0</gx:duration> '
+ ' <Update> '
+ ' <targetHref/> '
+ ' <Change> '
+ ' <Placemark targetId="Fly1"> '
+ ' <gx:balloonVisibility>1</gx:balloonVisibility> '
+ ' </Placemark> '
+ ' </Change> '
+ ' </Update> '
+ ' </gx:AnimatedUpdate> '
+ ' <gx:AnimatedUpdate> '
+ ' <gx:duration>0.0</gx:duration> '
+ ' <Update> '
+ ' <targetHref/> '
+ ' <Change> '
+ ' <Placemark targetId="Fly1">'
+ ' <gx:balloonVisibility>0</gx:balloonVisibility> '
+ ' </Placemark> '
+ ' </Change> '
+ ' </Update> '
+ ' </gx:AnimatedUpdate> '
+ ' <gx:FlyTo> '
+ ' <gx:duration>20</gx:duration> '
+ ' <gx:flyToMode>smooth</gx:flyToMode> '
+ ' <LookAt> '
+ ' <longitude>-77.701944</longitude> '
+ ' <latitude>38.885278</latitude> '
+ ' <altitude>1900</altitude> '
+ ' <heading>-123.948935</heading> '
+ ' <tilt>63.117317</tilt> '
+ ' <range>792.665540</range> '
+ ' <gx:altitudeMode>relativeToGround</gx:altitudeMode> '
+ ' </LookAt> '
+ ' </gx:FlyTo> '
+ ' <gx:AnimatedUpdate> '
+ ' <gx:duration>0.0</gx:duration> '
+ ' <Update> '
+ ' <targetHref/> '
+ ' <Change> '
+ ' <Placemark targetId="Fly2"> '
+ ' <gx:balloonVisibility>1</gx:balloonVisibility> '
+ ' </Placemark> '
+ ' </Change> '
+ ' </Update> '
+ ' </gx:AnimatedUpdate> '
+ ' <gx:AnimatedUpdate> '
+ ' <gx:duration>0.0</gx:duration> '
+ ' <Update> '
+ ' <targetHref/> '
+ ' <Change> '
+ ' <Placemark targetId="Fly2"> '
+ ' <gx:balloonVisibility>0</gx:balloonVisibility> '
+ ' </Placemark> '
+ ' </Change> '
+ ' </Update> '
+ ' </gx:AnimatedUpdate> '
+ ' <gx:FlyTo> '
+ ' <gx:duration>30</gx:duration>'
+ ' <gx:flyToMode>smooth</gx:flyToMode> '
+ ' <LookAt> '
+ ' <longitude>-77.901944</longitude> '
+ ' <latitude>38.769167</latitude> '
+ ' <altitude>2700</altitude> '
+ ' <heading>-123.948935</heading> '
+ ' <tilt>63.063392</tilt> '
+ ' <range>633.666023</range> '
+ ' <altitudeMode>relativeToGround</altitudeMode> '
+ ' </LookAt> '
+ ' </gx:FlyTo> '
+ ' <gx:AnimatedUpdate> '
+ ' <gx:duration>0.0</gx:duration> '
+ ' <Update> '
+ ' <targetHref/> '
+ ' <Change> '
+ ' <Placemark targetId="onland"> '
+ ' <gx:balloonVisibility>1</gx:balloonVisibility> '
+ ' </Placemark> '
+ ' </Change> '
+ ' </Update> '
+ ' </gx:AnimatedUpdate> '
+ ' </gx:Playlist> '
+ ' </gx:Tour> '
+ ' <Placemark id="Fly1"> '
+ ' <name> </name> '
+ ' <description> '
+ ' KIAD Starting point... </description> '
+ ' <Point> '
+ ' <gx:altitudeMode>relativeToGround</gx:altitudeMode> '
+ ' </Point> '
+ ' </Placemark> '
+ ' <Placemark id="Fly2"> '
+ ' <name></name> '
+ ' <description>We reached LOULU...</description> '
+ ' <Point> '
+ ' <gx:altitudeMode>relativeToGround</gx:altitudeMode> '
+ ' </Point> '
+ ' </Placemark> '
+ ' <Placemark id="onland"> '
+ ' <name></name> '
+ ' <description> '
+ ' <![CDATA[ RNDLI. '
+ ' You<gx:balloonVisibility>1</gx:balloonVisibility> '
+ ' Reached your destination]]> '
+ ' </description> '
+ ' <Point> '
+ ' </Point> '
+ ' </Placemark> '
+ ' <ScreenOverlay>'
+ ' <name>Absolute Positioning: Top left</name>'
+ ' <visibility>1</visibility>'
+ ' <Icon>'
+ ' <href>https://cdn4.iconfinder.com/data/icons/32x32-free-design-icons/32/Target.png</href>'
+ ' </Icon>'
+ ' <overlayXY x="0.5" y=".5" xunits="fraction" yunits="fraction"/>'
+ ' <screenXY x="0.5" y=".5" xunits="fraction" yunits="fraction"/>'
+ ' <rotation>2.37878630116985</rotation>'
+ ' <size x=".1" y=".1" xunits="fraction" yunits="fraction"/>'
+ ' </ScreenOverlay>'
+ ' </Document>'
+ ' </kml>';
var kmlObject = ge.parseKml(kmlString);
ge.getFeatures().appendChild(kmlObject);
ge.getView().setAbstractView(kmlObject.getAbstractView());
//ge.getTourPlayer().setTour(kmlObject);
// ge.getTourPlayer().play();
}
function hideSun() {
ge.getSun().setVisibility(false);
}
/* ]]> */
</script>
</head>
<body onload="if(window.prettyPrint)prettyPrint();init();" bgcolor=#87CEEB>
<h1>Google Earth -Practice</h1>
<dl>
</dl>
<div style="clear: both;"></div>
<div id="ui" style="position: relative;">
<div id="map3d_container" style="border: 1px solid #000; width: 800px; height: 800px;">
<div id="map3d" style="height: 100%;"></div>
</div>
<div id="extra-ui" style="position: absolute; left: 820px; top: 0;">
Starting Point:<input type="text" name="fname">
Destination Point: <input type="text" name="lname"><br><br/><br/>
<center><input type="button" onclick="KmlView()" value="Start"/><br/><br/></center><br/><br/>
<form id="Fly" style="visibility:hidden">
<input type="button" onclick="showSun()" value="Show Sun"/><br/><br/><br/>
<input type="button" onclick="hideSun()" value="Hide Sun"/><br/><br/><br/>
<img id="loadingImage" src="C:\Users\h118093\Downloads\Load2.gif" height="50%" width="50%" style="visibility:hidden" alt="Ready To Fly...."/>
</form>
</div>
</div>
</body>
</html>
How to make tour on Google Earth using javascript without fetchkml?

According to Google's Earth API site, Touring is supported via the javascript API to just play tours already encoded in the KML. Google's Touring API web-page: https://developers.google.com/earth/documentation/touring
Google's documentation on the above web-page link contains examples how to invoke a tour in a KML. The code you supplied above just loads the KML into the Google Earth plugin. Your code does not invoke the tour.
Your next step is to invoke the tour properly via the ge.getTourPlayer().setTour(object) and ge.getTourPlayer().play() methods shown on that page. You should be able to utilize the "Simple Tour" example shown on Google's touring documentation web page.
I tried out your code, and got it to play the tour when coded properly according to the info on Google's touring web page. However, your kmlString has some errors in it too. You don't have closing /Document and /kml tags. And to get the "Simple Tour" to work you actually need to remove the Document tag entirely.
[FYI ... you do know this API is going to be turned off by Google on 12/12/2015? You will need to begin looking for a tour alternative if you plan to utilize it past the end of this year.]
Edited answer to add code changes:
var kmlString = ''
+ '<?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">'
//+ ' <Document>' //<---------delete this line
:
: <clipped>
:
+ ' </gx:Tour>'
+ '</kml>'; //<---------add this line
kmlObject = ge.parseKml(kmlString);
ge.getFeatures().appendChild(kmlObject);
//ge.getView().setAbstractView(kmlObject.getAbstractView()); //<---------delete this line unless you need it for other purposes
ge.getTourPlayer().setTour(kmlObject); //<---------add these two lines
ge.getTourPlayer().play();

Related

how to connect to mysql using jsp

Statement st = con.createStatement();
//ResultSet rs;
int i = st.executeUpdate("insert into members(first_name,last_name,email,uname, pass, regdate) values ('" + fname + "','" + lname + "','" + email +"','" + user + "','" + pwd + "', CURDATE())");
if (i > 0)
{
//session.setAttribute("userid", user);
//response.sendRedirect("userList2.jsp");
out.print("Registration Successfull!"+"<a href='userList2.jsp'>View Members</a>");
}

Add Symbol () in report ssrs

I have code :
CourseName + ' ' + isnull(GradeLevel,'')) as CourseName
The result :
Permit Working High 3
How to make result like this :
Permit Working High (3)
CourseName + ' ' +
CASE
WHEN GradeLevel IS NULL THEN ''
ELSE '(' + GradeLevel + ')'
END
AS CourseName

How to format manipulated DateTime fields in dynamic TSQL

I have a query that looks basically like this, wrapped in a dynamic query to accommodate table names that can change. I got the date functions in the middle converted but it doesn't like the LoadedDateTime and CallPlacedTime at the end. I've tried every conversion and combination of quoting those lines that I can think of. How can I accomplish this?
DECLARE #sql_TotalDialsNewLeads nvarchar(1000) = N'
SELECT COUNT(*)
FROM ' + #tbl_CH + ' ch, ' + #tbl_CL + ' cl, ' + #tbl_DA + ' da
WHERE ch.IDENTITY = cl.IDENTITY
AND cl.CRMID = da.CRMID
AND CallPlacedTime BETWEEN ''' + CONVERT(varchar(30),DATEADD(HOUR,-#TimezoneOffset,#StartDate),126) + '''
AND ''' + CONVERT(varchar(30),DATEADD(HOUR,-#TimezoneOffset,#EndDate),126) + '''
AND Product = ''' + #Product + '''
AND Country = ''' + #Country + '''
AND DATEPART(DayOfYear,DATEADD(HOUR,-#TimezoneOffset,LoadedDateTime))
= DATEPART(DayOfYear,DATEADD(HOUR,-#TimezoneOffset,CallPlacedTime))'
EXECUTE(#sql_TotalDialsNewLeads);
Thanks,
Sean
Try to use sp_executesql with parameters instead of making string to execute manually:
...
AND CallPlacedTime BETWEEN DATEADD(HOUR,-#TimezoneOffset,#StartDate)
AND DATEADD(HOUR,-#TimezoneOffset,#EndDate)
...
and execute it with the following statement:
exec sp_executesql #sql_TotalDialsNewLeads,
N'#StartDate datetime, #EndDate datetime',
#StartDate,#EndDate;
Here is a MSDN guide. Also you can do it for other parameters in your SQL statement.
Instead of using the conversion outside use it inside the dynamic query.
something like this. (Not tested)
DECLARE #sql_TotalDialsNewLeads nvarchar(1000) = N'
SELECT COUNT(*)
FROM ' + #tbl_CH + ' ch, ' + #tbl_CL + ' cl, ' + #tbl_DA + ' da
WHERE ch.IDENTITY = cl.IDENTITY
AND cl.CRMID = da.CRMID
AND CallPlacedTime BETWEEN CONVERT(varchar(30),DATEADD(HOUR,'''+ -#TimezoneOffset +''','''+ #StartDate +'''),126)
AND CONVERT(varchar(30),DATEADD(HOUR,'''+ -#TimezoneOffset +''','''+ #EndDate +'''),126)
AND Product = ''' + #Product + '''
AND Country = ''' + #Country + '''
AND DATEPART(DayOfYear,DATEADD(HOUR,-#TimezoneOffset,LoadedDateTime))
= DATEPART(DayOfYear,DATEADD(HOUR,-#TimezoneOffset,CallPlacedTime))'
EXECUTE(#sql_TotalDialsNewLeads);

Append an integer to a string as a string

Trying to do something like this:
select 'Setup for Car ' + CAST(varchar(50), #CarID) + ' for user ' + CAST(varchar(5), #UserID)
doesn't work, not sure what the syntax would be then for T-SQL. I've hunted around, have not found it yet.
You can user either of these:
select 'Setup for Car ' + Convert(varchar(50), #CarID) + ' for user ' + Convert(varchar(5), #UserID)
OR
select 'Setup for Car ' + CAST(#CarID as varchar(50)) + ' for user ' + CAST(#UserID as varchar(5))
You are using CAST wrong. It should be
CAST(#Variable AS WhatYouAreCastingTo)
Here is a fiddle showing this
Remember, MSDN is your friend :)

Export all not in comparison table

I have been using the following export query (CTE) for a few years but a client has requested that we do not give them all of the data from the 'C' line as they do not need some of the data. I have all of the PlaintiffNames that they do not need but I have no idea how to adjust the query to exclude the PlaintiffNames they do not need. And using NOT IN as is shown below has not worked and I am guessing I am missing something!
SELECT 4 AS grpOrd
, null AS posInGrp
, 'C'
, A.CaseNumberKey
, 'C|' + IsNull(J.CType, '') + '|' + IsNull(J.plaintiffName,'') + '|' + IsNull(J.plaintiffAdd1, '') + '|' + IsNull(J.plaintiffCity, '') + '|' + IsNull(J.plaintiffState, '') + '|' + IsNull(J.plaintiffZip, '') + '|' + '|' + IsNull(J.defendantName, '') + '|' + IsNull(J.defendantAdd1, '') + '|' + IsNull(J.defCity, '') + '|' + IsNull(J.defState, '') + '|' + IsNull(J.defZip, '') + '|' + '|' + IsNull(J.Court, '') + '|' + IsNull(J.CaseID, '') + '|' + IsNull(J.JAmt, '') + '|' + IsNull(replace(convert(VarChar(10), JDate, 101), '/', ''), '') + '|' + IsNull(replace(convert(VARCHAR(10), revivedDate, 101), '/', ''), '') AS Extract
FROM newCityCollection.dbo.PropertyInformation A
JOIN Acme.new_judgment_system.dbo.selected_compiled_clean J
ON J.CaseNumber = A.CaseNumberKey
WHERE A.DateFinished BETWEEN #PeriodStart AND #PeriodEnd
AND ClientKey = 2
AND (J.plaintiffName NOT IN (SELECT Plaintiff FROM dbo.excluded_Plaintiffs))
I am getting invalid object name dbo.excluded_Plaintiffs when I try to run this. Note that is the very bottom of the CTE which has numerous lines but the issue is solely in this last line.
An example of a common plaintiff that they do not want is 'PHILA TRAFFIC COURT'
Is it possible to adjust the above to check the table (excluded_Plaintiffs) and exclude that data? I have tried to no avail and am hoping someone has the answer.
Well I answered my own question. I missed the database in this line dbo.excluded_Plaintiffs. Should be written newCityCollection.dbo.excluded_Plaintiffs.