Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing custom icons in KML at their actual sizes

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.

like image 390
TheWommies Avatar asked Mar 20 '14 06:03

TheWommies


3 Answers

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.

like image 185
CodeMonkey Avatar answered Nov 20 '22 16:11

CodeMonkey


<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.

like image 39
geocodezip Avatar answered Nov 20 '22 16:11

geocodezip


 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>
like image 1
user3442296 Avatar answered Nov 20 '22 16:11

user3442296