jsp 百度地图离线使用_jsp页面使用百度地图定位

这篇博客介绍了如何在JSP页面上使用百度地图API进行离线定位。通过CSS样式设置地图容器,JS代码加载地图并设置中心点,实现地图的显示和缩放功能。点击按钮触发地图展示,利用BMap.Point创建坐标点,添加标注,并实现点击关闭地图的功能。提供了源码Demo下载链接供读者实践。
摘要由CSDN通过智能技术生成

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;}

js代码:

$(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("/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();

});

});

HTML:

×

地图定位

源码Demo下载:http://download.csdn.net/detail/u010741376/8973469

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值