简体   繁体   English

在 FME 中更新 Google KMZ 弹出内容和删除“方向”

[英]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).默认情况下,KML 气球将包含链接“此处的方向”和“此处的方向”(行车路线)。

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.我想知道,如何使用FME从气球中删除这些链接,以及使用HTML设置KML Balloon内容,URL链接和图像,例如png,jpeg和tiff。

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.另外,如果有 FME 以外的解决方法,我将不胜感激,我的目标是从 google kmz 中删除我不需要的数据,并且只想显示所需的数据。

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.您希望在 KML 文件中最终得到的是用于您的气球内容的 BalloonStyle,它看起来像: <BalloonStyle><text>...</text></BalloonStyle> ,或者在 KML 的顶部共享文件,或内嵌在每个地标/特征中。 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.您的 BalloonStyle 可以包含用于气球的静态 HTML/文本内容,或者可以使用基本数据(名称、描述等)或来自每个功能的 ExtendedData 字段填充的 HTML 模板。 When you specify balloon content using BalloonStyle, it will leave leave out the directions info.当您使用 BalloonStyle 指定气球内容时,它将省略路线信息。 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.它也不会通过 defautl 在气球顶部包含名称,因此您可能希望将其包含在您的内容或模板中。

For more on KML BalloonStyles, see: https://developers.google.com/kml/documentation/kmlreference#balloonstyle有关 KML BalloonStyles 的更多信息,请参阅: https : //developers.google.com/kml/documentation/kmlreference#balloonstyle

and: https://developers.google.com/kml/documentation/extendeddata和: 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.我对 FME 不太了解,但看起来可以使用 AttributeCreator 来做到这一点。 For more see these instuctions: https://community.safe.com/s/article/kml-balloon-contents-removing-directions有关更多信息,请参阅这些说明: https ://community.safe.com/s/article/kml-balloon-contents-removing-directions

1. Read in GML File 1. 读入 GML 文件

Open FME Workbench and start a blank workspace.打开 FME Workbench 并启动一个空白工作区。

Add an OGC GML reader and select the gml dataset.添加 OGC GML 阅读器并选择 gml 数据集。

2. Reproject to LL84 2.重新投影到LL84

Next, add a CsmapReprojector transformer to the canvas and connect it to the FireHalls reader feature type.接下来,将 CsmapReprojector 转换器添加到画布并将其连接到 FireHalls 读取器功能类型。 In the parameters, set the Destination Coordinate System to LL84.在参数中,将目标坐标系设置为 LL84。 The coordinate system needs to be changed because KML only supports a latitude/longitude coordinate system.坐标系需要更改,因为 KML 仅支持纬度/经度坐标系。

3. Remove “Directions” from KML Balloons 3. 从 KML Balloons 中删除“方向”

To remove the direction links from the balloons, a KML attribute needs to be created.要从气球中移除方向链接,需要创建 KML 属性。 To do that, add an AttributeCreator to the canvas and connect it to the CsmapReprojector.为此,将 AttributeCreator 添加到画布并将其连接到 CsmapReprojector。 In the parameters, create a New Attribute called kml_balloonstyle_text.在参数中,创建一个名为 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".对于属性值,将值设置为 $[description],这会告诉 Google 地球仅使用特征气球的描述,而不是包含“Directions to Here”和“Directions from Here”链接的默认值。

4. Write to OGC/Google KML 4. 写入 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.为了测试路线是否成功删除,我们需要写出到 Google KML,然后在 Google Earth 中查看 KML 文件。 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.将 OGC/Google KML Writer 添加到画布,然后将数据集命名为 FireHallsOutput.kml,确保此文件与 jpeg 图像保存在同一文件夹中。

5. Run the translation 5. 运行翻译

Connect the FireHalls writer feature type to the AttributeCreator.将 FireHalls 编写器功能类型连接到 AttributeCreator。 Run the translation and then open up the folder containing the new FireHalls.kml file.运行翻译,然后打开包含新 FireHalls.kml 文件的文件夹。 Open the file in Google Earth to view the results.在 Google 地球中打开文件以查看结果。

6. Set Description Balloon HTML Content 6.设置描述气球HTML内容

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.将 KMLPropertySetter 添加到画布,并将其连接到 AttributeCreator 和 FireHalls 编写器功能类型之间。 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. KMLPropertySetter 将通过指定指向 Google 地图中 Firehall 位置的链接以及 Firehall 照片(如果可用)来设置气球的 HTML 内容。 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.在 KMLPropertySetter 参数中,将名称设置为属性名称,将摘要设置为属性地址,该信息已包含在 FireHalls.gml 数据集中。

Next set the Content Type to HTML and then for the Content, copy and paste the following html code:接下来将内容类型设置为 HTML,然后对于内容,复制并粘贴以下 html 代码:

<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.此 HTML 使用 X 和 Y 值以及地址,然后将它们嵌入到 Google 地图 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.最后将 Include Attribute Table 设置为 No,然后单击 OK。

7. Rerun the Workspace 7. 重新运行工作区

Rerun the workspace and view the updated KML in Google Earth to view the new balloon description with images.重新运行工作区并在 Google 地球中查看更新的 KML,以查看带有图像的新气球描述。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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