jsp页面使用百度地图定位

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010741376/article/details/47338993

css样式:

<style type="text/css">
    *{margin:0;padding:0;}
.theme-buy{margin-top:7%;text-align:center;}
.theme-signin{font-size:15px;}
.theme-popover-mask{z-index:1;position:absolute;left:0;top:0;width:100%;height:100%;background:#000;opacity:0.5;filter:alpha(opacity=50);-moz-opacity:0.5;display:none;}
.theme-popover{z-index:9;position:absolute;top:50%;left:50%;width:880px;height:400px;margin:-180px 0 0 -330px;border-radius:5px;border:solid 2px #e4e4e4;background-color:#fff;display:none;box-shadow:0 0 10px #666;background:#fff;}
.theme-poptit{border-bottom:1px solid #ddd;padding:12px;position:relative;height:24px;}
.theme-poptit .close{float:right;color:#999;padding:5px;margin:-2px -5px -5px;font:bold 14px/14px simsun;text-shadow:0 1px 0 #ddd}
.theme-poptit .close:hover{color:#444;}
.theme-popbod{width:600px;height:300px;}
 
#allmap{width:880px;height:400px;}
</style>

js代码:

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=GXkbjcszaqwT3Wqq7piaAEeu"></script>
    <script type="text/javascript" src="<%=path%>/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function($){
 
    $('.theme-login').click(function(){
        $('.theme-popover-mask').show();
        $('.theme-popover-mask').height($(document).height());
        $('.theme-popover').show();
        
        var Longitude=113.45;
	var Latitude=23.02;
        
        var map = new BMap.Map("allmap");
        map.centerAndZoom(new BMap.Point(Longitude, Latitude), 14);
        map.enableScrollWheelZoom(true);//缩放
        var new_point=new BMap.Point(Longitude,Latitude);

        var myIcon = new BMap.Icon("<%=path%>/image/position.png", new BMap.Size(24,24));
        var marker1 = new BMap.Marker(new_point,{icon:myIcon});  // 创建标注
        map.addOverlay(marker1);              // 将标注添加到地图中
        map.panTo(new_point);
        
        
         
    });
    $('.theme-poptit .close').click(function(){
        $('.theme-popover-mask').hide();
        $('.theme-popover').hide();
    });
    $('.theme-popover-mask').click(function(){
    $('.theme-poptit .close').click();
});
 
});
</script>
HTML:

<body>
     <div class="theme-buy">
    <a class="theme-login" href="javascript:;">点击查看效果</a>
</div>
 
<div class="theme-popover-mask"></div>
 
<div class="theme-popover">
    <div class="theme-poptit">
        <a href="javascript:;" title="关闭" class="close" style="text-decoration: none;">×</a>
        <h3>地图定位</h3>
    </div>
    <div class="theme-popbod">
        <div id="allmap"></div>
    </div>
</div>
</body>
源码Demo下载:http://download.csdn.net/detail/u010741376/8973469

上一篇:We wear culture:Google 艺术与文化项目带你探秘穿在身上的文化


下一篇:.NET平台开源项目速览(9)软件序列号生成组件SoftwareProtector介绍与使用