2009-05-05 18 views
0

我正在開發一個Web應用程序,它將顯示一個項目在地圖中的位置。我有這個功能添加我想要顯示到地圖圖層的數據。動態地圖圖層與Mapserver的C#MapScript

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頻道的傢伙們的推薦。但它不起作用!有人可以幫助弄清楚爲什麼點不顯示?

回答

1

您是否爲圖層創建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