diff --git a/admin/templates/css/metinfo.css b/admin/templates/css/metinfo.css index 99456a6..b110abd 100644 --- a/admin/templates/css/metinfo.css +++ b/admin/templates/css/metinfo.css @@ -1319,4 +1319,18 @@ li.village-list-item > p { background: rgba(206, 206, 206, 0.7); z-index: 9; display: none; +} + +@media (min-width: 992px) { + .modal-lgx { + max-width: 80%; + } + + .modal-fill-in .modal-dialog.modal-lg > * { + width: 80%; + } + + .h-500 { + height: 600px !important + } } \ No newline at end of file diff --git a/admin/templates/js/bmaps.js b/admin/templates/js/bmaps.js index e742bde..5e511f7 100644 --- a/admin/templates/js/bmaps.js +++ b/admin/templates/js/bmaps.js @@ -29,6 +29,7 @@ var APPMAP; this.selectCity = ''; this.selectDist = ''; this.address = ''; + this.placeName = ''; this.lngDom = {}; this.latDom = {}; this.mapLng = CL.c.maplng || this.mapLng; @@ -101,13 +102,13 @@ var APPMAP; base.prototype.level = function () { var level = 12; if (!this.isEmpty(this.selectProv)) - level = 10; + level = 11; if (!this.isEmpty(this.selectCity)) - level = 12; + level = 13; if (!this.isEmpty(this.selectDist)) - level = 14; - if (!this.isEmpty(this.selectDist) && !this.isEmpty(this.address)) level = 15; + if (!this.isEmpty(this.selectDist) && !this.isEmpty(this.address)) + level = 18; return level; }; base.prototype.watch = function (JsonObj, key, closure) { @@ -156,6 +157,7 @@ var APPMAP; }; initialMap.prototype.initMap = function (domId, level) { var map = new BMapGL.Map(domId, { enableMapClick: false }); + console.log(this.level()); map.centerAndZoom(this.mapPoints, level || this.level()); map.enableScrollWheelZoom(true); map.setDisplayOptions({ @@ -182,6 +184,30 @@ var APPMAP; } }, this.selectProv); }; + initialMap.prototype.placeNameMap = function (map, callbackQuery, callbackPolygon) { + var _this = this; + var local = new BMapGL.LocalSearch(this.selectCity, { + renderOptions: { + map: map + }, + pageCapacity: 1, + }); + local.search(this.placeName, { forceLocal: true }); + local.setMarkersSetCallback(function (e) { + var city = e.pop(); + map.removeOverlay(city.marker); + setTimeout(function () { + if (city.isAccurate === true) { + map.panTo(city.point); + map.setZoom(18); + callbackQuery(city.uid, callbackPolygon); + } + else { + _this.citySyncMap(map); + } + }, 50); + }); + }; initialMap.prototype.ajaxlnglatList = function (map, formJson, clickEvent, closure) { var _this = this; if (clickEvent === void 0) { clickEvent = false; } @@ -295,7 +321,9 @@ var APPMAP; }); } else { + _this.placeName = $('select[name="v_name"]').find("option:selected").val(); var html = '范围:' + _this.selectProv + '' + _this.allCity + ''; + html += '' + _this.placeName + ''; $('h4.modal-title').html(html); $('#appmaps').modal('show'); } @@ -311,6 +339,9 @@ var APPMAP; city: _this.selectCity, district: _this.selectDist }); + if (_this.placeName && _this.isEmpty(_this.inputLng) && _this.isEmpty(_this.inputLat)) { + _this.placeNameMap(_this.modalMap, _this.queryHouseOutline, _this.showPolygon(_this.modalMap)); + } _this.modalMap.addEventListener("click", function (e) { _this.modalMap.removeOverlay(_this.cacheMarker); _this.modalLng = e.latlng.lng; @@ -346,6 +377,107 @@ var APPMAP; if (!this.isEmpty(this.inputLng) && !this.isEmpty(this.inputLat)) this.addMapOverlay(this.modalMap, this.inputLng, this.inputLat, true); }; + modalMap.prototype.queryHouseOutline = function (uid, callback) { + var baseURL = 'https://map.baidu.com/?reqflag=pcmap&coord_type=3&from=webmap&qt=ext&ext_ver=new&l=18'; + var url = baseURL + "&uid=" + uid; + callback && (window['queryHouseOutlineCallback'] = callback); + $.ajax({ + type: "get", + async: false, + url: url, + dataType: "jsonp", + jsonpCallback: "queryHouseOutlineCallback", + success: function (datas) { + } + }); + }; + modalMap.prototype.parseGeo = function (mocator) { + if (typeof mocator != 'string') + return {}; + var t = mocator.split("|"); + var n = parseInt(t[0]); + var i = t[1]; + var r = t[2]; + var o = r.split(";"); + if (n === 4) { + var a = []; + for (var s = 0; s < o.length - 1; s++) { + "1" === o[s].split("-")[0] && a.push(o[s].split("-")[1]); + } + o = a; + o.push(""); + } + var u = []; + switch (n) { + case 1: + u.push(o[0]); + break; + case 2: + case 3: + case 4: + for (var s = 0; s < o.length - 1; s++) { + var l = o[s]; + if (l.length > 100) { + l = l.replace(/(-?[1-9]\d*\.\d*|-?0\.\d*[1-9]\d*|-?0?\.0+|0|-?[1-9]\d*),(-?[1-9]\d*\.\d*|-?0\.\d*[1-9]\d*|-?0?\.0+|0|-?[1-9]\d*)(,)/g, "$1,$2;"); + u.push(l); + } + else { + var c = []; + for (var d = l.split(","), f = 0; f < d.length; f += 2) { + var p = d[f], h = d[f + 1]; + c.push(p + "," + h); + } + u.push(c.join(";")); + } + } + break; + default: + break; + } + if (u.length <= 1) + u = u.toString(); + return { + type: n, + bound: i, + points: u + }; + }; + modalMap.prototype.coordinateToPoints = function (map, coordinate) { + var points = []; + if (coordinate) { + var arr = coordinate.split(";"); + if (arr) { + for (var i = 0; i < arr.length; i++) { + var coord = arr[i].split(","); + if (coord && coord.length == 2) { + var point = map.mercatorToLnglat(coord[0], coord[1]); + points.push(new BMapGL.Point(point[0], point[1])); + } + } + } + } + return points; + }; + modalMap.prototype.showPolygon = function (map) { + var _this = this; + return function (datas) { + var geo = datas.content.geo; + if (geo) { + var geoObj = _this.parseGeo(geo); + var points = _this.coordinateToPoints(map, geoObj.points); + var ply = new BMapGL.Polygon(points, { + strokeColor: "#ff4c52", + strokeWeight: 2, + strokeOpacity: 1, + strokeStyle: 'dashed', + fillColor: "transparent", + fillOpacity: 0 + }); + map.addOverlay(ply); + map.setViewport(ply.getPath()); + } + }; + }; return modalMap; }(showMap)); var selectMap = (function (_super) { @@ -656,17 +788,15 @@ var APPMAP; vtype: vtype, allinfo: 'all' }, true); - this.citySyncMap(this.selectMap); + this.citySyncMap(this.selectMap, this.level()); }; return selectMap; }(initialMap)); function bmaps() { if ($('#modalmap').length) { - console.log('模态框类型'); new modalMap(); } else if ($('#showmap').length) { - console.log('纯展示类型'); new showMap(); } else if ($('#selectMap').length) { diff --git a/admin/templates/village.php b/admin/templates/village.php index d0f5316..ef21e1d 100644 --- a/admin/templates/village.php +++ b/admin/templates/village.php @@ -79,7 +79,7 @@ $met_title = $data['met_title'];