jsp 百度地图离线使用_百度地图定位JSP代码

本文介绍了如何在JSP中离线使用百度地图,通过JavaScript实现地图的初始化、中心点定位、标注功能。用户可以手动设置经纬度,并通过拖动气泡来标注企业位置,保存经纬度信息。
摘要由CSDN通过智能技术生成

html{height:100%}

body{height:100%;margin:0px;padding:0px}

#container{height:100%}

.map_header{height:100px;position:relative;border-bottom:#ccc solid 1px;}

.map_header a{position:absolute;display:block;height:50px;line-height:50px;bottom:10px;left:10px;font-size:12px;background:url(images/markA.png) no-repeat;padding-left:17px;color:#2A2A81;}

.map_header p{position:absolute;right:10px;height:60px;font-size:12px;line-height:20px;padding:5px;background:#FDFCC3;border:#E5CE5C solid 1px;border-radius:10px;color:#ff0000;}

window.οnlοad=function(){

var isMaintain='${ent.isMaintain}';

if(isMaintain=="true"){

document.getElementById("show").style.display="";

}else{

document.getElementById("show").style.display="none";

}

}

  位置标注

  手动设置经纬度

提示:若要重新标注企业位置,则按以下步骤操作:
1、点击左上角“位置标注”
2、拖动气泡,当气泡拖动到您企业所在的位置后,松开鼠标

纬度:
经度:

举例说明:
经纬度坐标“35.232851,109.9333”,其中 35.232851表示纬度,109.9333表示经度

$(function(){

$(".sdsz").click(function(){

$("#aaaa").show();

});

$("#close").click(function(){

$("#aaaa").hide();

return false;

})

$("#save").click(function(){

var entId = document.getElementById("entId").value;

var stjd=document.getElementById("stjd").value;

var stwd=document.getElementById("stwd").value;

updateJwd(entId,stjd,stwd);

})

});

var map = new T.Map("container"); //初始化地图对象

map.centerAndZoom(new T.LngLat(120.059538,28.69158), 13);//定义一个中心点坐标

//创建缩放平移控件对象

control = new T.Control.Zoom();

//添加缩放平移控件

map.addControl(control);

var marker =null;

var icon = new T.Icon({

iconUrl: "images/markA.png",

iconSize: new T.Point(19, 27),

iconAnchor: new T.Point(10, 25)

});

// 创建地图实例

var jd = $("#jd").val();

var wd = $("#wd").val();

var marker =null;

if ( (jd.length !=0 && jd !='null' )||( wd.length !=0 && wd !='null')){

var point= new T.LngLat(jd,wd);

marker = new T.Marker(point, {icon:icon});

map.addOverLay(marker);

marker.addEventListener("click", function(){

var opts = {

width : 250, // 信息窗口宽度

height: 100, // 信息窗口高度

enableMessage:false //不允许发送短信

};

var name= document.getElementById("entName").value;

var infoWin = new T.InfoWindow();

infoWin.setLngLat(point);

infoWin.setContent("企业名称:"+name, opts);

map.addOverLay(infoWin);

});

marker.addEventListener("dragend", function(e){

if(window.confirm("确定标记该处?")){

marker.disableDragging();

document.getElementById("jd").value = e.lnglat.getLng();

document.getElementById("wd").value = e.lnglat.getLat();

var entId = document.getElementById("entId").value;

updateMark(entId,e.lnglat.getLng(),e.lnglat.getLat());

marker.enableDragging();

}

});

}else{

}

function updateMark(id,jd,wd){

$.post("updateMark.action",

{

id:id,

longitude:jd,

latitude:wd

},

function(status){

window.top.dorado.widget.NotifyTipManager.notify('标记成功!');

window.location.reload(true);

});

}

function updateJwd(id,jd,wd){

$.post("updateMark.action",

{

id:id,

longitude:jd,

latitude:wd

},

function(status){

window.top.dorado.widget.NotifyTipManager.notify('经纬度保存成功!');

window.location.reload(true);

});

}

function biaoji(){

if (marker != null){

marker.enableDragging();

}else{

marker= new T.Marker(new T.LngLat(120.059538,28.69158), {icon:icon});

map.addOverLay(marker);

marker.enableDragging();

marker.addEventListener("click", function(){

var opts = {

width : 250, // 信息窗口宽度

height: 100, // 信息窗口高度

enableMessage:false //不允许发送短信

};

var name= document.getElementById("entName").value;

var infoWin = new T.InfoWindow();

infoWin.setLngLat(new T.LngLat(120.059538,28.69158));

infoWin.setContent("企业名称:"+name, opts);

map.addOverLay(infoWin);

});

marker.addEventListener("dragend", function(e){

if(window.confirm("确定标记该处?")){

marker.disableDragging();

document.getElementById("jd").value = e.lnglat.getLng();

document.getElementById("wd").value = e.lnglat.getLat();

var entId = document.getElementById("entId").value;

updateMark(entId,e.lnglat.getLng(),e.lnglat.getLat());

}

});

}

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值