派生自 wuyushui/SewerAndRainNetwork

陈泽平
2021-05-30 0110b78419d98e114c59fa9fb6f69663fbdc3c98
src/components/helpers/LocateHelper.js
@@ -10,21 +10,31 @@
export const locate = function (feature, config, filter) {
  fitBounds(feature)
  highlight(feature, config.icon)
  const centerPoint = getCenterPoint(feature)
  const params = { LAYERS: config.layerGroup || config.typeName, QUERY_LAYERS: config.layerGroup || config.typeName }
  const filters = []
  if (config.filter) {
    filters[filters.length] = config.filter
  }
  if (filter) {
    filters[filters.length] = filter
  }
  if (filters.length > 0) {
    params.CQL_FILTER = filters.join(' AND ')
  }
  console.log(centerPoint)
  loadPointWfs(centerPoint, params)
}
/**
 * 加载点范围的wfs数据并弹窗
 * @param latlng  点的经纬度坐标
 * @param params
 */
export const loadPointWfs = function (latlng, params) {
  setTimeout(() => {
    const centerPoint = getCenterPoint(feature)
    const params = { LAYERS: config.layerGroup || config.typeName, QUERY_LAYERS: config.layerGroup || config.typeName }
    const filters = []
    if (config.filter) {
      filters[filters.length] = config.filter
    }
    if (filter) {
      filters[filters.length] = filter
    }
    if (filters.length > 0) {
      params.CQL_FILTER = filters.join(' AND ')
    }
    window.mapManager.loadWfsDatas(centerPoint, params).then((res) => {
      openPropsPopup(centerPoint, res.features)
    window.mapManager.loadWfsDatas(latlng, params).then((res) => {
      openPropsPopup(latlng, res.features)
    })
  }, 1000)
}
@@ -38,7 +48,7 @@
  if (type === 'Point') {
    var point = feature.geometry.coordinates
    point = [point[1], point[0]]
    window.map.setView(point, 17)
    window.map.setView(point, 19)
  } else {
    window.map.fitBounds(window.L.geoJSON(feature).getBounds())
  }
@@ -58,16 +68,7 @@
    // 叠加一个大尺寸的图标
    let point = feature.geometry.coordinates
    point = [point[1], point[0]]
    if (icon) {
      L.marker(point, {
        icon: L.icon({
          iconUrl: '/assets/images/map/' + icon,
          iconSize: [30, 30],
          iconAnchor: [15, 15]
        })
      }).addTo(highlightLayer)
    }
    pointZoom(point, icon)
    pulseEffect(point)
  } else {
    L.geoJSON(feature, {
@@ -76,6 +77,25 @@
          color: 'red'
        }
      }
    }).addTo(highlightLayer)
  }
}
/**
 * 高亮点位图标
 * @param latlng  经纬度
 * @param icon    图标
 */
export const pointZoom = function (latlng, icon) {
  const L = window.L
  const highlightLayer = window.mapManager.hightlightLayer
  if (icon) {
    L.marker(latlng, {
      icon: L.icon({
        iconUrl: '/assets/images/map/' + icon,
        iconSize: [30, 30],
        iconAnchor: [15, 15]
      })
    }).addTo(highlightLayer)
  }
}
@@ -111,8 +131,10 @@
  if (type === 'Point') {
    return [coordinates[1], coordinates[0]]
  } else {
    const center = L.geoJSON(feature, {}).getBounds().getCenter()
    return [center.lat, center.lng]
    return L.geoJSON(feature, {}).getBounds().getSouthWest()
    // return [center.lat, center.lng]
    // return turf.centerOfMass(L.geoJSON(feature, {}).toGeoJSON())
  }
}