Updating Google KMZ Popup Contents & Removing "Directions" in FME - kml

By default a KML balloon will contain links "Directions to Here" and "Directions from Here" (driving directions).
I want to know, how to remove these links from the balloon using FME, as well as use HTML to set KML Balloon content, URL links and images, such as pngs, jpegs, and tiffs.
Also, I will appreciate if there is a workaround other than FME, to do the same, my objective is to remove the data from google kmz which I don’t need and only want to show that data which is required.

What you will want to end up with in the KML file is a BalloonStyle for your balloon content, which looks like: <BalloonStyle><text>...</text></BalloonStyle>, either shared at the top of the KML file, or inline in each placemark/feature. Your BalloonStyle can contain with either static HTML/Text content for the balloon, or an HTML template that can be filled in with basic data (name, description, etc.) or ExtendedData fields from each feature. When you specify balloon content using BalloonStyle, it will leave leave out the directions info. It will also not include the name at the top of the balloon by defautl, so you may want to include that in your content or template.
For more on KML BalloonStyles, see:
https://developers.google.com/kml/documentation/kmlreference#balloonstyle
and:
https://developers.google.com/kml/documentation/extendeddata
I don't know much about FME, but looks like it's possible to do this using AttributeCreator. For more see these instuctions:
https://community.safe.com/s/article/kml-balloon-contents-removing-directions

Related

Should the <description> and <ExtendedData> nodes be exclusive?

I am Loading a KML file with a Placemark into Google Earth, when I include both the description and ExtendedData nodes, only the description is displayed in the balloon.
If I remove the description, and change nothing else, then the ExtendedData is displayed. I have found nothing in the KML Reference or the KML Schema to indicate this is the expected behavior. Presumably, at least as far as Google Earth is concerned, I'll have to resort to specifying a <BalloonStyle> in order to pull the ExtendedData into the description.
Can anyone confirm or dispute that this is the intended behavior?
If a KML feature has no description but has ExtendedData then Google Earth will auto-format the ExtendedData contents in a print-friendly HTML table. If a feature has a description then it will be used regardless whether or not ExtendedData is present.
Some details about this behavior can be found in the KML Errata.
If you want to custom format the ExtendedData elements then you must specify a BalloonStyle and apply that to each Placemark with styleUrl. More details can be found in a related help article: Adding Custom Data.

Loading photos in KML/KMZ files

I am going to develop a mechanism to export as many as approx. 100 photos with their position information to a KML/KMZ file.
Just wondering what is the best practise to do this. My initial quick options are:
1. use html img tag in the description of a placemark to internally reference the actual photos wrapped in the internal "files" folder in the KMZ;
2. use html img tag in the description of a placemark to reference the URL of a photo (publicly accessible).
Option one involves writing all photos in the internal "files" folder of a KMZ. This would make it a massive file. Meanwhile, all photos would have to be loaded in memory during the loading of the KMZ file.
My question is with the option 2, if a particular photo would not be loaded until the user clicks on the placemark to open the popup balloon OR all the photos are loaded like the option 1?
Thanks!
Cheers,
Alex
You can think of Google Earth as a specialized web browser and the HTML within a given placemark as being handled same way HTML in a web browser is handled. In option 2 the images are not downloaded until user clicks the placemark and the description balloon is selected and starts to render.
Option 1 you have a huge KMZ file as you describe that must be downloaded entirely to the client and unpacked locally. The file may be too large to download in a mobile device if you want Google Earth mobile users to view it. The Google Earth essentially unpack the KMZ then access images as in the case of option 2 when the placemark with that image is selected. Only difference is that the entire collection must be downloaded in one shot so the initial startup time is slower and depends on network speed.

Dynamically updating KML file based on certain conditions

