简体   繁体   中英

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

1. Read in GML File

Open FME Workbench and start a blank workspace.

Add an OGC GML reader and select the gml dataset.

2. Reproject to LL84

Next, add a CsmapReprojector transformer to the canvas and connect it to the FireHalls reader feature type. In the parameters, set the Destination Coordinate System to LL84. The coordinate system needs to be changed because KML only supports a latitude/longitude coordinate system.

3. Remove “Directions” from KML Balloons

To remove the direction links from the balloons, a KML attribute needs to be created. To do that, add an AttributeCreator to the canvas and connect it to the CsmapReprojector. In the parameters, create a New Attribute called kml_balloonstyle_text.

For the Attribute Value, set the value to $[description], which tells Google Earth to only use the description for the feature balloon rather than the default which contains the links for "Directions to Here" and "Directions from Here".

4. Write to OGC/Google KML

To test that the directions were removed successfully, we need to write out to Google KML and then view the KML file in Google Earth. Add an OGC/Google KML Writer to the canvas, and then name the Dataset FireHallsOutput.kml, ensure this file is saved in the same folder as the jpeg images.

5. Run the translation

Connect the FireHalls writer feature type to the AttributeCreator. Run the translation and then open up the folder containing the new FireHalls.kml file. Open the file in Google Earth to view the results.

6. Set Description Balloon HTML Content

Now that we know that the directions have been removed, we can make the description balloon a bit more useful by adding images.

Add a KMLPropertySetter to the canvas and connect it between the AttributeCreator and the FireHalls writer feature type. The KMLPropertySetter will set the HTML content for the balloon by specifying a link to the Firehall location in Google Maps as well as a photo of the Firehall if it is available. In the KMLPropertySetter parameters set the Name to the attribute Name, and the Summary to the attribute Address, this information is already contained within the FireHalls.gml dataset.

Next set the Content Type to HTML and then for the Content, copy and paste the following html code:

<h4>@Value(Name)</h4>
This facility is located at <a href="http://maps.google.com/maps?q=@YValue(),@XValue()">@Value(Address), Vancouver, BC</a>
<img src="@Value(HallNumber).jpg">

This HTML uses the X and Y values as well as the address and then embeds them into a Google Maps URL. It will also use the images that are saved in the same folder as the workspace that corresponds the Hall Number with the appropriate image. Finally set the Include Attribute Table to No, then click OK.

7. Rerun the Workspace

Rerun the workspace and view the updated KML in Google Earth to view the new balloon description with images.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM