2

I would like to remove the placemark names on the Google Earth Map and make them appear when I hover over the icon with the mouse. I tried to set the LabelStyle scale to 0 but it actually does the opposite situation.

1

Yes, the way to do this is with a normal and a highlight (hover) style. Below is a simplified example that hopefully makes it clear what the shared style should look like.

Be careful with style IDs, since the ones put out by many KML exporters can often be confusing. Also note that the hover style will only work on desktop/web, as there's no "hover" event on mobile touchscreens.

<StyleMap id="my_stylemap">
  <Pair><key>normal</key><styleUrl>#my_style_normal</styleUrl></Pair>
  <Pair><key>highlight</key><styleUrl>#my_style_highlight</styleUrl></Pair>
</StyleMap>

<Style id="my_style_normal">
  <IconStyle>
    <Icon><href>http://example.com/icons/my_icon.png</href></Icon>
    <scale>1.1</scale>
  </IconStyle>
  <LabelStyle>
    <scale>0</scale>
  </LabelStyle>
</Style>

<Style id="my_style_highlight">
  <IconStyle>
    <Icon><href>http://example.com/icons/my_icon.png</href></Icon>
    <scale>1.3</scale>
  </IconStyle>
  <LabelStyle>
    <scale>1</scale>
  </LabelStyle>
</Style>

The important parts are making sure that the style IDs and references in the StyleMap are correct, that the normal style has LabelStyle > scale = 0, and the highlight style has LabelStyle > scale = 1 or higher.

  • Ok I understood my mistakes, it works well with your Styles. 1st kml editing done, thank you very much! – stehrs May 16 at 7:38
0

I don't have both Style id like "s_ylw-pushpin" and "s_ylw-pushpin_hl"

<StyleMap id="msn_ylw-pushpin">
    <Pair>
        <key>normal</key>
        <styleUrl>#sn_ylw-pushpin</styleUrl>
    </Pair>
    <Pair>
        <key>highlight</key>
        <styleUrl>#sh_ylw-pushpin</styleUrl>
    </Pair>
</StyleMap>
<Style id="sn_ylw-pushpin">
    <IconStyle>
        <Icon>
            <href>C:/Users/s/OneDrive - /Database/Pictures/logo .png</href>
        </Icon>
        <hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
    </IconStyle>
    <ListStyle>
    </ListStyle>
    <LineStyle>
        <color>ffff00ff</color>
        <width>2</width>
    </LineStyle>
</Style>
<Style id="sh_ylw-pushpin">
    <IconStyle>
        <scale>1.18182</scale>
        <Icon>
            <href>C:/Users/s/OneDrive - /Database/Pictures/logo .png</href>
        </Icon>
        <hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
    </IconStyle>
    <LabelStyle>
        <scale>0</scale>
    </LabelStyle>
    <ListStyle>
    </ListStyle>
    <LineStyle>
        <color>ffff00ff</color>
        <width>3</width>
    </LineStyle>
</Style>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.