Using a KML file to display thumbnail & full size pictures in My Maps - kml

I'm afraid my original post was not very clear, so I've rewritten my question.
My basic question is how to modify a KML file to best display (in Google My Maps) two or more photos taken at a particular location. No matter what I do to the KML file (see below), when I click on a marker I always end up with only the first picture being displayed TWICE as shown in this example:
Result of clicking on a place marker with 2 pictures
Below is a snippet of my KML code. Please note that <img src... points to the full-sized version of the picture.
# Marker(s) [1, 2]
<Placemark>
<name>Markers 1,2</name>
<styleUrl>#Pic2</styleUrl>
<description>
<![CDATA[
<table>
<tr>
<td>[1] This Monarch butterfly found Bob H. at the beginning of the hike and stayed around quite awhile!</td>
<img src="https://drive.google.com/uc?export=open&id=16a_438A1OCihb1SnYUPm0t9O3WDEdt6u">
</tr>
<tr>
<td>[2] Denny L. along with Sarah (and "Cooper") also seem ready to start.</td>
<img src="https://drive.google.com/uc?export=open&id=1KMGYeJDgqBDJwgkwYju6vlA8--XehACQ">
</tr>
</table>
]]>
</description>
<Point>
<coordinates>-82.7915648,35.2841368</coordinates>
</Point>
</Placemark>
If I click on EITHER of the pictures in the example I get the full-sized version of that picture. Then, using the ">" and "<" that are displayed next to that full-sized picture I can move to the other pictures taken at that location. This isn't TERRIBLE, but I'd really like to initially see thumbnails of all the pictures taken at a particular location. Clicking on a thumbnail should then bring up the full-sized version. (Also, I don't really want 2 copies of the first picture!)
No matter what I do - including adding an line pointing to the thumbnail - I get exactly the same result when clicking on a marker.
I'm not sure if it is possible to do what I'd like, but any suggestions/thoughts would be greatly appreciated!
Wayne

Related

How to represent a table using excel data when clicked on a location in Google Earth Pro?

I am building a map on Google Earth Pro to visualize political workers' data in a specific area. I have designed the basic elements in kml but the data used is hard coded in the kml file itself. I want to automate the process so that anyone can change the data in the master excel sheet and it gets reflected on Google Earth because the booth workers keep changing in every area for every election.
How can I fetch data from an excel sheet and represent it in a tabular format on Google Earth?
Sharing a snippet from the kml file:
`<Placemark>
<name>1,Dehradun</name>
<description><[CDATA[<div><b>PARTY WORKERS</b><br></div>
<table border="1">
<tbody>
<tr><br></tr><tr><td><b>SNO</b><br></td><td><b>NAME</b><br></td><td><b>CONTACT</b><br></td><td><b>COMMENTS</b><br></td><td><b>WORK ASSIGNED</b><br></td></tr>
<tr><td>1<br></td><td>Member1<br></td><td>9917973599<br></td><td>GOOD WORKER<br></td><td>BOOTH MGMT<br></td></tr>
<tr><td>2<br></td><td>Member2<br></td><td>8958644329<br></td><td>LAZY<br></td><td>MAKE PHONE CALLS<br></td></tr>
<tr><td>3<br></td><td>Member3<br></td><td>7894512547<br></td><td>SMART<br></td><td>DATA MGMT<br></td></tr>
</tbody>
</table>
<div><br></div><div><br></div><div><b>INFLUENCERS</b><br></div>
<table border="1">
<tbody>
<tr><br></tr><tr><td><b>SNO</b><br></td><td><b>NAME</b><br></td><td><b>CONTACT</b><br></td><td><b>COMMENTS</b><br></td><td><b>WORK ASSIGNED</b><br></td></tr>
<tr><td>1<br></td><td>Influencer1<br></td><td>9917973599<br></td><td>HIGH INFLUENCE<br></td><td>BOOTH MGMT<br></td></tr>
<tr><td>2<br></td><td>Influencer2<br></td><td>8958644329<br></td><td>ENTIRE BOOTH<br></td><td>NO WORK ASSIGNED<br></td></tr>
<tr><td>3<br></td><td>Influencer3<br></td><td>7894512547<br></td><td>SMART MAN<br></td><td>DATA MGMT<br></td></tr>
</tbody>
</table></description>
<styleUrl>#__managed_style_053287BE6F14D9C2C7B8</styleUrl>
<Point>
<coordinates>78.032188,30.316496,0</coordinates>
</Point>
</Placemark>`
Tried Spreadsheet Mapper V3.2 earlier but it doesn't seem to work now. Found out online that it has been discontinued.
I want this kind of output but it should come from an excel sheet instead of being hard coded:
enter image description here
In order to update a KML file from a spreadsheet, you'll need a server of some kind that can re-generate the KML when the spreadsheet is updated (like Spreadsheet Mapper used to do using Apps Scripts). This is not something that is "built in" to Google Earth, so there's not a simple solution.
That said, Google My Maps recently launched a feature where you can update a layer in your MyMap based on changing data in a spreadsheet. For info see this medium post:
https://medium.com/google-earth/new-my-maps-features-make-it-easier-to-share-maps-update-datasets-and-more-965ed0b48875
and this documentation page:
https://support.google.com/mymaps/answer/3024836
I'm not if it will be easy or even possible to update the data behind your custom balloon layout, but it's probably worth a shot. If you get it to work, then you can either have your users view the data directly in My Maps, or you can try getting the NetworkLink KML for the MyMap, and viewing that in Earth.

Creating small image file png's showing tabular data from Excel or other spreadsheet

On: Creating small image file png's showing tabular data
We sometimes need to show data online. There are a couple of popular ways of doing this:
HTML table
JSON/Xml or other and using some method to display
Creating an image
In this case we need to (or prefer to) create PNG images. The method we use now is to create it in Excel and export it to PNG.
The problem is that we have seen is that these images are not really optimized. And don't look nice when zoomed in. Or on different displays.
Question: now what would be the best way of exporting table/tabular data from program X where we can store it (like Excel) to a clean and neat image format lik epNG that is safe for the web?
Advice and ideas appreciated
There is a quick and good solution for your need. It is wkhtmltopdf
It renders any web page or local html file and converts it image or pdf. Result is satisfactory. It has windows, linux, bsd, os x ports.
What is it?
wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the Qt WebKit rendering engine. These run entirely "headless" and do not require a display or display service.
There is also a C library, if you're into that kind of thing.
Usage is as easy as like this:
wkhtmltoimage.exe http://www.google.com output.png
Note: You can set the quality of the image from command line and have very small sized images with additional command line options.
For example this code becomes
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
<body>
<table style="width:100%">
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>
this image (size 5.16 KB with --quality 80)
And this becomes
wkhtmltoimage.exe --quality 80 https://www.google.co.uk/webhp?hl=en output.png
this (size 32.7 KB)

kml document auto refresh in google earth

I have an app that over time writes Placemarks to a kml file, slowly building up a route over time.
When I open the file in Google Earth, I can see the Placemarks already in the file, but any new ones added to the doc aren't shown on the map, until I reopen the document again.
Is there any way of getting the document to auto refresh in Google earth?
I've tried putting a NetworkLink into the document whose href points itself (the file) with a refreshMode of onChange, and that works, but the whole document is reloaded on each change and each point is displayed again, which is messy.
NOTE: I can't change the apps code, to generate single Placemark updates, which I believe is the proper way of using NetworkLinks.
The only way to perform incremental updates in KML is using the NetworkLinkControl element in conjunction with a NetworkLink.
NetworkLinkControl controls the behavior of files fetched by a <NetworkLink> in which you can change, add, or delete elements that you already fetched.
<NetworkLinkControl>
<cookie>cookie=sometext</cookie>
<linkName>link name</linkName>
<Update>
<targetHref>same-targethref-for-networklink</targetHref>
<Create>
<Document targetId="targetdoc">
<Placemark>
<name>Created place1</name>
</Placemark>
<Placemark>
<name>Created place2</name>
</Placemark>
</Document>
</Create>
...
</Update>
</NetworkLinkControl>
The NetworkLinkControl is tricky to get working such as the URLs in the NetworkLink and NetworkLinkControl must match exactly.
You can find a tutorial with an example to get started.
https://developers.google.com/kml/documentation/updates
So I guess you can't. I thought there might be some kind of structure within kml to achieve this, nut it would appear not.

Google Earth KML - Weird GE behavior when using balloon links to fragment URLs when doc loaded via NetworkLink

KML newb here. First post.
Using GE client application, v7.12. Have fairly simple KML doc containing placemarks to several GPS time-based breadcrumb points. Wrote a simple C# app to generate the kml doc. Expect to have several more like files for additional tracked entities. I get this working and decide to fancy up the placemark balloons via HTML. Ultimately decide I'd like to have links in the balloon to move to the previous or next placemark. Find advice on this site and make it happen.
Since my app may update(by rewriting) the doc at times it would be nice to not have to manually reload it. Plus there will ultimately be other docs for other tracked entities, all controlled/updated by my app. OK - NetworkLink to the rescue. Cool feature and gives me the option of dynamically modifying the networklinks file to only include the entity doc files that have changed. Plus big bonus -- turning 'flyToView' off so that when networklinks file is reloaded or refresh fires, I'm not pulled away from whatever I'm currently viewing by the default 'LookAt' that normally seems to happen when a doc is loaded directly (anyone know a way around this?)
Very happy, until I discover that when I click one of my balloon links to move to the next or previous point, GE decides to create a new copy of the entire containing document under Temporary Places and now I have two entire sets of points displayed, one hiding the other. On the surface, my next/prev links appear to be working, but they are actually only working with the newly created doc. To test, I alter the original doc with an entirely different set of locations. Reload the networklinks doc to bring in the new point-laden doc and see the new set of points. But when I use any balloon links on the new, they jump to points on the older doc that GE had created on its own. Delete the GE-created version, click balloon and viola, GE creates a new copy of it and were back where we started. Frustrating.
As placemark IDs, I'm using strings like "TPn", where n increments. In my balloon links, I'm linking to the fragment URLs such as href="#TPn-1" and href="TPn+1", ie TP2 links to TP1 and TP3, etc, and I account for both placemarks on the end so they don't have bad links to non-existent IDs. BTW, I've found when you do activate a link to a non-existent fragment URL, GE also decides to create a copy of the file, even if the file was loaded directly and not via a networklink, so you again have one point set laying on top of the other. However, I'm confident I have no bad links in this case.
Any light that can be shed would be appreciated. Or alternate ways of achieving my goals. I'm a KML newb after all and maybe there's something I'm doing wrong.
I suppose if I have to, I will sacrifice the balloon links. Being able to reload only one networklinks document for a collection of files + timed refresh + turning off flyToView are too desirable to lose now.
Thanks!
EDIT: Additional info - The duplicate document is created only when using balloon links. Clicking a link in the treeview under the placemark does not cause this anomaly. (In the code sample, remove the null Snippet element for each Placemark to see this effect.) Furthermore, it appears that a balloon link to ANY fragment URL causes the anomaly, such as a link back to a containing folder or document.
EDIT: Added 2 code samples. These are pared down to my essential needs, but still demonstrate the problem. Interesting to note the difference in the GE tree view when the data file 'document' element has an 'id' defined vs not, but it has no bearing on the problem. I prefer the look when the id is omitted.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- File is: C:\myTwoDataPoints.kml -->
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document id="myDoc">
<name>Two Points Doc Name Here</name>
<description>Doc Description Here</description>
<visibility>0</visibility>
<Snippet>Contains Two Data Points</Snippet>
<Style id="myStyle">
<BalloonStyle >
<text><![CDATA[Link To: $[description] ]]></text>
</BalloonStyle>
</Style>
<Folder>
<name>Points Folder</name>
<open>1</open>
<Placemark id="TP1">
<name>Miami, FL, USA</name>
<Snippet />
<description><![CDATA[New York]]></description>
<styleUrl>#myStyle</styleUrl>
<Point>
<coordinates>-80.226439,25.788969,0</coordinates>
</Point>
</Placemark>
<Placemark id="TP2">
<name>New York, NY, USA</name>
<Snippet />
<description><![CDATA[Miami]]></description>
<styleUrl>#myStyle</styleUrl>
<Point>
<coordinates>-74.005973,40.714353,0</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
and...
<?xml version="1.0" encoding="UTF-8"?>
<!-- File is: C:\myNetworkLink.kml -->
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>NetworkLink Document Name Here</name>
<visibility>0</visibility>
<open>1</open>
<NetworkLink>
<name>NetworkLink Name Here</name>
<refreshVisibility>1</refreshVisibility>
<flyToView>0</flyToView>
<Link><href>file:///C:/myTwoDataPoints.kml</href></Link>
</NetworkLink>
</Document>
</kml>

How to display a moving boat in Google Earth?

I am new to the KML format and try to figure out how to display a boat (a png), moving from a place to another along a path (a simple line drawn composed of several lines).
I can see how to display a Placemark, even with an icon, and a Path, separately.
What I would like to see when I click on the KML file is :
the boat appearing at the departure point;
the path drawing itself until the arrival;
the boat icon moving at a comfortable speed (bonus point it I can set a ration time / progress, extra bonus if I can click on start, pause or rewind) from departure to arrival along the path.
Is that even possible ? I know it is with Google Map, but you can program it with Javascript, which eases things a lot.
This is an old question, and there is now a better way to move a placemark (or even better a model) along a pre-determined linestring. Look into using this feature:
http://code.google.com/apis/kml/documentation/kmlreference.html#gxtrack
Sample code:
<?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">
<Folder>
<Placemark>
<gx:Track>
<when>2010-05-28T02:02:09Z</when>
<when>2010-05-28T02:02:35Z</when>
<when>2010-05-28T02:02:44Z</when>
<when>2010-05-28T02:02:53Z</when>
<when>2010-05-28T02:02:54Z</when>
<when>2010-05-28T02:02:55Z</when>
<when>2010-05-28T02:02:56Z</when>
<gx:coord>-122.207881 37.371915 156.000000</gx:coord>
<gx:coord>-122.205712 37.373288 152.000000</gx:coord>
<gx:coord>-122.204678 37.373939 147.000000</gx:coord>
<gx:coord>-122.203572 37.374630 142.199997</gx:coord>
<gx:coord>-122.203451 37.374706 141.800003</gx:coord>
<gx:coord>-122.203329 37.374780 141.199997</gx:coord>
<gx:coord>-122.203207 37.374857 140.199997</gx:coord>
</gx:Track>
</Placemark>
</Folder>
</kml>
The only way I've been able to make this work in static KML is to interpolate between the start and stop points and add placemarks for each frame I want to animate. So, from t=0 to t=1, draw a placemark at the start point. From t=1 to t=2, draw a placemark at the next point, etc.
This gives you the temporal player bar in Google Earth and you can rewind or advance the animation. However it is a little annoying because you wind up with every interpolation point in your placemark tree. Putting the placemarks in their own folder keeps them out of the way, but there's no way to hide them from the user.
Take a look at http://code.google.com/apis/kml/documentation/time.html#animating
The whale shark example does more or less what you want for the placemark. (The URL for the marker icon is broken). Animating the progress along the track can be done using the same trick.
If you want to try something much more difficult, you can try serving dynamic KML. Have Google Earth load a network link to your initial data. Then load another network link with an that sends an update for your placemark at every time tick.
http://code.google.com/apis/kml/documentation/kmlreference.html#link
http://code.google.com/apis/kml/documentation/updates.html
This approach has some serious disadvantages because it requires an external program to drive Google Earth and it does not give the user access to the built-in Google Earth temporal player bar. It also requires that all the data be loaded over a network link -- KML data from a file cannot be updated. That means your driver program needs to act as a http server. Also, in this model it is very hard to know exactly when Google Earth has finished loading and drawing the update. Really I don't recommend doing this; you can make it work using the Google Earth COM API, but it will always be a fragile solution.
There's a browser plug-in that lets you embed Google Earth into a browser page. From there you can use JavaScript to animate your placemark, change your paths, etc. Check out the Google Earth API Developer's Guide.
If you are going to display a boat on Google Earth, a 3D model would be a better approach then an image, since the users can change the viewing angle.
You might want to look into tours: http://code.google.com/apis/kml/documentation/touring.html
I've seen something like this done using a combination of (a number of) <gx:AnimatedUpdate> tags to move a previously created placemark representing your boat and <gx:FlyTo> tags to move the view (I think) all within a <gx:Playlist>.
Hope this helps.
I'm presuming this functionality did not exist when originally answered, but you can achieve the effect using a tour. The following shows a placemark moving in this fashion.
<?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>
<Placemark id="boat">
<Point>
<coordinates>0,0</coordinates>
</Point>
</Placemark>
<gx:Tour>
<name>Play me!</name>
<gx:Playlist>
<gx:FlyTo>
<gx:duration>5.0</gx:duration>
<LookAt>
<longitude>0</longitude>
<latitude>0</latitude>
<altitude>0</altitude>
<heading>-95</heading>
<tilt>65</tilt>
<range>250000</range>
<altitudeMode>relativeToGround</altitudeMode>
</LookAt>
</gx:FlyTo>
<gx:AnimatedUpdate>
<gx:duration>5.0</gx:duration>
<Update>
<targetHref/>
<Change>
<Placemark targetId="boat">
<Point>
<coordinates>1,1</coordinates>
</Point>
</Placemark>
</Change>
</Update>
</gx:AnimatedUpdate>
<gx:Wait>
<gx:duration>6.0</gx:duration>
</gx:Wait>
</gx:Playlist>
</gx:Tour>
</Document>
</kml>
The path could be marked with points whose visibility is altered by the tour at the appropriate time.
I have following sample in Google site. Hope this help.
(details inside : https://sites.google.com/site/canadadennischen888/home/kml/auto-refresh-3d-tracking)
prepare a RestFul service to generate KML file from DB
(sample as in https://sites.google.com/site/canadadennischen888/home/kml/3d-tracking)
My other code will generate a KMZ file which has a link to my Restful service
(sample as in this page)
KMZ file has onInterval
Web page allow user to download KMZ file which has URL that link to my Restful service
When Google Earth open KMZ file, Google Earth will auto refresh to get new data from that Restful service
Just google for "kml time animation"
KML: Time and Animation
KML: Animation
Animation and Dynamic Updates with KML

Resources