问题
I am using kml file to draw polygons in google map. I am setting click events for those polygon which is working. Now I want the clicked polygon to be highlighted. I had tried the setOption() method, but it didn't work. Is it possible to change the color of polygon on clicking it?
回答1:
If you are using KmlLayer (a guess), you can't change the properties of the Polygons. If you use a third party KML parser like geoxml3 or geoxml-v3 to render the polygons as native Google Maps API v3 objects you can change their properties (but whether the performance is acceptable will depend on how complex your KML is). You can also dynamically change Polygons in tiles rendered using FusionTablesLayer (import your KML into a Fusion Tabel).
Example changing the color of Polygons from KML rendered using geoxml3 on mouseover
回答2:
If you are using KmlLayer (a guess), you can't change the properties of the Polygons. If you use a third party KML parser like geoxml3. Here is a link to that.. http://developers.cloudmade.com/projects/web-maps-api/examples/kml-and-geo-rss
来源:https://stackoverflow.com/questions/14478441/highlight-a-polygon-while-on-click-using-kml