|
2004-05-18
- 改变区域的颜色:做面雨量时,需要根据雨量填充区域的颜色
//图层tab名称为yc_area,包含一个field:road,包含一个图元:area_rd1.
myMap = new MapJ();
myMap.loadMapDefinition("e:/open/maps/yc_area.mdf");
//------------for adding a buffer------------------------------------
ArrayList columns = new ArrayList();
Attribute att1 = new Attribute("area_rd1");
FeatureLayer parkLayer = (FeatureLayer)myMap.getLayers().get("yc_area");
FeatureSet fs = parkLayer.searchByAttribute(columns,"road",att1,null);
LabelProperties lprops = new LabelProperties();
// requires valid column name of layer
// also see setLabelColumn()
lprops.setLabelExpression("road");
// Toss the FeatureSet when done with it
//引用自uestcwlh
// Create a SelectionTheme
SelectionTheme selTheme = new SelectionTheme("PointSelection");
// Create a Selection object, and add the selected features
Selection sel = new Selection();
sel.add(fs);
// Assign the Selection object to the SelectionTheme
selTheme.setSelection(sel);
// Assign the display style of the SelectionTheme
Rendition rend =RenditionImpl.getDefaultRendition();
rend.setValue(Rendition.FILL, Color.red);
selTheme.setRendition(rend);
// Add the SelectionTheme to the layer's list of themes
parkLayer.getThemeList().add(selTheme);
//Add 2004-05-18
parkLayer.setSelectable(true);
Rendition rend = new RenditionImpl();
// Make the font 14 pts
rend.setValue(Rendition.FONT_SIZE, new Float(14));
// The weight should be greater than 0. 1.0 = normal, 2.0 = bold, etc.
rend.setValue(Rendition.FONT_WEIGHT, new Float(2));
// Make it a leaning garbage can
rend.setValue(Rendition.FONT_STYLE, Rendition.FontStyle.ITALIC);
// Indicate that we are using a font for the symbol
rend.setValue(Rendition.SYMBOL_MODE, Rendition.SymbolMode.FONT);
// The number 4 is the garbage can
rend.setValue(Rendition.SYMBOL_STRING, "4");
// Make the symbol yellow on a red background
rend.setValue(Rendition.SYMBOL_FOREGROUND, Color.yellow);
rend.setValue(Rendition.SYMBOL_BACKGROUND, Color.red);
rend.setValue(Rendition.FILL, Color.blue);
rend.setValue(Rendition.FILL_OPACITY, new Float(0.40));
2004-05-19
- mapXtreme java 4.7中处理mdf格式可能存在问题,最好采用gst格式,可以用mapinfo中的GeosetManager.exe将tab图层文件生成gst格式。Mapdemo范例不能显示电子地图,可能是这个原因造成的。采用mdf格式不能显示,gst格式即可显示。
- 今天实现面雨量的技术原型,在mapdemo的基础上进行测试,效果不错。
- 图层wh_area中包含wc_area、hk_area、hy_area三个面图元,程序将wc_area的底色改为red表示某一雨量范围、hk_area的底色改为cyan表示某一雨量范围,实际中需要根据不同的雨量情况对不同的图元进行面操作。
- 在servlet中增加一个surfaceRainFall
- 在mapevent.js中增加mapSurfaceRainFall
- 在maprequest中增加surfaceRainFall
- 没有对页面图标做改动,在最后一个放大图标中实现面底色的改动。
- 感谢原作者的辛勤努力的成果,使俺的demo能够向前推进一步;还有我的同事sunday_28在原型中做了不少的技术探讨。
- 谨献给mpxJ的广大同仁们。
- 鉴于对原作者的尊重,不公开其源码,只提供俺增加的部分,原型不过多讲究代码的规范性。代码段如下:
//在doGet中增加
if(rqutype != null && rqutype.equals("surfacerainfall"))
{
System.out.println("doGet surfaceRainFall");
mymap = initmap(request);
boundmap = initboundmap(request);
surfaceRainFall(mymap, request);
responseimg(mymap, response);
}
//增加一下的一个方法
private void surfaceRainFall(MapJ myMap, HttpServletRequest request)
{
try
{
System.out.println("call surfaceRainFall");
Double rainFall = new Double(request.getParameter("rainfall"));
//------------for adding a buffer------------------------------------
ArrayList columns = new ArrayList();
Attribute att1 = new Attribute("wc_area");
Attribute att2 = new Attribute("hk_area");
FeatureLayer parkLayer = (FeatureLayer)myMap.getLayers().get("wh_area");
FeatureSet fs = parkLayer.searchByAttribute(columns,"wh_area",att1,null);
LabelProperties lprops = new LabelProperties();
// Create a SelectionTheme
SelectionTheme selTheme = new SelectionTheme("PointSelection");
// Create a Selection object, and add the selected features
Selection sel = new Selection();
sel.add(fs);
// Assign the Selection object to the SelectionTheme
selTheme.setSelection(sel);
// Assign the display style of the SelectionTheme
Rendition rend =RenditionImpl.getDefaultRendition();
// The number wh is the garbage can
rend.setValue(Rendition.FILL, Color.red);
selTheme.setRendition(rend);
// Add the SelectionTheme to the layer's list of themes
parkLayer.getThemeList().add(selTheme);
parkLayer.setSelectable(true);
FeatureLayer parkLayer1 = (FeatureLayer)myMap.getLayers().get("wh_area");
FeatureSet fs1 = parkLayer.searchByAttribute(columns,"wh_area",att2,null);
LabelProperties lprops1 = new LabelProperties();
// Create a SelectionTheme
SelectionTheme selTheme1 = new SelectionTheme("PointSelection");
// Create a Selection object, and add the selected features
Selection sel1 = new Selection();
sel1.add(fs1);
// Assign the Selection object to the SelectionTheme
selTheme1.setSelection(sel1);
// Assign the display style of the SelectionTheme
Rendition rend1 =RenditionImpl.getDefaultRendition();
// The number wh is the garbage can
rend1.setValue(Rendition.FILL, Color.cyan);
selTheme1.setRendition(rend1);
// Add the SelectionTheme to the layer's list of themes
parkLayer1.getThemeList().add(selTheme1);
parkLayer1.setSelectable(true);
fs.dispose();
}
catch(Exception e)
{
e.printStackTrace();
}
}
其他
|