|
在MapXtreme如何让查询选中的目标高亮显示 有两种方法,一种是换图的 一种是不换图的。 换图就是在服务器端生成高亮点的图片,传给客户端。这么做的优点在于简单。缺点在于服务器负载量大。 不换图法是服务器将高亮点的屏幕坐标传到客户端,在客户端采用定时器法绘制该点坐标。这么做的好处是通讯量小,但实现起来需要程序员的水平 以下代码供参考 // 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);
|