jsp在图片上添加标记点功能

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <!-- 引用公用部分 -->
    <%@include file="/header.jsp" %>
</head>
<body style="margin: 0;">
		<div  id="signX" >
		    <img usemap="#tMap" id="img" src="<%=basePath %>hazard/back/basegeneral/baserequest/showimagefirstpage.do" height="800" width="1600" onclick="imageClick(this)">
		    <map name="tMap" id="tMap">
    	
        <c:forEach items="${objList}" var="bpCoordinate" varStatus="st">
            <div style="
                    background-image:<c:if test="${bpCoordinate.statue == '42'}">url('<%=basePath %>assets/images/location.png')</c:if>
                    <c:if test="${bpCoordinate.statue == '43'}">url('<%=basePath %>assets/images/location1.png')</c:if>;
                    width: 30px; height: 30px;
                    left: ${bpCoordinate.xCoordinate}px; top:${bpCoordinate.yCoordinate}px;
                    position: fixed; "
                 onclick="show_del('标记详情','<%=basePath %>hazard/back/pictureMap/pictureInfo/list.do?dscoordinateId=${bpCoordinate.id}','1200','800')"
            >
            </div>
        </c:forEach>
    </map>
</div>
<div style="display: none">
    X:<input id="xxx" type="text" />  Y:<input id="yyy" type="text" />
</div>



<!-- 引用公用部门 -->
<%@include file="/bottom.jsp" %>
<script type="text/javascript">
    function cnvs_getCoordinates(e) {
        x = e.clientX;
        y = e.clientY;
    }

    function showContent() {
        $.sign.bindSign('#signx');
        $.get('<%=basePath%>hazard/back/pictureMap/pictureInfo/show.do',function (data) {
            var objList = data.objList;
            var mapData = [];
            $.each(objList,function (i,obj) {
                var tobj = {
                    m:obj.xCoordinate,
                    n:obj.yCoordinate
                };
                mapData.put(tobj);
                $.sign.loadingSign(mapData);
            });
        });
    }



    function imageClick(el) {
        mouseMove(event);
        var x = parseInt(document.getElementById('xxx').value)-el.offsetLeft;
        var y = parseInt(document.getElementById('yyy').value)-el.offsetTop;
        show_del('新增标记信息','<%=basePath%>hazard/back/pictureMap/pictureInfo/openEdit.do?id=00 &xCoordinate='+x+'&yCoordinate='+y,'900','700')
    }

    function mouseMove(event) {
        event = event || window.event;
        var mousePos = mousePosition(event);
        document.getElementById('xxx').value = mousePos.x;
        document.getElementById('yyy').value = mousePos.y;
    }

    function mousePosition(event){
        if(event.pageX || event.pageY){
            return {x:event.pageX, y:event.pageY};
        }
        return {
            x:event.clientX + document.body.scrollLeft - document.body.clientLeft,
            y:event.clientY + document.body.scrollTop  - document.body.clientTop
        };
    }

    function show_del(title,url,w,h){
        layer_show(title,url,w,h);
    }


</script>
</body>
</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值