My Google Map Blog

Labelling Polygons in Google Earth

by Timothy Whitehead on Feb.11, 2016, under 3D Models, Argentina, Australia, Brazil, California, Denmark, England, Germany, Google Earth News, Google Earth Tips, Google Sky, Google maps, Hawaii, Indonesia, Ireland, Italy, Japan, Kenya, Mexico, Natural Landmarks, Netherlands, Sightseeing, Street Views, USA

We were recently asked by a GEB reader whether or not it is possible to add labels to paths and polygons. The ability to add labels to paths was added to KML with version 6.1 of Google Earth. Unfortunately, it cannot be done within Google Earth but requires editing the KML file. You need to identify the style element for the lines you want labels for, and add <gx:labelVisibility> in a <LineStyle>. See the KML Reference for more.

For polygons, however, there is no way to tell Google Earth to display the label. The only solution is to create a separate placemark for each polygon with the name. This can be quite tedious for large datasets, so we thought it might be useful to have a utility to do it automatically.

The utility below simply goes through a KML file and for every polygon, creates a new placemark in the centre with the same name as the polygon.


Our KML parser is still in development so it is not guaranteed to keep all elements in the KML file. Let us know in the comments if you find any bugs or have suggestions for improvements.


We tested it on our map of 3D imagery.

We previously wrote a JavaScript utility to put numbered labels on the points of polygons.

The post Labelling Polygons in Google Earth appeared first on Google Earth Blog.

:,

Comments are closed.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...