I have developed the following network link for dynamic updates :
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<NetworkLink>
<name>Loads TEST.kml</name>
<Link>
<href>/home/desktop/farhan/test.kml</href>
</Link>
</NetworkLink>
</kml>
Test.kml file has two placemarks.
My network link file is getting successfully updated on changes in Test.kml file
Now what I want to do is to place an 'IF' condition so that if a certain thing is true then placemark color is 'Green' Else 'Red'.
What should I do here ?? Is there any Java API I need to follow.
Depends how/where you want to host the KML and what those conditions are.
If the styles and conditions are static then you can generate the KML pre-set with those styles as part of the KML. For example, if you want to generate the KML based on some conditions such as population size > 100K => red, size > 50K => blue, otherwise white where each generated Placemark would have the appropriate shared share or inline style.
One popular Java-API to generate KML is the Java API for KML (or JAK for short).
If the views (based on conditions) are "dynamic" and user-selected then you have a couple of options:
Generate different versions/views of the Placemarks based on different conditions with NetworkLinks and radioFolders to load a particular view. The KML could be statically generated once or dynamically via a web-service, servlet, CGI-script, etc.
For example, the USGS has an earthquake real-time feed with multiple NetworkLinks each with a different view/color/size scheme for the same data (e.g. color by age vs magnitude).
Check out http://earthquake.usgs.gov/earthquakes/feed/earthquakes.kml
Use the Google Earth API to load, create, and modify KML in context of HTML and JavaScript with Google Earth running as a plugin in your web browser. This requires some JavaScript programming.
Use NetworkLinks as shown in your example combined with NetworkLinkControl elements to globally change the shared styles. See NetworkLinkControl tutorial. You can't add NetworkLinkControl elements to your KML directly in Google Earth so you have to author your KML manually or programmatically.
use php , if you are aware of it and generate kml with the help of your table and also you can use various plugins and JAK as told by jason above.
What you can do is :
connect your mysql db ( having latnlong ) through jdbc.
2 .Run a loop i.e while loop which will add placemarks as per the latitude and longitude and add other necessary element of kml like :
Element ristyle = doc.createElement("IconStyle"); // this will create an Icon.
make a new file through :
Result dest = new StreamResult(new File("file location"));
this will create your new kml file
-- place a condition here which will show your condition like a normal loop.
5 Make a network link and refer your kml file in this for manual updation.
I think this should work

How does browser detect embedded web content from a HTML page?

Once a browser gets the main html page, how does it know which are the embedded content should be request again from web server, and which are only external links? Is it based on type of tags, e.g ?
If so, could someone give me a reference of what these tags are?
Thanks.
The HTML5 spec defines the element category "Embedded content":
Embedded content is content that imports another resource into the document, or content from another vocabulary that is inserted into the document.
It lists the following elements:
audio
canvas
embed
iframe
img
math
object
svg
video
Elements like link or script (both in Metadata category) can also refer to other ressources that user-agents (browsers, screen-readers, …) are free to link to or include or do whatever they want to do with it. For example, browsers like Firefox or Chromium will (by default) load and "apply" CSS that is linked within the link element, that has the rel value = stylesheet. Browsers like Lynx or w3m won't do that. They simply ignore that link.
For link, HTML5 states which link types "are links to resources that are to be used to augment the current document, generally automatically processed by the user agent":
Two categories of links can be created using the link element: Links to external resources and hyperlinks. The link types section defines whether a particular link type is an external resource or a hyperlink.
Maybe also consider the style attribute (for inline CSS), which could include a background-image url.
Yes, the tags help browser identify the resources to load. After downloading/retrieving the content the browser determines what to do with the content based on the content-type header in the response.

How to modify Sharepoint filetype icons depending on parts of the filename?

We have a SharePoint Document library, where we store html files with links to external files. Samples:
mypicture.jpg.html
mywordfile.docx.html
mypdffile.pdf.html
and so on. Now by default all Files show up with the HTML Icon, referenced in the DOCICON.XML file. Thats of course correct as the .html extension shows, it is a HTML file. But we want the files to have different icons, based on their original file type.
Is there a way to automatically change the Icon
during rendering or
when we save the file to the library (via SharePoint API)?
Any other approachs?
Why not use a little jquery to change the icon during rendering? Each doc in your library should be contained in
<td class="ms-vb-icon"><a tabindex=...><img ... src="/_layouts/images/ichtm.gif"></a></td>
I think you can slurp that into an array, assign a new var that's just the href stripped of path/filename. and .html, and use that to replace htm in the src tag.
Could you not just edit the DOCICON.xml to add the ".jpg.html" and ".docx.html" extensions in?
For a full listing of icon files see all "ic*.gif" files in the TEMPLATE\IMAGES directory under the 12 hive. Unfortunately, this will not solve your problem, but this is where you can change it based on the extension, if you so choose.
Note that a blog I wrote a while back has a different focus, but does discuss where the icons come from: http://wiki.threewill.com/display/is/2007/10/14/External+Link+for+Editing+a+SharePoint+Document.

Resources