I'm trying to import kml file and style them.
In my KML, we have different styles for example
<Style id="YellowPolyStyle">
<LabelStyle>
<color>00000000</color>
<scale>0</scale>
</LabelStyle>
<BalloonStyle>
</BalloonStyle>
<LineStyle>
<color>ff6e6e6e</color>
<width>0.4</width>
</LineStyle>
<PolyStyle>
<color>ff00d9ff</color>
</PolyStyle>
</Style>
<Style id="GreenPolyStyle">
<LabelStyle>
<color>00000000</color>
<scale>0</scale>
</LabelStyle>
<BalloonStyle>
</BalloonStyle>
<LineStyle>
<color>ff6e6e6e</color>
<width>0.4</width>
</LineStyle>
<PolyStyle>
<color>ff009961</color>
</PolyStyle>
</Style>
And I calling those style for filling my KML layer. Here is my sample
<Placemark id="ID_00000">
<name>Grid ID: 14</name>
<Snippet maxLines="0"></Snippet>
<description></description>
<styleUrl>#GreenPolyStyle</styleUrl>
.......
</Placemark>
But it is not working. It is filling default Blue colour in the KML layer.
So how can I fix this issue. I am using Leaflet Omnivore library for loading the KML.
I manually tried to attach style using setStyle function but it is also not working. Here is my sample code
var runLayer = omnivore.kml(kml)
.on('ready', function() {
runLayer.eachLayer(function(layer) {
if(layer.feature.properties.styleUrl == "#YellowPolyStyle") {
layer.setStyle(
{
"LabelStyle": {
"color": "00000000",
"scale": "0"
},
"BalloonStyle": "",
"LineStyle": {
"color": "ff6e6e6e",
"width": "0.4"
},
"PolyStyle": { "color": "ff00d9ff" }
}
);
}
How can this be done?