Change icon in kml for Google Earth

0

I've been trying to make a kml file for Google Earth where a certain point on the map is shown. I tried to change the icon (instead of the yellow thumbtack that another appears) with the following code, but I have not succeeded:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
 <Style id="icono">
  <IconStyle>
   <Icon>
    <href>http://maps.google.com/mapfiles/kml/pal4/icon28.png</href>
   </Icon>
  </IconStyle>
 </Style>
 <Folder>
  <Placemark>
   <name>name</name>
   <description>descrip</description>
   <styleUrl>#icono</styleUrl>
   <Point>
    <coordinates>lon,lat</coordinates>
   </Point>
  </Placemark>
 </Folder>
</kml>

What would I have to modify to be able to change this icon? Thanks!

    
asked by Adrian 22.12.2017 в 09:13
source

1 answer

2

You would say that the only thing you need is the <Document> tag

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
 <Document>
   <Style id="icono">
    <IconStyle>
     <Icon>
      <href>http://maps.google.com/mapfiles/kml/pal4/icon28.png</href>
     </Icon>
    </IconStyle>
   </Style>
   <Folder>
    <Placemark>
     <name>name</name>
     <description>descrip</description>
     <styleUrl>#icono</styleUrl>
     <Point>
      <coordinates>-3.6955,40.4276</coordinates>
     </Point>
    </Placemark>
   </Folder>
 </Document>
</kml>

 function initialize() {
        var map = new google.maps.Map(document.getElementById('map'), {
          zoom: 13,
          center: {lat: 40.40, lng: -3.6955}
        });

        var ctaLayer = new google.maps.KmlLayer({
          url: 'http://www.ffflabs.com/cctv7.kml?0',
          map:map,
          preserveViewport:true
        });
        
        
      }
	google.maps.event.addDomListener(window, 'load', initialize);
      
#map {
	height:600px;
}
<script src="https://maps.googleapis.com/maps/api/js?libraries=geometry&key=AIzaSyBRqo4qwqHHrtbY9aL6vYYDw1GOhkK97MQ"></script>
<div id="map">
    
answered by 22.12.2017 / 12:45
source