繁体   English   中英

使用Mapserver的C#MapScript的动态地图层

[英]Dynamic map layer with Mapserver's C# MapScript

我正在开发一个Web应用程序,它将在地图中显示项目的位置。 我有此功能将要显示的数据添加到地图图层。

protected void AgregarPunto(DataTable result)
{
    layerObj thislayer = util.MSMap.getLayerByName("poi");

    foreach (DataRow dr in result.Rows)
    {
        shapeObj shp = new shapeObj(mapscript.MS_SHP_POINTM);
        shp = shapeObj.fromWKT(dr["the_geom"].ToString());

        thislayer.addFeature(shp);
    }
}

这是来自#mapserver IRC频道的人员的推荐。 但这不起作用! 有人可以帮忙弄清楚为什么不显示要点吗???

您是否为图层创建classObj和styleObj?

这是我的代码示例:

myLayer.type = OSGeo.MapServer.MS_LAYER_TYPE.MS_LAYER_LINE;
myLayer.status = 1;
myLayer.symbolscaledenom = 1; 

// Create a mapping class
OSGeo.MapServer.classObj myClass = new OSGeo.MapServer.classObj(myLayer);

// Create a style
OSGeo.MapServer.styleObj style = new OSGeo.MapServer.styleObj(myClass);

// unitColor = new Color(12, 34, 56);
int red = Convert.ToInt32(unitColor.R);
int green = Convert.ToInt32(unitColor.G);
int blue = Convert.ToInt32(unitColor.B);

style.color.setRGB(red, green, blue);

style.outlinecolor.setRGB(255, 255, 255);
//style.symbol = _map.symbolset.index("circle");  // Here '_map' is an instance of mapObj, this line is not strictly necessary 

style.size = 10;
style.minsize = 3; // Change this to your needs

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM