Capa de mapa dinámico con MapScript C # de Mapserver
Pregunta
Estoy desarrollando una aplicación web que mostrará la ubicación de un proyecto en un mapa. Tengo esta función para agregar los datos que quiero mostrar a una capa de mapa.
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);
}
}
Esta fue una recomendación de los chicos de #mapserver IRC Channel. ¡Pero no funciona! ¿Puede alguien ayudarme a averiguar por qué no se muestran los puntos?
Solución
¿Creas un classObj y styleObj para tu capa?
Aquí está mi ejemplo de código:
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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow