title: Load a KML in Google Maps API with proper rendering of colored disc placemarks
body: <p>I am using this piece of code to load a KML file in GoogleMapsAPI:</p>
  
  <pre><code>&lt;script&gt;
  function googleMapInitialize() {
    var myOptions = {
      center: new google.maps.LatLng(-34.397, 150.644),
      zoom: 8,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var myMap = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    var ctaLayer = new google.maps.KmlLayer('http://www.freemages.fr/test/session_k.kml');
    ctaLayer.setMap(myMap);
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>While it works properly to load the points, the style I have defined is not rendered properly, as it uses a white disc in PNG format that is supposed to be re-colorized according to the color parameter, and also a resizing of the picture according to the scale parameter:</p>
  
  <pre><code>&lt;Style id="sn_style_0"&gt;
      &lt;IconStyle&gt;
          &lt;color&gt;FF4ea24a&lt;/color&gt;
          &lt;scale&gt;0.4&lt;/scale&gt;
          &lt;Icon&gt;
              &lt;href&gt;http://www.freemages.fr/test/disc.png&lt;/href&gt;
          &lt;/Icon&gt;
      &lt;/IconStyle&gt;
      &lt;LabelStyle&gt;
          &lt;scale&gt;0.5&lt;/scale&gt;
      &lt;/LabelStyle&gt;
  &lt;/Style&gt;
  &lt;Style id="sh_style_0"&gt;
      &lt;IconStyle&gt;
          &lt;color&gt;FF4ea24a&lt;/color&gt;
          &lt;scale&gt;0.5&lt;/scale&gt;
          &lt;Icon&gt;
              &lt;href&gt;http://www.freemages.fr/test/disc.png&lt;/href&gt;
          &lt;/Icon&gt;
      &lt;/IconStyle&gt;
      &lt;LabelStyle&gt;
          &lt;scale&gt;0.5&lt;/scale&gt;
      &lt;/LabelStyle&gt;
  &lt;/Style&gt;
  &lt;StyleMap id="msn_style_0"&gt;
      &lt;Pair&gt;
          &lt;key&gt;normal&lt;/key&gt;
          &lt;styleUrl&gt;#sn_style_0&lt;/styleUrl&gt;
      &lt;/Pair&gt;
      &lt;Pair&gt;
          &lt;key&gt;highlight&lt;/key&gt;
          &lt;styleUrl&gt;#sh_style_0&lt;/styleUrl&gt;
      &lt;/Pair&gt;
  &lt;/StyleMap&gt;
  </code></pre>
  
  <p>Google Earth can render properly this kind of style and it works very nicely.</p>
  
  <p>In my project, I want to let the user choose exactly the color he wants, so I cannot use a collection of colored  discs that I would use without recoloring, which otherwise would be a simple option.</p>
  
  <p>I also tried to use a dynamic creation of PNG transparent disc in PHP using the following code, but PHP does not manage transparency very well and it does not display properly in the file:</p>
  
  <pre><code>&lt;?php
  header('Content-type: image/png');
  
  $r = $_GET["r"];
  $fg = $_GET["fg"];
  
  is_numeric($r) or $r = 16; // radius
  strlen($fg)==6 or $fg = '22e822'; // fill color
  $bg = 'ffffff';
  
  function hex2rgb($im,$hex) {
      return imagecolorallocate($im,
          hexdec(substr($hex,0,2)),
          hexdec(substr($hex,2,2)),
          hexdec(substr($hex,4,2))
          );
  }
  
  $d = $r*2;
  $dm = $d-4;
  
  $im1 = imagecreatetruecolor($d,$d);
  imagecolortransparent($im1, hex2rgb($im1,$bg));
  imagefill($im1,0,0,hex2rgb($im1,$bg));
  imagefilledellipse($im1, $r, $r, $dm, $dm, hex2rgb($im1,$fg));
  imagepng($im1);
  ?&gt;
  </code></pre>
  
  <p>Ideally if it could be possible just to create a colored disc by code in the KML file it would be the best, but I did not find any way to do so in the documentation.</p>
  
  <p>Any suggestion how to workaround this issue?</p>
  
  <p>Thanks!</p>