当我将功能写入KML时。它不包括功能样式。要求openlayers similiar question 2.我想要openlayers的代码3.以下是将功能写入kml文件的代码
class Program
{
static void Main(string[] args)
{
DiceRoll DR = new DiceRoll();
DR.SecondRolledDice();
}
}
public int RolledDice()
{
Random numberGenerator;
numberGenerator = new Random();
int firstdiceroll = numberGenerator.Next(1, 7);
return firstdiceroll;
}
public void SecondRolledDice()
{
Random SecondnumberGenerator;
SecondnumberGenerator = new Random();
int seconddiceroll = SecondnumberGenerator.Next(1, 7);
DiceRoll DR = new DiceRoll();
var diceroll = DR.RolledDice();
string NumberName;
string NumberNameTwo;
string sum;
string[] SecondNumberNames;
SecondNumberNames = new string[12] { "One", "Two", "Three", "Four", "Five", "Six", "seven", "eight", "Nine", "ten", "eleven", "twelve"};
NumberName = SecondNumberNames[seconddiceroll - 1];
NumberNameTwo = SecondNumberNames[diceroll - 1];
sum = SecondNumberNames[(diceroll + seconddiceroll) - 1];
Console.WriteLine("{0} Plus {1} Equals {2} ", NumberName, NumberNameTwo, sum);
}
答案 0 :(得分:0)
您只需将样式对象添加到ol.format.KML();
即可var source = new ol.source.Vector({
url: 'city.kml',
format: new ol.format.KML({
projection: 'EPSG:3857',
extractStyles: false
})
});
function styleFunction(feature) {
var style = new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'red',
width: 4
})
})
return [style];
}
var layer = new ol.layer.Vector({
source: source,
style: styleFunction
});
map.addLayer(layer);