Showing custom icons in KML at their actual sizes
Asked Answered
P

3

6

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.

Phoenicia answered 20/3, 2014 at 6:22 Comment(0)
D
13

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.

Decca answered 21/3, 2014 at 21:10 Comment(0)
F
2

<w> and <h> are in the gx: namespace, user <gx:w> and <gx:h>

https://developers.google.com/kml/documentation/kmlreference#gxw

Elements Specific to Icon

An HTTP address or a local file specification used to load an icon. and If the specifies an icon palette, these elements identify the offsets, in pixels, from the lower-left corner of the icon palette.If no values are specified for x and y, the lower left corner of the icon palette is assumed to be the lower-left corner of the icon to use. and If the specifies an icon palette, these elements specify the width () and height (), in pixels, of the icon to use.

Fructiferous answered 20/3, 2014 at 13:23 Comment(0)
P
1
 Use the Scale tag
 1 - Displays actual size
 anything less than 1 (0.1 - 0.9) - reduces the size of icon


<Style>
  <IconStyle>
   <scale>1</scale>
    <Icon>
      <href>Pins/aPin.jpg</href>
    </Icon>
  </IconStyle>
</Style>
Package answered 20/3, 2014 at 14:44 Comment(2)
Thanks but setting scale 1 seems to give it another size and not its actual size which I want. I want the actual image size to show on google earthPhoenicia
According to groups.google.com/forum/#!topic/google-maps-api/3ofrKMLnB68 It will always be initially 32 by 32 pixlsPhoenicia

© 2022 - 2024 — McMap. All rights reserved.