Showing custom icons in KML at their actual sizes

TheWommies picture TheWommies · Mar 20, 2014 · Viewed 8.4k times · Source

Like the post below I cannot get my placemark to display my icon at their actual size.

https://stackoverflow.com/questions/21549842/how-to-display-custom-icon-of-placemark-in-original-size-width-height-at-kml

   <Style>
      <IconStyle>
        <Icon>
          <href>Pins/aPin.jpg</href>
          <w>95</w>
          <h>95</h>
        </Icon>
      </IconStyle>
    </Style>

Seems w and h have no affect in google earth.

The icon is in a relative folder shows at some smaller size but I want it to display the actual size.

Any information is appreciated.

Answer

JasonM1 picture JasonM1 · Mar 21, 2014

Google Earth (and likewise Google Maps) normalizes all square icons referenced in KML to 32x32 pixels when displayed on the map so for example both a 50x50 and a 64x64 pixel icon each gets normalized to 32x32 when scale = 1.0.

This can be adjusted using an IconStyle in the KML and adjusting the scale, but a 1.0 scale represents 32 pixels regardless of the actual image size. (scale 0.5 = 16 pixels, scale 2.0 = 64 pixels, etc.)

<Style>
  <IconStyle>
   <scale>1</scale>
   <Icon>
      <href>icon.png</href>
   </Icon>
  </IconStyle>
</Style>

If the icon image is non-square (i.e. rectangular) then the smaller dimension (either height or width) gets normalized to 32-pixels and the larger dimension gets normalized with same aspect ratio. For example, a 64x80 icon image will be normalized to 32x40 pixels when displayed.

For this reason, it is recommended that the icons either be 32x32 or 64x64.

You can measure the "screen" pixels dimensions with this KML screen ruler.