How can I reference local custom icons in a kml?

孤街浪徒 提交于 2021-01-29 11:49:51

问题


I have quite literally never tried to edit a kml file before, so I'm not totally sure of what I'm trying to ask, but I'll do my best.

I'm trying to use custom icons for my placemarkers. I tried to upload the images to a hosting site and link to them, and I also tried putting them into a subfolder and referencing the local address. Here are those attempts.

  <Style id="1">
    <IconStyle>
      <Icon>
    <href>https://cdn1.imggmi.com/uploads/2019/3/8/63626b5bc964d76ca0d5bdb30fb44afd-full.png</href>
      </Icon>
    </IconStyle>
    </Style>

And the second method:

  <Style id="1">
    <IconStyle>
      <Icon>
        <href>files/number_1.png</href>
      </Icon>
    </IconStyle>
    </Style>

And the placemarker references the style like this:

        <Placemark>
            <styleUrl>#1</styleUrl>
            <Point>
                <coordinates>-86.78824404543640,36.41901416833124,1005.84</coordinates>
                <altitudeMode>absolute</altitudeMode>
            </Point>
        </Placemark>

No matter what I do, I can't get the icon to show up in GE. I have read a bunch of different tutorials, tried naming the folder and subfolder differently, and tried making a kmz with the kml in the main folder and the icons in a subfolder. Nothing seems to work. It feels like I'm missing something basic or fundamentally misunderstanding some aspect of this, but for the life of me I can't seem to figure it out!

Any help is appreciated!


回答1:


This KML works for me in Google Earth in a KMZ/zip file:

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
  <Style id="1">
    <IconStyle>
      <Icon>
        <href>files/number_1.png</href>
      </Icon>
    </IconStyle>
    </Style>
    <Placemark>
      <styleUrl>#1</styleUrl>
      <Point>
          <coordinates>-86.78824404543640,36.41901416833124,1005.84</coordinates>
          <altitudeMode>absolute</altitudeMode>
      </Point>
    </Placemark>
  </Document>
</kml>

The file number_1.png is in the "files" directory.

displayed on Google Maps

on Google Earth:




回答2:


I just struggled with this for... never mind. It's embarrassing.

Same problem: kmz with embedded icons worked on GE desktop, but the icons would not import into Google My Maps. I was so frustrated I was ready to hurt someone.

Of course it was entirely my fault.

<href>Images/Icon-1.png</href> worked in GE desktop, but not maps.

<href>images/icon-1.png</href> worked in both.

The issue: everything for the web is case sensitive so the folder name "Images" didn't work on the web because the folder in the zip file was named "images" (lower case ')

D'Oh!



来源:https://stackoverflow.com/questions/55056263/how-can-i-reference-local-custom-icons-in-a-kml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!