678 lines
29 KiB
JavaScript
678 lines
29 KiB
JavaScript
"use strict";
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = function (d, b) {
|
|
extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
return extendStatics(d, b);
|
|
};
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
var APPMAP;
|
|
(function (APPMAP) {
|
|
var base = (function () {
|
|
function base() {
|
|
var _this = this;
|
|
this.mapLng = '116.395645';
|
|
this.mapLat = '39.929986';
|
|
this.mapPoints = {};
|
|
this.inputLng = '';
|
|
this.inputLat = '';
|
|
this.inputPoints = {};
|
|
this.cacheMarker = {};
|
|
this.allCity = '';
|
|
this.selectProv = '';
|
|
this.selectCity = '';
|
|
this.selectDist = '';
|
|
this.address = '';
|
|
this.lngDom = {};
|
|
this.latDom = {};
|
|
this.mapLng = CL.c.maplng || this.mapLng;
|
|
this.mapLat = CL.c.maplat || this.mapLat;
|
|
this.watch(this, 'inputLng', function () {
|
|
_this.setInputLng();
|
|
});
|
|
this.watch(this, 'inputLat', function () {
|
|
_this.setInputLat();
|
|
});
|
|
this.initHtmlDom();
|
|
this.getInputLngLat();
|
|
this.syncMapLngLat();
|
|
this.getCity();
|
|
$(document).on('change keyup', '.city-js select', function () {
|
|
if ($(".city-mapjs-address").length)
|
|
$(".city-mapjs-address").val('');
|
|
});
|
|
$(document).on('change keyup', '.city-js select, .city-mapjs-address', function () {
|
|
_this.getCity();
|
|
});
|
|
}
|
|
base.prototype.initHtmlDom = function () {
|
|
this.lngDom = $(".city-mapjs-lng");
|
|
this.latDom = $(".city-mapjs-lat");
|
|
};
|
|
base.prototype.isEmpty = function (val) {
|
|
switch (val) {
|
|
case ',':
|
|
return true;
|
|
case '请选择':
|
|
return true;
|
|
case '请选择所在地区':
|
|
return true;
|
|
}
|
|
return APPFUN.isEmpty(val);
|
|
};
|
|
base.prototype.getInputLngLat = function () {
|
|
this.inputLng = this.lngDom.val();
|
|
this.inputLat = this.latDom.val();
|
|
};
|
|
base.prototype.syncMapLngLat = function () {
|
|
if (!this.isEmpty(this.inputLng) && !this.isEmpty(this.inputLat)) {
|
|
this.mapLng = this.inputLng;
|
|
this.mapLat = this.inputLat;
|
|
}
|
|
};
|
|
base.prototype.setInputLngLat = function () {
|
|
this.setInputLng();
|
|
this.setInputLat();
|
|
};
|
|
base.prototype.setInputLng = function () {
|
|
this.lngDom.val(this.inputLng);
|
|
this.lngDom.trigger('input');
|
|
};
|
|
base.prototype.setInputLat = function () {
|
|
this.latDom.val(this.inputLat);
|
|
this.latDom.trigger('input');
|
|
};
|
|
base.prototype.getCity = function () {
|
|
this.selectProv = this.isCity($(".city-js select.prov").find("option:selected").val());
|
|
this.selectCity = this.isCity($(".city-js select.city").find("option:selected").val());
|
|
this.selectDist = this.isCity($(".city-js select.dist").find("option:selected").val());
|
|
this.address = this.isCity($(".city-mapjs-address").val());
|
|
this.allCity = this.selectCity + this.selectDist + this.address;
|
|
};
|
|
base.prototype.isCity = function (string) {
|
|
return !this.isEmpty(string) ? string : '';
|
|
};
|
|
base.prototype.level = function () {
|
|
var level = 12;
|
|
if (!this.isEmpty(this.selectProv))
|
|
level = 10;
|
|
if (!this.isEmpty(this.selectCity))
|
|
level = 12;
|
|
if (!this.isEmpty(this.selectDist))
|
|
level = 14;
|
|
if (!this.isEmpty(this.selectDist) && !this.isEmpty(this.address))
|
|
level = 15;
|
|
return level;
|
|
};
|
|
base.prototype.watch = function (JsonObj, key, closure) {
|
|
var cacheData = {};
|
|
cacheData[key] = JsonObj[key];
|
|
Object.defineProperty(JsonObj, key, {
|
|
enumerable: true,
|
|
configurable: true,
|
|
get: function () {
|
|
return cacheData[key];
|
|
},
|
|
set: function (newValue) {
|
|
var oldValue = cacheData[key];
|
|
cacheData[key] = newValue;
|
|
if (typeof closure === 'function' && oldValue !== newValue)
|
|
closure(newValue, oldValue);
|
|
}
|
|
});
|
|
};
|
|
return base;
|
|
}());
|
|
var initialMap = (function (_super) {
|
|
__extends(initialMap, _super);
|
|
function initialMap() {
|
|
var _this = _super.call(this) || this;
|
|
_this.showMap = {};
|
|
_this.modalMap = {};
|
|
_this.mapType = false;
|
|
_this.myGeos = {};
|
|
_this.mapLngLatList = {};
|
|
_this.mapCacheMarker = {};
|
|
_this.myGeos = new BMapGL.Geocoder();
|
|
if (!_this.isEmpty(_this.inputLng) && !_this.isEmpty(_this.inputLat)) {
|
|
_this.inputPoints = _this.mapPoints = _this.lnglatToPoints(_this.inputLng, _this.inputLat);
|
|
}
|
|
else {
|
|
_this.mapPoints = _this.lnglatToPoints(_this.mapLng, _this.mapLat);
|
|
}
|
|
return _this;
|
|
}
|
|
initialMap.prototype.lnglatToPoints = function (lng, lat) {
|
|
var point = {};
|
|
if (!this.isEmpty(lng) && !this.isEmpty(lat))
|
|
point = new BMapGL.Point(lng, lat);
|
|
return point;
|
|
};
|
|
initialMap.prototype.initMap = function (domId, level) {
|
|
var map = new BMapGL.Map(domId, { enableMapClick: false });
|
|
map.centerAndZoom(this.mapPoints, level || this.level());
|
|
map.enableScrollWheelZoom(true);
|
|
map.setDisplayOptions({
|
|
poiIcon: false
|
|
});
|
|
return map;
|
|
};
|
|
initialMap.prototype.setHeadingTilt = function (map) {
|
|
map.setTilt(65);
|
|
};
|
|
initialMap.prototype.citySyncMap = function (mapOjb, level) {
|
|
var _this = this;
|
|
this.myGeos.getPoint(this.allCity || this.selectProv, function (point) {
|
|
if (point) {
|
|
_this.mapPoints = point;
|
|
_this.mapLng = point.lng;
|
|
_this.mapLat = point.lat;
|
|
mapOjb.panTo(point);
|
|
if (level && level > 0)
|
|
mapOjb.setZoom(level);
|
|
}
|
|
else {
|
|
console.log("您选择地址没有解析到结果!");
|
|
}
|
|
}, this.selectProv);
|
|
};
|
|
initialMap.prototype.ajaxlnglatList = function (map, formJson, clickEvent, closure) {
|
|
var _this = this;
|
|
if (clickEvent === void 0) { clickEvent = false; }
|
|
$.getJSON(M.url.own_name + "c=ajax&a=doallmap", formJson, function (listJson) {
|
|
_this.mapLngLatList = listJson;
|
|
$.each(listJson, function (i, val) {
|
|
val.maplng = val.v_maplng;
|
|
val.maplat = val.v_maplat;
|
|
var clickClosure = clickEvent ? _this.addOpenInfo(map, val) : '';
|
|
if (!_this.isEmpty(val.maplng) && !_this.isEmpty(val.maplat))
|
|
_this.addMapOverlay(map, val.maplng, val.maplat, false, val.id, clickClosure);
|
|
});
|
|
});
|
|
};
|
|
initialMap.prototype.myIcon = function () {
|
|
return new BMapGL.Icon(M.url.own_tem + "/img/markers.png", new BMapGL.Size(21, 25), {
|
|
imageSize: new BMapGL.Size(42, 325),
|
|
anchor: new BMapGL.Size(10, 25),
|
|
imageOffset: new BMapGL.Size(0, 300)
|
|
});
|
|
};
|
|
initialMap.prototype.addMapOverlay = function (appmapl, lng, lat, icons, listId, clickClosure) {
|
|
var _this = this;
|
|
if (icons === void 0) { icons = false; }
|
|
if (this.isEmpty(lng))
|
|
return false;
|
|
var points = this.lnglatToPoints(lng, lat);
|
|
var marker = new BMapGL.Marker(points);
|
|
if (typeof clickClosure === 'function') {
|
|
marker.addEventListener("click", function (e) {
|
|
clickClosure(e);
|
|
});
|
|
this.watch(marker, 'domElement', function () {
|
|
_this.mapCacheMarker[listId] = $(marker.domElement);
|
|
});
|
|
}
|
|
if (icons) {
|
|
this.cacheMarker = marker;
|
|
marker.setIcon(this.myIcon());
|
|
}
|
|
appmapl.addOverlay(marker);
|
|
return points;
|
|
};
|
|
initialMap.prototype.addOpenInfo = function (map, value) {
|
|
var _this = this;
|
|
var opts = {
|
|
maxWidth: 350,
|
|
enableAutoPan: true,
|
|
title: value.v_name
|
|
};
|
|
var content = "<p>" + value.v_province + value.v_city + value.v_district + value.v_address + "</p>";
|
|
return function (e) {
|
|
var p = e.target;
|
|
var point = _this.lnglatToPoints(p.getPosition().lng, p.getPosition().lat);
|
|
var infoWindow = new BMapGL.InfoWindow(content, opts);
|
|
map.openInfoWindow(infoWindow, point);
|
|
};
|
|
};
|
|
return initialMap;
|
|
}(base));
|
|
var showMap = (function (_super) {
|
|
__extends(showMap, _super);
|
|
function showMap() {
|
|
var _this = _super.call(this) || this;
|
|
_this.getMapType();
|
|
_this.showInitMap();
|
|
_this.watchCity();
|
|
return _this;
|
|
}
|
|
showMap.prototype.showInitMap = function () {
|
|
this.showMap = this.initMap("showmap");
|
|
this.setHeadingTilt(this.showMap);
|
|
if (this.isEmpty(this.inputLng) && this.isEmpty(this.inputLat) && !this.isEmpty(this.allCity))
|
|
this.citySyncMap(this.showMap);
|
|
if (this.mapType)
|
|
this.addMapOverlay(this.showMap, this.inputLng, this.inputLat, true);
|
|
};
|
|
showMap.prototype.getMapType = function () {
|
|
return this.mapType = $('#showmap').data('type') === 'showmap' ? false : true;
|
|
};
|
|
showMap.prototype.watchCity = function () {
|
|
var _this = this;
|
|
var $fun = function () {
|
|
_this.citySyncMap(_this.showMap);
|
|
};
|
|
this.watch(this, 'selectProv', $fun);
|
|
this.watch(this, 'allCity', $fun);
|
|
if (!this.mapType) {
|
|
this.watch(this, 'mapLng', function () {
|
|
_this.inputLng = _this.mapLng;
|
|
});
|
|
this.watch(this, 'mapLat', function () {
|
|
_this.inputLat = _this.mapLat;
|
|
});
|
|
}
|
|
};
|
|
return showMap;
|
|
}(initialMap));
|
|
var modalMap = (function (_super) {
|
|
__extends(modalMap, _super);
|
|
function modalMap() {
|
|
var _this = _super.call(this) || this;
|
|
_this.modalLng = '';
|
|
_this.modalLat = '';
|
|
_this.modalPoints = {};
|
|
$('#mapmodal').on('click', function () {
|
|
if (_this.isEmpty(_this.selectCity)) {
|
|
$.include(M['url']['static2_vendor'] + 'alertify/alertify.js', function () {
|
|
alertify.logPosition("右下角");
|
|
alertify.error("请选择城市。");
|
|
});
|
|
}
|
|
else {
|
|
var html = '范围:' + _this.selectProv + '<small style="padding-left:15px;">' + _this.allCity + '</small>';
|
|
$('h4.modal-title').html(html);
|
|
$('#appmaps').modal('show');
|
|
}
|
|
});
|
|
$('#appmaps').on('shown.bs.modal', function () {
|
|
setTimeout(function () {
|
|
document.body.scrollTop = document.documentElement.scrollTop = 0;
|
|
_this.modalInitMap();
|
|
var mapId = $('#modalmap').data('mapid') || '';
|
|
_this.ajaxlnglatList(_this.modalMap, {
|
|
id: mapId,
|
|
province: _this.selectProv,
|
|
city: _this.selectCity,
|
|
district: _this.selectDist
|
|
});
|
|
_this.modalMap.addEventListener("click", function (e) {
|
|
_this.modalMap.removeOverlay(_this.cacheMarker);
|
|
_this.modalLng = e.latlng.lng;
|
|
_this.modalLat = e.latlng.lat;
|
|
_this.modalPoints = _this.addMapOverlay(_this.modalMap, _this.modalLng, _this.modalLat, true);
|
|
});
|
|
}, 200);
|
|
});
|
|
$('#appmaps .button-save').on('click', function () {
|
|
if (!_this.isEmpty(_this.modalLng) && !_this.isEmpty(_this.modalLat)) {
|
|
_this.inputLng = _this.modalLng;
|
|
_this.inputLat = _this.modalLat;
|
|
if (!_this.isEmpty(_this.showMap)) {
|
|
_this.showMap.clearOverlays();
|
|
_this.mapPoints = _this.inputPoints = _this.modalPoints;
|
|
_this.showMap.panTo(_this.mapPoints);
|
|
_this.addMapOverlay(_this.showMap, _this.inputLng, _this.inputLat, true);
|
|
}
|
|
}
|
|
$('#appmaps').modal('hide');
|
|
});
|
|
$('#appmaps').on('hidden.bs.modal', function () {
|
|
_this.modalMap.clearOverlays();
|
|
_this.modalLng = _this.modalLat = '';
|
|
_this.modalPoints = {};
|
|
$('#appmaps').removeData("bs.modal");
|
|
_this.modalMap.destroy();
|
|
});
|
|
return _this;
|
|
}
|
|
modalMap.prototype.modalInitMap = function () {
|
|
this.modalMap = this.initMap("modalmap");
|
|
if (!this.isEmpty(this.inputLng) && !this.isEmpty(this.inputLat))
|
|
this.addMapOverlay(this.modalMap, this.inputLng, this.inputLat, true);
|
|
};
|
|
return modalMap;
|
|
}(showMap));
|
|
var selectMap = (function (_super) {
|
|
__extends(selectMap, _super);
|
|
function selectMap() {
|
|
var _this = _super.call(this) || this;
|
|
_this.selectMapInitType = false;
|
|
_this.selectMap = {};
|
|
_this.drawingManager = {};
|
|
_this.overlaysCache = {
|
|
overlays: {},
|
|
hashCode: '',
|
|
drawingMode: ''
|
|
};
|
|
_this.overlays = {};
|
|
_this.hashCode = {};
|
|
_this.markerID = {
|
|
marker: [],
|
|
polyline: [],
|
|
circle: [],
|
|
rectangle: [],
|
|
polygon: []
|
|
};
|
|
_this.villageFilterList = {};
|
|
_this.villageList = {};
|
|
$(document).on('change', 'select[name="vtype"]', function () {
|
|
_this.filter();
|
|
});
|
|
_this.watch(_this, 'selectProv', function () {
|
|
_this.filter();
|
|
});
|
|
_this.watch(_this, 'allCity', function () {
|
|
_this.filter();
|
|
});
|
|
$('#selectMapId').on('shown.bs.modal', function () {
|
|
if (_this.selectMapInitType)
|
|
return false;
|
|
_this.setHeight();
|
|
setTimeout(function () {
|
|
document.body.scrollTop = document.documentElement.scrollTop = 0;
|
|
_this.selectInitMap();
|
|
_this.ajaxlnglatList(_this.selectMap, {
|
|
id: '',
|
|
province: _this.selectProv,
|
|
city: _this.selectCity,
|
|
district: _this.selectDist,
|
|
allinfo: 'all'
|
|
}, true);
|
|
_this.drawingManagerInit();
|
|
_this.drawingManager.addEventListener("overlaycomplete", function (e) {
|
|
var overlay = e.overlay;
|
|
var hashCode = overlay.hashCode;
|
|
var drawingMode = e.drawingMode;
|
|
_this.overlays[hashCode] = overlay;
|
|
_this.hashCode[hashCode] = drawingMode;
|
|
_this.overlaysCache = {
|
|
overlays: overlay,
|
|
hashCode: hashCode,
|
|
drawingMode: drawingMode
|
|
};
|
|
var latLngNum = 0;
|
|
_this.villageFilterList = {};
|
|
$.each(_this.mapLngLatList, function (i, val) {
|
|
latLngNum++;
|
|
var points = _this.lnglatToPoints(val.v_maplng, val.v_maplat);
|
|
var result = false;
|
|
switch (drawingMode) {
|
|
case 'polyline':
|
|
result = BMapGLLib.GeoUtils.isPointOnPolyline(points, overlay);
|
|
break;
|
|
case 'circle':
|
|
result = BMapGLLib.GeoUtils.isPointInCircle(points, overlay);
|
|
break;
|
|
case 'rectangle':
|
|
var bounds = overlay.getBounds();
|
|
result = BMapGLLib.GeoUtils.isPointInRect(points, bounds);
|
|
break;
|
|
case 'polygon':
|
|
result = BMapGLLib.GeoUtils.isPointInPolygon(points, overlay);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
if (result == true) {
|
|
if (!_this.markerID[drawingMode][hashCode])
|
|
_this.markerID[drawingMode][hashCode] = [];
|
|
_this.markerID[drawingMode][hashCode].push(val.id);
|
|
_this.villageFilterList[val.id] = val;
|
|
}
|
|
if (latLngNum === Object.keys(_this.mapLngLatList).length)
|
|
_this.confirmOperate();
|
|
});
|
|
});
|
|
if (_this.selectMapInitType === false)
|
|
_this.selectMapInitType = true;
|
|
}, 100);
|
|
});
|
|
$('#selectMapId .mapreset').on('click', function (e) {
|
|
_this.mapreset();
|
|
_this.listNum('selectMapId');
|
|
_this.input();
|
|
});
|
|
$('#selectMapId').on('click', 'li button', function (e) {
|
|
var domLi = $(e.target).parents('li');
|
|
_this.delFilterList(domLi.data('id'));
|
|
domLi.remove();
|
|
});
|
|
$('#selectMapId .button-save').on('click', function () {
|
|
var keysArr = Object.keys(_this.villageList);
|
|
var keysStr = keysArr.toString();
|
|
_this.input(keysStr);
|
|
$('#selectMapId').modal('hide');
|
|
});
|
|
$('#selectMapId').on('hidden.bs.modal', function () {
|
|
});
|
|
$('.villageList ul').on('click', 'li[data-id] h5', function (e) {
|
|
var id = $(e.target).parents('li').data('id');
|
|
var listInfo = _this.villageList[id];
|
|
var point = _this.lnglatToPoints(listInfo.maplng, listInfo.maplat);
|
|
_this.selectMap.panTo(point);
|
|
_this.mapCacheMarker[id].trigger('click');
|
|
});
|
|
return _this;
|
|
}
|
|
selectMap.prototype.setHeight = function () {
|
|
var headerHeight = $("#selectMapId .modal-header").outerHeight(true);
|
|
var wHeight = $(document.body).height();
|
|
var mapHeight = wHeight - headerHeight - 15;
|
|
$(".selectMapHeight").height(mapHeight);
|
|
var panelHeading = $(".selectMapHeight .panel-heading").outerHeight(true);
|
|
var panelFooter = $(".selectMapHeight .panel-footer").outerHeight(true);
|
|
var panelBody = $(".selectMapHeight .panel-body").outerHeight(true) - $(".selectMapHeight .panel-body").height();
|
|
$(".selectMapHeight .panel-body").height(mapHeight - panelHeading - panelFooter - panelBody);
|
|
};
|
|
selectMap.prototype.setFilterModalBodyHeight = function () {
|
|
var filterListmodalHeight = $("#filterListmodal").outerHeight(true);
|
|
var modalHeader = $("#filterListmodal .modal-header").outerHeight(true);
|
|
var modalFooter = $("#filterListmodal .modal-footer").outerHeight(true);
|
|
var modalBody = $("#filterListmodal .modal-body").outerHeight(true) - $("#filterListmodal .modal-body").height();
|
|
$("#filterListmodal .filterList").height(filterListmodalHeight - modalHeader - modalBody - modalFooter);
|
|
};
|
|
selectMap.prototype.selectInitMap = function () {
|
|
this.selectMap = this.initMap("selectMap");
|
|
};
|
|
selectMap.prototype.drawingManagerInit = function () {
|
|
var styleOptions = {
|
|
strokeColor: '#5E87DB',
|
|
fillColor: '#5E87DB',
|
|
strokeWeight: 2,
|
|
strokeOpacity: 1,
|
|
fillOpacity: 0.2
|
|
};
|
|
var labelOptions = {
|
|
borderRadius: '2px',
|
|
background: '#FFFBCC',
|
|
border: '1px solid #E1E1E1',
|
|
color: '#703A04',
|
|
fontSize: '12px',
|
|
letterSpacing: '0',
|
|
padding: '5px'
|
|
};
|
|
this.drawingManager = new BMapGLLib.DrawingManager(this.selectMap, {
|
|
enableDrawingTool: true,
|
|
enableCalculate: true,
|
|
drawingToolOptions: {
|
|
enableTips: true,
|
|
customContainer: 'selectbox_Drawing',
|
|
hasCustomStyle: true,
|
|
anchor: BMAP_ANCHOR_TOP_RIGHT,
|
|
offset: new BMapGL.Size(25, 15),
|
|
scale: 1,
|
|
drawingModes: [
|
|
BMAP_DRAWING_POLYLINE,
|
|
BMAP_DRAWING_RECTANGLE,
|
|
BMAP_DRAWING_POLYGON,
|
|
BMAP_DRAWING_CIRCLE,
|
|
]
|
|
},
|
|
enableSorption: true,
|
|
sorptionDistance: 20,
|
|
enableGpc: true,
|
|
circleOptions: styleOptions,
|
|
polylineOptions: styleOptions,
|
|
polygonOptions: styleOptions,
|
|
rectangleOptions: styleOptions,
|
|
labelOptions: labelOptions
|
|
});
|
|
};
|
|
selectMap.prototype.confirmOperate = function () {
|
|
var _this = this;
|
|
this.addHtmlShow('filterList');
|
|
$('#filterListmodal').modal('show');
|
|
$('#filterListmodal').on('shown.bs.modal', function () {
|
|
_this.listNum('filterListmodal');
|
|
_this.setFilterModalBodyHeight();
|
|
});
|
|
$('#filterListmodal .mapreset').on('click', function (e) {
|
|
$('#filterListmodal').modal('hide');
|
|
_this.mapresetClose();
|
|
});
|
|
$('#filterListmodal .button-save').on('click', function () {
|
|
$('#filterListmodal').modal('hide');
|
|
_this.addHtmlShow('villageList');
|
|
});
|
|
$('#filterListmodal').on('click', 'li button', function (e) {
|
|
var domLi = $(e.target).parents('li');
|
|
_this.delFilterList(domLi.data('id'), 'filterList');
|
|
domLi.remove();
|
|
});
|
|
$('#selectMapId').on('hidden.bs.modal', function () {
|
|
$('#selectMapId').removeData("bs.modal");
|
|
});
|
|
};
|
|
selectMap.prototype.addHtmlShow = function (domclass) {
|
|
var _this = this;
|
|
var dom = $("." + domclass).find('ul');
|
|
var listNum = domclass === 'filterList' ? 0 : (Object.keys(this.villageList).length || 0);
|
|
var initListNum = 0;
|
|
$.each(this.villageFilterList, function (i, val) {
|
|
if (domclass !== 'filterList') {
|
|
if (_this.villageList[i] && Object.keys(_this.villageList[i]).length > 0)
|
|
return true;
|
|
_this.villageList[i] = val;
|
|
}
|
|
var li = _this.htmlLi(i, val);
|
|
listNum === 0 ? dom.html(li) : dom.prepend(li);
|
|
listNum++;
|
|
initListNum++;
|
|
if (initListNum === Object.keys(_this.villageFilterList).length) {
|
|
_this.listNum('selectMapId');
|
|
}
|
|
});
|
|
};
|
|
selectMap.prototype.htmlLi = function (key, val) {
|
|
var address = val.v_city + val.v_district + val.v_address;
|
|
return "<li class=\"list-group-item village-list-item\" data-id=\"" + key + "\">\n <h5>" + val.v_name + "</h5>\n <button type=\"button\" class=\"float-right close\">\n <i class=\"icon wb-close m-0 font-danger\" aria-hidden=\"true\"></i>\n </button>\n <p>\u5730\u5740\uFF1A" + address + "</p>\n </li>";
|
|
};
|
|
selectMap.prototype.mapresetClose = function () {
|
|
var hashCode = this.overlaysCache.hashCode;
|
|
var drawingMode = this.overlaysCache.drawingMode;
|
|
delete this.overlays[hashCode];
|
|
delete this.hashCode[hashCode];
|
|
delete this.markerID[drawingMode][hashCode];
|
|
this.selectMap.removeOverlay(this.overlaysCache.overlays);
|
|
};
|
|
selectMap.prototype.mapreset = function () {
|
|
var _this = this;
|
|
$.each(this.overlays, function (i, val) {
|
|
_this.selectMap.removeOverlay(val);
|
|
delete _this.overlays[i];
|
|
delete _this.hashCode[i];
|
|
});
|
|
this.markerID = {
|
|
marker: [],
|
|
polyline: [],
|
|
circle: [],
|
|
rectangle: [],
|
|
polygon: []
|
|
};
|
|
this.villageList = {};
|
|
$('.villageList ul').html("<li class=\"list-group-item\">\u6CA1\u6709\u9009\u4E2D\u5C0F\u533A</li>");
|
|
};
|
|
selectMap.prototype.delFilterList = function (id, domclass) {
|
|
if (domclass === 'filterList') {
|
|
delete this.villageFilterList[id];
|
|
this.listNum('filterListmodal', 'del');
|
|
}
|
|
else {
|
|
delete this.villageList[id];
|
|
this.listNum('selectMapId', 'del');
|
|
}
|
|
};
|
|
selectMap.prototype.listNum = function (domclass, type) {
|
|
if (domclass === 'filterListmodal') {
|
|
var listNum = this.villageFilterList ? Object.keys(this.villageFilterList).length : 0;
|
|
$('#filterListmodal .listNum').html(listNum);
|
|
if (listNum === 0 && type === 'del') {
|
|
this.mapresetClose();
|
|
$('#filterListmodal').modal('hide');
|
|
}
|
|
}
|
|
else {
|
|
var listNums = this.villageList ? Object.keys(this.villageList).length : 0;
|
|
$('#selectMapId .listNum').html(listNums);
|
|
$('button[data-target="#selectMapId"] .listNum').html(listNums > 0 ? listNums : '');
|
|
if (listNums === 0 && type === 'del')
|
|
this.mapreset();
|
|
}
|
|
};
|
|
selectMap.prototype.input = function (keysStr) {
|
|
var inputVid = $('input[name="v_id"]');
|
|
inputVid.val(keysStr);
|
|
inputVid.trigger('change');
|
|
};
|
|
selectMap.prototype.filter = function () {
|
|
var vtype;
|
|
if ($('select[name="vtype"]').length) {
|
|
vtype = $('select[name="vtype"]').val();
|
|
vtype = vtype ? vtype.join(',') : '';
|
|
}
|
|
$('#selectMapId .mapreset').trigger('click');
|
|
this.selectMap.clearOverlays();
|
|
this.ajaxlnglatList(this.selectMap, {
|
|
id: '',
|
|
province: this.selectProv,
|
|
city: this.selectCity,
|
|
district: this.selectDist,
|
|
vtype: vtype,
|
|
allinfo: 'all'
|
|
}, true);
|
|
this.citySyncMap(this.selectMap);
|
|
};
|
|
return selectMap;
|
|
}(initialMap));
|
|
function bmaps() {
|
|
if ($('#modalmap').length) {
|
|
console.log('模态框类型');
|
|
new modalMap();
|
|
}
|
|
else if ($('#showmap').length) {
|
|
console.log('纯展示类型');
|
|
new showMap();
|
|
}
|
|
else if ($('#selectMap').length) {
|
|
new selectMap();
|
|
}
|
|
}
|
|
APPMAP.bmaps = bmaps;
|
|
})(APPMAP || (APPMAP = {}));
|