|
@@ -57,27 +57,23 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
- <label class="col-sm-3 control-label">经度:</label>
|
|
|
+ <label class="col-sm-3 control-label" style="cursor: pointer" onclick="choseLatLng()"><a>经度:</a></label>
|
|
|
<div class="col-sm-8">
|
|
|
<input name="lng" class="form-control" id="lng" type="text" th:field="*{lng}" readonly>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
- <label class="col-sm-3 control-label">纬度:</label>
|
|
|
+ <label class="col-sm-3 control-label" style="cursor: pointer" onclick="choseLatLng()"><a>纬度:</a></label>
|
|
|
<div class="col-sm-8">
|
|
|
<input name="lat" class="form-control" id="lat" type="text" th:field="*{lat}" readonly>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
- <label class="col-sm-3 control-label">地址:</label>
|
|
|
+ <label class="col-sm-3 control-label" style="cursor: pointer" onclick="choseLatLng()"><a>地址:</a></label>
|
|
|
<div class="col-sm-8">
|
|
|
<input name="address" class="form-control" id="address" type="text" th:field="*{address}" readonly>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <button type="button" id="open">
|
|
|
- 点击显示地图获取地址经纬度
|
|
|
- </button>
|
|
|
- <div id='allmap' style='width: 60%; height: 60%; position: absolute; display: none'></div>
|
|
|
</form>
|
|
|
</div>
|
|
|
<th:block th:include="include :: footer" />
|
|
@@ -102,64 +98,26 @@
|
|
|
$("#"+selectId).html(html);
|
|
|
});
|
|
|
}
|
|
|
- </script>
|
|
|
- <script type="text/javascript">
|
|
|
- document.getElementById('open').onclick = function () {
|
|
|
- if (document.getElementById('allmap').style.display == 'none') {
|
|
|
- document.getElementById('allmap').style.display = 'block';
|
|
|
- } else {
|
|
|
- document.getElementById('allmap').style.display = 'none';
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- var map = new BMap.Map("allmap");
|
|
|
- var geoc = new BMap.Geocoder(); //地址解析对象
|
|
|
- var markersArray = [];
|
|
|
- var geolocation = new BMap.Geolocation();
|
|
|
-
|
|
|
-
|
|
|
- var point = new BMap.Point(116.404412, 39.914714);
|
|
|
- map.centerAndZoom(point, 12); // 中心点
|
|
|
- geolocation.getCurrentPosition(function (r) {
|
|
|
- if (this.getStatus() == BMAP_STATUS_SUCCESS) {
|
|
|
- var mk = new BMap.Marker(r.point);
|
|
|
- map.addOverlay(mk);
|
|
|
- map.panTo(r.point);
|
|
|
- map.enableScrollWheelZoom(true);
|
|
|
- }
|
|
|
- else {
|
|
|
- alert('failed' + this.getStatus());
|
|
|
- }
|
|
|
- }, {enableHighAccuracy: true})
|
|
|
- map.addEventListener("click", showInfo);
|
|
|
-
|
|
|
-
|
|
|
- //清除标识
|
|
|
- function clearOverlays() {
|
|
|
- if (markersArray) {
|
|
|
- for (i in markersArray) {
|
|
|
- map.removeOverlay(markersArray[i])
|
|
|
+ function choseLatLng() {
|
|
|
+ var options = {
|
|
|
+ title: '选择摄像头位置',
|
|
|
+ url: prefix + "/choseParcel",
|
|
|
+ callBack: function (index, layero){
|
|
|
+ var body = layer.getChildFrame('body', index);
|
|
|
+ var lng = body.find('#lng').val();
|
|
|
+ var lat = body.find('#lat').val();
|
|
|
+ var address = body.find('#address').val();
|
|
|
+ if (lng.length === 0 || lat.length === 0) {
|
|
|
+ $.modal.alertWarning("请选择摄像头位置");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $("#lng").val(lng);
|
|
|
+ $("#lat").val(lat);
|
|
|
+ $("#address").val(address);
|
|
|
+ layer.close(index);
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- //地图上标注
|
|
|
- function addMarker(point) {
|
|
|
- var marker = new BMap.Marker(point);
|
|
|
- markersArray.push(marker);
|
|
|
- clearOverlays();
|
|
|
- map.addOverlay(marker);
|
|
|
- }
|
|
|
- //点击地图时间处理
|
|
|
- function showInfo(e) {
|
|
|
- document.getElementById('lng').value = e.point.lng;
|
|
|
- document.getElementById('lat').value = e.point.lat;
|
|
|
- geoc.getLocation(e.point, function (rs) {
|
|
|
- var addComp = rs.addressComponents;
|
|
|
- var address = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber;
|
|
|
- document.getElementById('allmap').style.display = 'none';
|
|
|
- document.getElementById('address').value = address;
|
|
|
- });
|
|
|
- addMarker(e.point);
|
|
|
+ };
|
|
|
+ $.modal.openOptions(options);
|
|
|
}
|
|
|
</script>
|
|
|
</body>
|