Search code examples
google-mapsgoogle-maps-api-3kmlgoogle-maps-styling

Style a KML polygon overlay on Google Maps?


I am adding a KML polygon overlay to a Google Map:

var ctaLayer = new google.maps.KmlLayer('http://global.mapit.mysociety.org/area/14020.kml');
ctaLayer.setMap(plainmap);

This gives me a bright blue polygon with a dark blue path outline. How can I style it?

The documentation seems to suggest that CSS styles can be used, but I can't find the KML polygon within the DOM, so I'm not sure what style rules to use.


Solution

  • KML includes the ability to style the Polygon. If you want to style it dymnamically (not in the KML), you need to use a third party parser like geoxml3 or FusionTableLayers (which will import KML).