Je travaille actuellement avec l'API GoogleMaps V3. Et je charge le KML suivant:GoogleMaps V3 KML PlaceMark StyleURL changer
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document><Style id="red">
<LineStyle>
<color>e2001aFF</color>
<width>1</width>
</LineStyle>
<PolyStyle>
<color>e2001acc</color>
<fill>1</fill>
</PolyStyle>
<BalloonStyle>
<bgColor>ffffffff</bgColor>
<text>
<font font size='3' color="#aa0000"><b>$[name]</b></font>
<table border='1' padding='1'>$[description]</table>
</text>
</BalloonStyle>
</Style><Style id="gray">
<LineStyle>
<color>666666FF</color>
<width>1</width>
</LineStyle>
<PolyStyle>
<color>cccccccc</color>
<fill>1</fill>
</PolyStyle>
<BalloonStyle>
<bgColor>ffffffff</bgColor>
<text>
<font font size='3' color="#aa0000"><b>$[name]</b></font>
<table border='1' padding='1'>$[description]</table>
</text>
</BalloonStyle>
</Style><name>KML</name><Placemark id="5473">
<Snippet maxLines="0"></Snippet>
<name></name>
<description></description>
<visibility>1</visibility>
<open>0</open>
<Polygon>
<extrude>1</extrude>
<tessellate>1</tessellate>
<altitudeMode>clampedToGround</altitudeMode>
<outerBoundaryIs>
<LinearRing>
<coordinates>5.54377026975101,51.6529393188121,0 5.54235383140039,51.6401639644859,0 5.53873941603147,51.6354393533086,0 5.53313983380098,51.6352371598686,0 5.53109711126943,51.6324409224198,0 5.52737786126051,51.6324813956187,0 5.52260612519502,51.6307520918321,0 5.51872075256068,51.6322363340599,0 5.51736992027453,51.6316246096909,0 5.51484051209933,51.6325529212478,0 5.51142301311675,51.6346650281583,0 5.51056937640636,51.6341534949811,0 5.50849516823445,51.634713720177,0 5.50639250193852,51.6343571115019,0 5.50606525074908,51.6362594682684,0 5.49722704729733,51.6265043908797,0 5.46737140246617,51.6425173978967,0 5.42182366459901,51.6543409225039,0 5.42437999474141,51.6560175383335,0 5.42661087246537,51.6554954605812,0 5.43004089768112,51.6592736942533,0 5.43163811861903,51.6609457181974,0 5.43165069241378,51.6634400858201,0 5.43400899528993,51.6642654325698,0 5.43709542035706,51.6646638722533,0 5.44492487842012,51.6642912329926,0 5.44573674258826,51.6661636919472,0 5.4489840685884,51.6698962431202,0 5.45900781447863,51.6917003092576,0 5.4607098223104,51.6897436062354,0 5.46973551245956,51.6895883044489,0 5.46923994357604,51.6914530469315,0 5.4707388732589,51.691761698608,0 5.47831558751497,51.7015861823258,0 5.48458009605862,51.7018910935235,0 5.49211917579361,51.7059403621055,0 5.50347583796229,51.6934008340147,0 5.50205171042708,51.6901914509596,0 5.49762079494402,51.6850245556145,0 5.49108009295296,51.6774498385961,0 5.48603420879267,51.6715509606335,0 5.50117534805849,51.6655353570913,0 5.50085686840637,51.6595932268782,0 5.51334569323478,51.6586174823159,0 5.52070245822274,51.6631783875663,0 5.52147513937071,51.6732045469624,0 5.53323861625654,51.66639133756,0 5.54377026975101,51.6529393188121,0 </coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
<styleUrl>#red</styleUrl>
</Placemark></Document></kml>
Ce que je wan't pour atteindre est de changer la couleur d'un gris sur marqueur de position, cliquez sur le indicateur d'emplacement.
Je suis capable d'attraper l'événement click, mais je ne peux pas trouver comment changer le style après le chargement:
google.maps.event.addListener(_kml_layer, "click", function(obj) {
alert(obj.featureData.id);
});
Le _kml_layer est défini par la fonction suivante:
_kml_layer = new google.maps.KmlLayer(
'http://www.mydomain.com/mykml.kml',
{
suppressInfoWindows : true,
map : _map
});
Peut yo Vous ajoutez un exemple de code comment le changer? – Niels
Si vous demandez un style dynamique de fusionTablesLayer, il existe [un exemple dans la documentation] (https://developers.google.com/maps/documentation/javascript/layers#fusion_table_styles) – geocodezip