You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mapsui内存图层点要素未全部渲染问题排查求助

问题:Mapsui地图大量点要素未渲染

我正在开发一款使用Mapsui的应用,目标是在地图上显示一系列附带信息的点要素。为此参考了Mapsui官方示例(分类:Info,示例:Single Callout),但实现测试后发现大量点未被渲染。

调试应用后确认存储点的图层始终保持不变(该图层为最终待显示图层,数据状态正常),但渲染时并非所有点都能被呈现。以下是相关代码:

图层创建方法

private MemoryLayer CreatePointLayer(List<GeoPoint> points)
{
    return new MemoryLayer
    {
        Name = "Incidencias",
        IsMapInfoLayer = true,
        Features = new MemoryProvider(SetFeaturesForPoints(points)).Features,
        Style = SymbolStyles.CreatePinStyle(symbolScale: 0.7),
    };
}

要素自定义方法

private IEnumerable<IFeature> SetFeaturesForPoints(List<GeoPoint> points)
{
    if (points != null)
    {
        return points.Select(p =>
        {
            var feature = new PointFeature(SphericalMercator.FromLonLat((double)p.Longitude, (double)p.Latitude).ToMPoint());
            Incidencia incidencia = IncidenciasSingleton.Instance.GetIncidencias().Where(incidencia => incidencia.Identificador == p.IncidenciaIdent).FirstOrDefault();

            feature["Título"] = incidencia.Titulo;
            feature["Fecha del incidente"] = incidencia.FechaIncidente;
            feature["Incidente cerrado"] = incidencia.IncidenteCerrado;
            feature["Última actualización"] = incidencia.UltimaActualizacion;
            feature.Styles.Add(CreateCalloutStyle(feature.ToStringOfKeyValuePairs()));
            feature["Enlace"] = incidencia.Enlace;

            return feature;
        });
    }

    return null;
}

地图配置方法

public Task<Mapsui.Map> ConfigureMap(ILayer layer)
{
    _mapControl.Map = new Mapsui.Map();
    _mapControl.Map.Layers.Add(OpenStreetMap.CreateTileLayer());
    _mapControl.Map.Layers.Add(layer);
    _mapControl.Map.Navigator.RotationLock = true;
    return Task.FromResult(_mapControl.Map);
}

更新:问题根源并非Mapsui,而是点数据本身存在重复,Mapsui实际渲染是正常的。


内容的提问来源于stack exchange,提问作者Jose Maria

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 07:00:04