⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jsp1.jsp

📁 jsp写的电子地图部分控件,编写好的java类和页面
💻 JSP
字号:
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="com.mapinfo.mapj.MapJ,
                 com.mapinfo.mapxtreme.client.EncodedImageRenderer,
                 com.mapinfo.xmlprot.mxtj.ImageRequestComposer,
                 com.mapinfo.xmlprot.MapImageResponse,
                 com.mapinfo.graphics.Rendition,
                 com.mapinfo.graphics.RenditionImpl,
                 com.mapinfo.util.DoublePoint,
                 com.mapinfo.util.DoubleRect,
                 com.mapinfo.util.Overlay,
                 com.mapinfo.theme.OverrideTheme,
                 com.mapinfo.unit.LinearUnit"%>
<jsp:useBean id="imageBean" scope="request" class="sample.ImageBean">
</jsp:useBean>
<%
 String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
 String sConnStr = "jdbc:odbc:location";
 //       String tDBDriver = "OracleDriver";
 //       String tConnStr = "jdbc:oracle:thin:";
 //       String tDBName = "@localhost:1521:jcxt";
 //       String tUid = "jjbweb";
 //       String tPwd = "jjbweb";
 Connection conn = null;
 Statement stmt = null;
 ResultSet rs = null;
 String query = null;
 String  x = null, y = null;
 DoublePoint currentPoint = null;
 DoublePoint currentPointOfScreen = null;
 String terminalID = null;
 //ImageBean imageBean = null;
 String beginCmd = null;
 String rootPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";

    imageBean.init(pageContext.getServletContext(),pageContext.getServletConfig());
    terminalID = request.getParameter("Tid");
    if (terminalID == null){
      terminalID = "001";
    }
    beginCmd = request.getParameter("beginCmd");
    //HttpSession session = request.getSession(true);

    try {
       Class.forName(sDBDriver);
       conn = DriverManager.getConnection(sConnStr);
       stmt = conn.createStatement();
       query = "Select id1, x,y FROM t1 WHERE id='"+terminalID+"'";

       rs = stmt.executeQuery(query);
       if(rs.next()){
         x = rs.getString(2);
         y = rs.getString(3);
       }



       currentPoint = new DoublePoint((new Double(x)).doubleValue(), new Double(y).doubleValue());
       DoublePoint centerPoint = null;
       MapJ map = new MapJ();


       if(session.getAttribute("centerPoint")==null || (beginCmd != null && !beginCmd.equals(""))){ //if user submit query on specific receiver

         //centerPoint = new DoublePoint(currentPoint); //define the map center point of the current location of the receiver
         session.setAttribute("centerPoint",currentPoint);//save centerpoint
         imageBean.setCenterPoint(currentPoint.x,currentPoint.y); //set center point
         imageBean.setZoom(2000); //set zoom
         imageBean.createOverlayMap();//create grid image

         out.print("parent.frames['main'].location.reload();"); //refresh the page containing the map
         session.setAttribute("imageUrl",rootPath+imageBean.getImageUrl()); // save image name

       }

       else{
         centerPoint = (DoublePoint)session.getAttribute("centerPoint");

       }

       map.setCenter(centerPoint);
       map.setDistanceUnits(LinearUnit.mile);
       map.setZoom(2000);
       currentPointOfScreen = map.transformNumericToScreen(currentPoint);


       if(!new DoubleRect(0, 0, 640, 480).contains(currentPointOfScreen)){
         centerPoint = currentPoint; //define the map center point of the current location of the receiver
         session.setAttribute("centerPoint",currentPoint);//save centerpoint
         imageBean.setCenterPoint(currentPoint.x,currentPoint.y); //set center point
         imageBean.setZoom(2000); //set zoom
         imageBean.createOverlayMap();//create grid image

         out.print("parent.frames['main'].location.reload();"); //refresh the page containing the map
         session.setAttribute("imageUrl",rootPath+imageBean.getImageUrl()); // save image name

       }

       out.print("parent.main.mobileTarget.STYLE=\"position: absolute; left: "+currentPointOfScreen.x+"; top: "+currentPointOfScreen.y+";\";");
       out.print("parent.main.document.baseMap.SRC=\""+session.getAttribute("imageUrl")+"\";");

       //out.print("parent.frames['main'].location.href='content.jsp';");


 }
 catch(SQLException ex){
            System.err.println("sql.executeQuery: " + ex.getMessage());
 }
 catch(Exception ex){
            System.err.println("executeQuery: " + ex.getMessage());
 }
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -