阅读:1644回复:0
[求助]mapxtreme for java4.7 在servlet里打开现有页面的问题
<P>在servlet里有下面的方法,通过鼠标点击一个点(这个点代表一棵树,城市的里树),并把该点渲染,然后打开一个jsp页面,显示这个树的详细信息。现在我不能打开这个详细信息页,请给予帮助!谢谢!</P>
<P>private void SelectElement(MapJ myMap, HttpServletRequest req,<BR> HttpServletResponse res, DoublePoint newPoint) {</P> <P> try {<BR>// res.setContentType("text/html");<BR>// PrintWriter out = res.getWriter();<BR> ArrayList resList = new ArrayList();<BR> ArrayList<String> tt = new ArrayList<String>();<BR> tt.add("dd");<BR> FeatureSet fSet = null;<BR> FeatureLayer tLayer = (FeatureLayer) myMap.getLayers().get(<BR> "树木");<BR> // 判断图层是否可选,如果不可选,设置其属性可选<BR> if (!tLayer.isSelectable()) {<BR> tLayer.setSelectable(true);<BR> }<BR> // Create a SelectionTheme<BR> SelectionTheme selTheme = (SelectionTheme) tLayer.getThemeList()<BR> .getTheme("PointSel");<BR> // Create a Selection object, and add the selected features<BR> Selection sel = new Selection();<BR> // 判断该选中专题图层存在不存在<BR> if (selTheme == null) {<BR> selTheme = new SelectionTheme("PointSel");<BR> } else {<BR> // 删除以上操作已经删除的theme列表<BR> tLayer.getThemeList().remove(selTheme);<BR> selTheme = new SelectionTheme("PointSel");<BR> }<BR> // 保存图元属性<BR> ArrayList colList = new ArrayList();<BR> colList.add("treecode");// 增加想要取回的数据列<BR> try {<BR> // Select a feature at the specified location<BR> fSet = tLayer.searchAtPoint(colList, newPoint, null);<BR> // Assign the display style of the SelectionTheme<BR> Rendition rend = RenditionImpl.getDefaultRendition();<BR> rend.setValue(Rendition.SYMBOL_MODE, Rendition.SymbolMode.FONT);<BR> rend.setValue(Rendition.FONT_FAMILY, "MapInfo Symbols");<BR> rend.setValue(Rendition.FONT_SIZE, 9);<BR> rend.setValue(Rendition.SYMBOL_STRING, String<BR> .valueOf((char) 35));<BR> rend.setValue(Rendition.SYMBOL_FOREGROUND, Color.RED);<BR> Feature ftr = null;<BR> while ((ftr = fSet.getNextFeature()) != null) {<BR> sel.add(ftr);<BR>// resList.add(ftr.getAttribute(colList.indexOf("BDZ_CODE")));<BR>// resList.add(ftr.getAttribute(colList.indexOf("POLE_ID")));<BR>// if (ftr.getAttribute(0) != null) {<BR>// resList.add(ftr.getAttribute(0).toString());<BR>// }<BR> code=ftr.getAttribute(colList.indexOf("treecode")).toString();<BR> req.getSession().setAttribute("code", code);<BR> //getServletContext().getRequestDispatcher("/TreeInfo/TreeInfoDetail.jsp?treeid=" + Treeid + ";;thid=" + tid + "").forward(req,res);<BR> }<BR>// for (int j = 0; j < resList.size(); j++) {<BR>// System.out.println(resList.get(j).toString());<BR>// }<BR> selTheme.setRendition(rend);<BR> // Assign the Selection object to the SelectionTheme<BR> selTheme.setSelection(sel);<BR> // Add the SelectionTheme to the layer's list of themes<BR> tLayer.getThemeList().add(selTheme);<BR> } catch (Exception e) {<BR> System.out.println("error");<BR> } finally {<BR> if (fSet != null) {<BR> fSet.dispose();<BR> fSet = null;<BR> }<BR> }<BR> // myMap.setCenter(newpoint);<BR> req.getSession().setAttribute("mapJ", myMap);<BR> <BR> resImg(myMap, res);<BR> <BR> } catch (Exception e) {<BR> System.out.println("选择图元报错");<BR> }<BR> }</P> |
|