Advertisements

MkrGeo

An original point of view

GIS

How to highlight a multiple KML placemarks in Google Earth?

KML unique icon highlight

Pic. 13 Unique highlight for the .kml placemark in Google Earth.

An element or text hover effect is known i.e. from HTML and CSS languages. What is interesting, this effect can be achieved also in .kml files. Sometimes, when we have a lot of placemarks with the same (or different) icon can be easier for us, when we move a cursor on the placemark, which we are interested in.
For this purpose, you need only a program to edit an XML code (i.e Notepad++) and make small amendments!
At the very beginning, I prepared a 10 single placemarks, showing cities in Western Europe (Pic. 1).

Cities Netherlands, Belgium and UK in Google Earth

Pic. 1 10 random placemarks in Google Earth

Next, go to the XML code and see, what can we change swiftly in order to get them highlighted after you hovering by the cursor (Pic. 2).

KML hover placemark XML

Pic. 2 A piece of XML code, that must be changed in order to highlight your placemark when hovering it. 1 – A ” box, which refers to in general to the placemarks being hover by cursor; 2 – The ” section, where we can set both font color and size of the name, which pops up under hovering.

Let’s go through these highlighted sections: The most important things here are ‘<IconStyle>’ and ‘<LabelStyle>’. Digging down into them interesting elements will be: ‘<Scale>’, ,‘<Color>’ and link to the icon shape.
Firstly I change the color of my label and it size, setting 3 for ‘<IconStyle>’ and 2 for ‘<LabelStyle>’.
Let’s see the results then (Pic. 3).

KML placemark after hovering

Pic. 3 One of our placemarks has been highlighted after hovering.

Everything looks good, but our placemark looks too translucent, as you possibly spotted. So we must do something small to make it opaque. Small color code changes are required in order to set it hex transparency. In our case, we would like to have it completely opaque, although there are quite a few other options available. Our alterations we can make in the relevant software (Pic. 4) and seen in Google Earth afterward (Pic. 5).

KML placemark color transparency setting

Pic. 4 Setting color hex transparency in .kml file using Notepad ++: 1 – Color before changes; 2 – Color after changes. Red stuff shows you a part of the code, which must be changed.

KML placemark opaque color hover

Pic. 5 Highlighted placemark already presenting an opaque colour in Google Earth.

Another thing, which is changeable in .kml placemark is an icon. Obviously, you can do it at the very beginning, using an interactive map builder. If you won’t do it at this stage, there is no problem. This issue can be also altered via XML editor. However, you must have a proper URL address of the icon, which you want to use. It can be an icon from Google or from another icon source. There are a few icon bases available on the web, from where you can pick up the most needed one. You can save them on your hard drive. Next, you must upload them on the web server first in order to generate a link to them, which will be applicable in the .kml file.
Once you do this, just replace the link in XML code as per below (Pic. 6) and enjoy your new icon, which appears as a highlight (Pic. 7).

KML icon link replacement

Pic. 7 Icon link replacement in the XML code for the .kml placemark highlight.

KML placemark icon change

Pic. 8 The .kml placemark hovering after icon link change.

Great!  Our icon is coming, when we are hovering the random city. If you wish to change the colour, then you can back to the code and replace the colour description.  Remember about the hex colour transparency too. Thereafter open your .kml file in Google Earth and see the results (Pic. 9).

KML placemark icon and color change

Pic. 9 Both icon and colour have been applied for our .kml placemarks highlight.

The last thing, that comes to mind is the possibility to make a unique highlight for every single placemark. We have the same highlight for every placemark so far. It’s fine when you just want to know, which one particular are you hovering right now. If you want to make a step ahead and collocate your placemark with some main feature, like Paris with Eiffel Tower or Miami with Miami Beach, etc, then you can differ your highlight, making it unique for every single or at least group of your placemarks.
To do this you must copy quite a big section of your XML code and paste it underneath. It will make your .kml file harder to read through, although you must remember about a few changes of the ID’s (Pic. 10).

<Style id=”Canterbury-normal”>

</StyleMap>

This is the stuff, which you must copy, as I did (Pic. 10). Next, you can change a default ID, expressed by random codes into your name, easier for recognize.

KML unique placemark highlight

Pic. 10 Changes the ID’s in XML code (marked red) in order to make the placemark highlight unique.

Let’s crack on with another one (Pic. 11).

KML unique highlight icon

Pic. 11 Unique highlight icon for .kml placemark – An XML code alterations.

Remember to input your ID also in the ‘<Placemark>’ section, located below in the XML code. Otherwise, you won’t have the good result (Pic. 12, 14)

KML Placemark ID change

Pic. 12 The .kml placemark ID change is very important, when you change the ID for an icon, and map above.

As a result, you should have unique icons when you hovering the placemarks (Pic. 13).

KML unique icon highlight

Pic. 13 Unique highlights for the .kml placemark in Google Earth.

What about if you will be wrong? If you, for instance, forget to change the ID for your placemark or miss at least one letter, then you will get a default placemark icon in Google Earth (Pic. 14).

KML one placemark with wrong icon id

Pic. 14 One placemark must have been written wrongly. As a result, it appears as a default icon in Google Earth.

At the finish, I would like to add, that a separate ID for every single placemark or group of placemarks refers also both to the ‘<Description>’ as well as the ‘<BalloonStyle>’. It means, that you can make your general content unique for these groups of placemarks. Read more about it in my previous articleContent management in KML files.

Mariusz Krukar

 

Links:

  1. KML file colour picker
  2. Custom icons in Google Earth
  3. https://mapicons.mapsmarker.com/
  4. Styles for highlighted icons

 

Forums:

  1. Translucent objects in KML
  2. Hex transparency in colours

Youtube:

Read also:

  1. Content management in KML files

 

 

 

 

Advertisements

Theme by Anders Norén

Follow

Get the latest posts delivered to your mailbox:

%d bloggers like this: