有两种方法,一种是换图的一种是不换图的。
换图就是在服务器端生成高亮点的图片,传给客户端。这么做的优点在于简单。缺点在于服务器负载量大。
不换图法是服务器将高亮点的屏幕坐标传到客户端,在客户端采用定时器法绘制该点坐标。这么做的好处是通讯量小,但实现起来需要程序员的水平
以下代码供参考
// Given a Layer object and x- and y-coordinates, this method selects the layer's feature(s) at the specified location, and creates a SelectionTheme to display the selected features in red.
// Assume layer as a Layer object
Vector v = new Vector();
DoublePoint dp = new DoublePoint(x, y);
FeatureSet fs = null;
// Select a feature at the specified location
fs = layer.searchAtPoint(v, dp, null);
// 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
layer.getThemeList().add(selTheme);
博客介绍了服务器高亮点显示的两种方法。换图法在服务器端生成高亮点图片传给客户端,优点是简单,缺点是服务器负载大;不换图法是服务器传坐标到客户端,客户端用定时器绘制,好处是通讯量小,但对程序员水平要求高,还给出了相关代码示例。
429

被折叠的 条评论
为什么被折叠?



