KML using html-code for characters - kml

I now that you can use & lt; etc... in KML. But I use also & iacute; = í, & eacute; = é or & uuml; = ü etc...(without the space behind &) But Google Earth do not accept that in a tag
<name>Potos& iacute;</name> is not accept by Google Earth.
I need that CHAR-codes for text on my site and the same text is used in the KML export.

If want HTML entities to correctly decode in Google Earth then wrap the text with entities with CDATA block which is then treated as HTML vs plain text.
This will add an special entity to the placemark name.
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name><![CDATA[abcí]]></name>
...
</Placemark>
</kml>
Also, if the HTML entity does not decode then simply replace that with the
equivalent numerical code; e.g. í = í = í. Check KML Errata for a short discussion of HTML entity encoding in KML.

The problem is resolved. I have the code í replaced by í

Related

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

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

Xpath select node text but exclude child node text

I have the following XML:
<topic class="Top">
<title>
Interesting Article
</title>
<subtitle>
Science & Industry
<insertedText action="start"/>
Inside & Out
<insertedText action="end"/>
A Profile
</subtitle>
</topic>
And I would like to use xpath to extract the text of the subtitle, except for the string between the two <insertedText> nodes, giving the text "Science & Industry A Profile".
Here is my latest attempt but to be honest I'm stumped and realise that this does not exclude the text between the two tags! Any help would be appreciated:
/topic[#class='Top']/*[local-name()='subtitle'][not(descendant::insertedText)]/text()
The number of <insertedText> tags is also variable, so there may be none or multiple sets on <insertedText> tags which should be ignored.
A further example of the type XML that might be encountered is below:
<topic class="Top">
<title>
Interesting Article
</title>
<subtitle>
Science & Industry
<insertedText action="start"/>
Inside & Out
<insertedText action="end"/>
A Profile
<insertedText action="start"/>
An Insiders View
<insertedText action="end"/>
The Full Story
</subtitle>
</topic>
Answer
The full answer, based on that provided by #lambo477, is as follows:
./topic[#class='top']/*[local-name()='subtitle']/text()[1]|/topic[#class='top']/*[local-name()='subtitle']/*[local-name()='insertedText'][#action='end']/following-sibling::node()[1]
You could try the following XPath:
//subtitle/text()[1]|//insertedText[#action="end"]/following-sibling::node()[1]

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>

KML file without coordinates

Is it possible to create a KML file without coordinates in it? I have a list of addresses and I don't have the long/lat. I'd like to create a KML file and have Google Earth geocode and determine the long/lat for each placemark. Thanks in advance.
The geometry (e.g. Point, Polygon, etc.) in a KML Placemark is not required.
You can just have an address in your KML placemarks and Google Earth will automatically geodecode it for you if it can. Under the covers Google Earth will perform a lookup on that address and use the first match if any results are returned. Basically, the resolved address will be the same as if you entered an address via search panel in Google Earth or Google Maps.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name>Google place</name>
<address>1600 Amphitheatre Parkway, Mountain View, CA</address>
</Placemark>
</kml>
After that if you save your KML then Google Earth will have inserted the coordinates for you into each Placemark.
<Point>
<coordinates>-122.083954,37.421998,0</coordinates>
</Point>
You can create KML file without coordinates when you have an address in your file. You can input the data from MS Excel for instance, if you are interested a batch operation. See the solution below:
http://www.mkrgeo-blog.com/input-a-multiple-address-list-in-google-maps-and-google-earth-the-quickest-way/
Then Google Earth will geocode your placemarks automatically when save it as a .kml file again.
It only works when you have no additional data in your excel column. If so, then you must import the Excel spreadsheet to the Google Earth directly, as per the explanation below:
https://gis.stackexchange.com/questions/298570/exporting-layer-from-google-my-maps-as-kml-has-no-geometries/332642#332642

How does a KML file help in loading maps in the Google Earth?

https://developers.google.com/kml/documentation/kml_tut
KML uses a tag-based structure with nested elements and attributes and is based on the XML standard.
So, KML is basically a "text" file, it doesn't contain the maps.
How does Google Earth use KML files to show maps? Does it treat KML file as an "index" to know which of its maps to pick when user presses x button?
KML is an XML language used to annotate the Earth with points, lines, polygons, 3d models, and overlays.
As an analogy, HTML is a language to structure and represent textual information and multi-media in a 2-D document context within a web browser. Likewise, KML is a language to structure and represent geospatial and temporal entities on a map and show in "earth browsers" such as Google Earth.
Specifically KML allows you to :
Specify icons and labels to identify locations on the surface of the planet
Create different camera positions to define unique views for geographic features
Define image overlays to attach to ground or screen
Define styles to specify KML feature appearance
Organize KML features into hierarchies
Locate and update retrieved KML documents from local or remote network locations
KML is a structured format of data that tells Google Earth how to display the data (point, line, icons, colors, styles, etc.) and where to draw it (longitude and latitude optionally at a given altitude). KML is simply a data exchange format.
Here's a simple KML file:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>New York City</name>
<description>New York City</description>
<Point>
<coordinates>-74.006393,40.714172</coordinates>
</Point>
</Placemark>
</Document>
</kml>
As an "index", a KML file by default will load at the center point that covers all includes features in the KML, but that can be overridden if a LookAt or Camera is defined. If you click on a Placemark it will fly to that feature as defined by its coordinates.
Clicking on such a placemark in Google Earth will fly to that location, which for the example above happens to be New York City.
KML is a "text" file that can also be packaged and distributed in a "KMZ" file, which is a ZIP file with .kmz file extension.
More details about KML can be in the OGC KML Standard # 07-147r2 .

Resources