Commit 8880e7f8 authored by liyuanhong's avatar liyuanhong

地图工具,正价了gps定位

parent e316dd9d
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
width:90px; width:90px;
text-align:right; text-align:right;
} }
#container:hover{
cursor:crosshair;
}
</style> </style>
<div id="container2" style="width:85%;min-height:750px;float:left;_background:pink;"> <div id="container2" style="width:85%;min-height:750px;float:left;_background:pink;">
{% block content_1 %} {% block content_1 %}
...@@ -38,8 +41,14 @@ ...@@ -38,8 +41,14 @@
<a href="#" class="btn btn-default" role="button" id="ctrArea2" onclick="ctrAreaShow(this)">录制轨迹</a> <a href="#" class="btn btn-default" role="button" id="ctrArea2" onclick="ctrAreaShow(this)">录制轨迹</a>
<a href="#" class="btn btn-default" role="button" id="ctrArea3" onclick="ctrAreaShow(this)">查询轨迹</a> <a href="#" class="btn btn-default" role="button" id="ctrArea3" onclick="ctrAreaShow(this)">查询轨迹</a>
</div> </div>
<div id="ctrArea_1" style="width:400px;height:250px;background:white;z-index:50;position:absolute;top:160px;right:40px;border-radius:5px;display:none;" class="btn-group btn-group-justified" role="group"> <div id="ctrArea_1" style="width:400px;height:120px;background:white;z-index:50;position:absolute;top:160px;right:40px;border-radius:5px;display:none;" class="btn-group btn-group-justified" role="group">
111 <div style="border-width: 1px;border-bottom: 1px solid #eee;margin: 10px;padding-bottom: 5px;">
<label>经 ,纬 度 :</label><input id="toLngLat" type="text" class="form-control" value="106.54041,29.40268" style="width:200px;">
<button type="button" class="btn btn-default" onclick="setposition()">定位</button>
</div>
<div style="border-width: 1px;border-bottom: 1px solid #eee;margin: 10px;padding-bottom: 5px;">
<label>当前经纬度:</label><input id="curLngLat" type="text" class="form-control" value="106.587436,29.565099" style="width:200px;"> <label style="font-size:10px;">点击地图自动获取</label>
</div>
</div> </div>
<div id="ctrArea_2" style="width:400px;height:250px;background:white;z-index:50;position:absolute;top:160px;right:40px;border-radius:5px;display:none;" class="btn-group btn-group-justified" role="group"> <div id="ctrArea_2" style="width:400px;height:250px;background:white;z-index:50;position:absolute;top:160px;right:40px;border-radius:5px;display:none;" class="btn-group btn-group-justified" role="group">
222 222
...@@ -57,17 +66,23 @@ ...@@ -57,17 +66,23 @@
<script> <script>
var map = null; var map = null;
var curShow = ""; var curShow = "";
//控制点击地图的触发事件
var clickType = 0;
var marker = undefined; //单个点标记
//加载地图 //加载地图
(function(){ (function(){
map = new AMap.Map('container', { map = new AMap.Map('container', {
zoom:12,//级别 zoom:13,//级别
center: [106.587436, 29.565099] center: [106.587436, 29.565099]
}); });
})(); })();
//处理地图点击事件 //处理地图点击事件
map.on('click', function(ev) { map.on('click', function(ev) {
var lnglat = ev.lnglat; if(clickType == 0){
console.log(lnglat); var lnglat = ev.lnglat;
var lnglattxt = lnglat["lng"] + "," + lnglat["lat"];
$("#curLngLat").val(lnglattxt);
}
}); });
function ctrAreaShow(e){ function ctrAreaShow(e){
var cliId = $(e).attr("id"); var cliId = $(e).attr("id");
...@@ -103,6 +118,20 @@ ...@@ -103,6 +118,20 @@
} }
} }
} }
//设置地图中心点,移动地图
function setposition(){
if(marker != undefined){
map.remove(marker);
}
var theGps = $("#toLngLat").val().split(",")
marker = new AMap.Marker({
position: new AMap.LngLat(theGps[0],theGps[1]), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
title: '定位'
});
map.setCenter(theGps);
map.add(marker);
}
</script> </script>
{% endblock %} {% endblock %}
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment