Search code examples
javascriptgoogle-mapsgoogle-maps-api-3kml

Google Maps JavaScript API : Dynamically style KML Layer


I am making this interactive map using Google Maps API and I need your help on something.

First here is the example I'm working on : http://it-zone.ma/map/

A KML Polygon is loaded over Africa for it to be highlightable. I need to change the fillColor of the polygon when mouse is over it. In Google Maps API documentation, there is a chapter on Dynamically Styling Data Layers and another one on KML Layers but I can't seem to find any way to Dynamically Style KML Data Layers.

Thank you in advance.


Solution

  • You can't dynamically style KmlLayers. You can use a data layer, a FusionTables layer, or a third party parser like geoxml3 or geoxml-v3.

    example using geoxml3