span8
span4
span8
span4
By default a KML balloon will contain links "Directions to Here" and "Directions from Here" (driving directions).This demo shows how to remove these links from the balloon,as well as use HTML to set KML Balloon content,in this case,URL links and images,such as pngs,jpegs,and tiffs.
Datasets.zip (Dataset containing FireHalls.gml as well as the firehall images)
KMLBalloonsFinal.fmwt (Completed workspace template)
KML after being reprojected to demonstrate the "Directions" links viewed in Google Earth
1.Read in FireHalls.gml
In a blank workspace,add a GML reader and select the FireHalls.gml dataset.The dataset can be read in as a zip file downloaded from this tutorial.
2.Reproject to LL84
Next,add a CsmapReprojector transformer to the canvas and connect it to the FireHalls 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.This is a KML specific style element,for more information on KML elements see thedocumentation.
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".
AttributeCreator parameters
4.Write to 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 a 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.Set the Feature Type Definition to Automatic.
When the Feature Type dialog appears,set the Feature Type Name to FireHalls and click OK.Connect the new writer feature type to the AttributeCreator.
5.Run the translation
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.
KML viewed in Google Earth with the "Directions" links removed
6.Set Description Balloon HTML Content
Now that we know that the descriptions 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 KML 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 in 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:
@Value(Name)
This facility is located at@Value(Address),Vancouver,BC
This HTML use the X and Y values as well as the address and then embed it into a Google Maps URL.It will also use the images that are saved in the same folder as the workspace that correspond the Hall Number with the appropriate image.
Finally set the Include Attribute Table to No then click OK.
KMLPropertySetter parameters,set the Name,Summary,Content Type,Content and Include Attribute Table.
Notethat the image name can be given without a path,only because the output is being written to the same folder in which the image files exist.Otherwise,this would need to be given the full path.Specifying the name or full path only works with local drives.If you are using a network drive,you will need to specify the images under the Additional Files section.Please see thedocumentationfor further information on using additional files in FME.
7.Rerun the translation
Rerun the translation and view the updated KML in Google Earth to view the new balloon description with images.
Final KML output viewed in Google Earth with the styled balloon and named points.
Final workspace overview
Data Attribution
The data used here originates from open data made available by theCity of Vancouver,British Columbia.It contains information licensed under the Open Government License - Vancouver.
Exactly where do you "demo" how to remove Directions from a KML popup?THis title is very misleading.
Hi@tinydancer,
I apologize for the article not being clear,it looks like the attached dataset/workspace was broken.
I have updated the article for 2018.1,hopefully the directions are a bit more clear.Please let me know if you encounter any other issues.
-Liz
© 2019 亚搏在线Safe Software Inc |Legal