使用 Mapsui 显示线串和轨迹点
Display Linestring and Trackpoints with Mapsui
我的目的是在地图上用 Mapsui (wpf) 显示 gps 轨迹和相应的轨迹点。我尝试了以下代码。结果是显示了蓝色线串(ok),红色轨迹点(ok)但是出于任何原因你会看到非常大的白色轨迹点,我不希望它们出现在地图上而且我不知道在哪里白点来自。知道我做错了什么吗?
protected ILayer CreateLineStringLayer(String name, List<GeoWaypoint> geoWaypoints)
{
var lineString = new LineString();
List<Feature> featureList = new List<Feature>();
IStyle pointStyle = new SymbolStyle()
{
SymbolScale = 0.30,
Fill = new Brush(Mapsui.Styles.Color.FromString("Red"))
};
foreach (var wp in geoWaypoints)
{
var point = SphericalMercator.FromLonLat(wp.Longitude, wp.Latitude);
lineString.Vertices.Add(point);
var p2 = SphericalMercator.FromLonLat(wp.Longitude, wp.Latitude);
var pointFeature = new Feature();
pointFeature.Geometry = p2;
pointFeature.Styles.Add(pointStyle);
featureList.Add(pointFeature);
}
IStyle linestringStyle = new VectorStyle()
{
Fill = null,
Outline = null,
Line = { Color = Mapsui.Styles.Color.FromString("Blue"), Width = 4 }
};
Feature lineStringFeature = new Feature()
{
Geometry = lineString
};
lineStringFeature.Styles.Add(linestringStyle);
featureList.Add(lineStringFeature);
MemoryProvider memoryProvider = new MemoryProvider(featureList);
return new MemoryLayer
{
DataSource = memoryProvider,
Name = name
};
}
所有对答案感兴趣的人
return new MemoryLayer
{
DataSource = memoryProvider,
Name = name ,
Style = null
};
您需要将 Memorylayer 的 Style 值设置为 null
我的目的是在地图上用 Mapsui (wpf) 显示 gps 轨迹和相应的轨迹点。我尝试了以下代码。结果是显示了蓝色线串(ok),红色轨迹点(ok)但是出于任何原因你会看到非常大的白色轨迹点,我不希望它们出现在地图上而且我不知道在哪里白点来自。知道我做错了什么吗?
protected ILayer CreateLineStringLayer(String name, List<GeoWaypoint> geoWaypoints)
{
var lineString = new LineString();
List<Feature> featureList = new List<Feature>();
IStyle pointStyle = new SymbolStyle()
{
SymbolScale = 0.30,
Fill = new Brush(Mapsui.Styles.Color.FromString("Red"))
};
foreach (var wp in geoWaypoints)
{
var point = SphericalMercator.FromLonLat(wp.Longitude, wp.Latitude);
lineString.Vertices.Add(point);
var p2 = SphericalMercator.FromLonLat(wp.Longitude, wp.Latitude);
var pointFeature = new Feature();
pointFeature.Geometry = p2;
pointFeature.Styles.Add(pointStyle);
featureList.Add(pointFeature);
}
IStyle linestringStyle = new VectorStyle()
{
Fill = null,
Outline = null,
Line = { Color = Mapsui.Styles.Color.FromString("Blue"), Width = 4 }
};
Feature lineStringFeature = new Feature()
{
Geometry = lineString
};
lineStringFeature.Styles.Add(linestringStyle);
featureList.Add(lineStringFeature);
MemoryProvider memoryProvider = new MemoryProvider(featureList);
return new MemoryLayer
{
DataSource = memoryProvider,
Name = name
};
}
所有对答案感兴趣的人
return new MemoryLayer
{
DataSource = memoryProvider,
Name = name ,
Style = null
};
您需要将 Memorylayer 的 Style 值设置为 null