| | |
| | | // eslint-disable-next-line no-unreachable |
| | | return url + '\n' + arg + '\n' + argValue |
| | | } |
| | | |
| | | /** |
| | | * 脉冲效果 |
| | | */ |
| | | export function pulseEffect (xy) { |
| | | window.mapManager.clearHighlight() |
| | | let times = 1000 |
| | | const colors = ['#00f100', '#ff0000'] |
| | | // 插件 效果实现 |
| | | var pulsingIcon = window.L.icon.pulse({ |
| | | iconSize: [30, 30], |
| | | color: colors[0], |
| | | fillColor: '' |
| | | }) |
| | | var picGroupMarker = window.L.marker(xy, { icon: pulsingIcon }).addTo(window.mapManager.hightlightLayer) |
| | | // 定时 |
| | | var timeInterval = setInterval(() => { |
| | | if (times > 0) { |
| | | times-- |
| | | } else { |
| | | clearInterval(timeInterval) |
| | | picGroupMarker.remove() |
| | | } |
| | | }, 1000) |
| | | } |
| | | |
| | | export function reversePolyLine (feature) { |
| | | const coordinates = clone(feature.geometry.coordinates) |
| | | var latlng = [] |
| | | for (var j = 0; j < coordinates.length; j++) { |
| | | let coordinate = coordinates[j] |
| | | coordinate = [coordinate[1], coordinate[0]] |
| | | latlng.push(coordinate) |
| | | } |
| | | return latlng |
| | | } |
| | | |
| | | export function reverseMultiLine (feature) { |
| | | const coordinates = clone(feature.geometry.coordinates) |
| | | var latlng = [] |
| | | for (var j = 0; j < coordinates.length; j++) { |
| | | const coordinate = coordinates[j] |
| | | var xy = [] |
| | | for (var k = 0; k < coordinate.length; k++) { |
| | | let coor = coordinate[k] |
| | | if (coor.length > 2) { |
| | | coor = coor.splice(2, 1) |
| | | } |
| | | xy.push(coor.reverse()) |
| | | } |
| | | latlng.push(xy) |
| | | } |
| | | return latlng |
| | | } |
| | | |
| | | /** |
| | | * 设置弹窗平移位置 |
| | | * @param pos |
| | | * @param value |
| | | */ |
| | | export function setPanTo (pos, value) { |
| | | var position = pos |
| | | position = window.map.latLngToLayerPoint(position) |
| | | position.y += value |
| | | position = window.map.layerPointToLatLng(position) |
| | | window.map.flyTo(position) |
| | | } |
| | | |
| | | /** |
| | | * 复制对象 |
| | | * @param obj |
| | | * @returns {{}} |
| | | */ |
| | | export function clone (obj) { |
| | | var o |
| | | // 如果 他是对象object的话 , 因为null,object,array 也是'object'; |
| | | if (typeof obj === 'object') { |
| | | // 如果 他是空的话 |
| | | if (obj === null) { |
| | | o = null |
| | | } else { |
| | | // 如果 他是数组arr的话 |
| | | if (obj instanceof Array) { |
| | | o = [] |
| | | for (var i = 0, len = obj.length; i < len; i++) { |
| | | o.push(clone(obj[i])) |
| | | } |
| | | } else { |
| | | // 如果 他是对象object的话 |
| | | o = {} |
| | | for (var j in obj) { |
| | | o[j] = clone(obj[j]) |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | o = obj |
| | | } |
| | | return o |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 设置index,线在最下面,点在上面 |
| | | * @param layerGroup 图层组 |
| | | */ |
| | | export function setZIndex (layer) { |
| | | if (Array.isArray(layer)) { |
| | | for (var i = 0; i < layer.length; i++) { |
| | | setZIndex(layer[i]) |
| | | } |
| | | } else { |
| | | if (layer.getLayers) { |
| | | setZIndex(layer.getLayers()) |
| | | } else { |
| | | if (layer.feature && (layer.feature.geometry.type === 'LineString' || layer.feature.geometry.type === 'MultiLineString')) { |
| | | layer.bringToBack && layer.bringToBack() |
| | | } else { |
| | | layer.bringToFront && layer.bringToFront() |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 去掉两头空格 |
| | | * @param str |
| | | * @returns {*} |
| | | */ |
| | | export function lrtrim (str) { |
| | | return str.replace(/^\s+|\s+$/g, '') |
| | | } |
| | | |
| | | export default clone |