Commit c5beccc0 authored by 田翔's avatar 田翔

fix: 代码提交

parent 4de74f62
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "6.0.28", "version": "6.0.29",
"description": "6.0.28 台账选择器只读样式优化", "description": "6.0.29 高德三方地图更换为天地图",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -572,14 +572,20 @@ export function GetAreaNameByCoordinate({ sourceType, x, y }) { ...@@ -572,14 +572,20 @@ export function GetAreaNameByCoordinate({ sourceType, x, y }) {
//模糊搜索地名 //模糊搜索地名
export function searchAdress({ keywords, region }) { export function searchAdress({ keywords, region }) {
return request({ return request({
// headers: {
// 'Civ-Site': window?.globalConfig?.userInfo?.site
// },
url: `/pandagis/mapserver/Tool/PlaceAroundV2?key=6e0b74fa6de65506b360e2e801f8582f&keywords=${keywords}&region=${region}`, url: `/pandagis/mapserver/Tool/PlaceAroundV2?key=6e0b74fa6de65506b360e2e801f8582f&keywords=${keywords}&region=${region}`,
method: 'get' method: 'get'
}) })
} }
//后端转发地址
export function placeAroundRelay(url) {
return request({
url: `/pandagis/mapserver/Tool/PlaceAroundRelay`,
method: 'get',
params: { url }
})
}
//获取表字段 //获取表字段
export function LoadTableFields(paramas) { export function LoadTableFields(paramas) {
return request({ return request({
......
...@@ -11,8 +11,8 @@ import { ...@@ -11,8 +11,8 @@ import {
geomUtils, geomUtils,
} from '@wisdom-map/arcgismap' } from '@wisdom-map/arcgismap'
import Drag from '../../../components/Drag' import Drag from '../../../components/Drag'
import { isObject, mercatorToLngLat } from '../../../../utils' import { isJson, isObject, mercatorToLngLat } from '../../../../utils'
import { getLocation, getLocationV5, GetAreaNameByCoordinate } from '../../../../apis/process' import { getLocation, getLocationV5, GetAreaNameByCoordinate, placeAroundRelay } from '../../../../apis/process'
import styles from './index.less' import styles from './index.less'
const Coordinate = (props) => { const Coordinate = (props) => {
...@@ -170,14 +170,17 @@ const Coordinate = (props) => { ...@@ -170,14 +170,17 @@ const Coordinate = (props) => {
let targetPath = getTargetPath(addressSync) let targetPath = getTargetPath(addressSync)
if (targetPath) { if (targetPath) {
let LngLat = mercatorToLngLat(currentPointerCoordinate[0], currentPointerCoordinate[1]) let LngLat = mercatorToLngLat(currentPointerCoordinate[0], currentPointerCoordinate[1])
const { code, data } = await getLocationV5(LngLat.join(',')) let postStr = {
if (code === '0' && Array.isArray(data) && data.length) { lon: LngLat[0],
const { pname, adname, name, address } = data[0] lat: LngLat[1],
addons.setValue(targetPath, `${pname}/${adname}/${name}`) ver: 1,
} else { }
const { code, data } = await getLocation(LngLat.join(',')) let url = `http://api.tianditu.gov.cn/geocoder?postStr=${JSON.stringify(postStr)}&type=geocode&tk=a1d480f55b805db96e1ed295e62c72b1`
const { pname, adname, name, address } = data[0] const { code, data } = await placeAroundRelay(url)
addons.setValue(targetPath, `${pname}/${adname}/${name}`) if (code === '0' && isJson(data)) {
let res = JSON.parse(data) || {}
let text = res?.result?.addressComponent?.poi || res?.result?.formatted_address || ''
addons.setValue(targetPath, text)
} }
} }
} }
...@@ -198,14 +201,17 @@ const Coordinate = (props) => { ...@@ -198,14 +201,17 @@ const Coordinate = (props) => {
if (presetValue) { if (presetValue) {
let coordinate = presetValue.split(',') let coordinate = presetValue.split(',')
let LngLat = mercatorToLngLat(coordinate[0], coordinate[1]) let LngLat = mercatorToLngLat(coordinate[0], coordinate[1])
const { code, data } = await getLocationV5(LngLat.join(',')) let postStr = {
if (code === '0' && Array.isArray(data) && data.length) { lon: LngLat[0],
const { pname, adname, name, address } = data[0] lat: LngLat[1],
setText(`${pname}/${adname}/${name}`) ver: 1,
} else { }
const { code, data } = await getLocation(LngLat.join(',')) let url = `http://api.tianditu.gov.cn/geocoder?postStr=${JSON.stringify(postStr)}&type=geocode&tk=a1d480f55b805db96e1ed295e62c72b1`
const { pname, adname, name, address } = data[0] const { code, data } = await placeAroundRelay(url)
setText(`${pname}/${adname}/${name}`) if (code === '0' && isJson(data)) {
let res = JSON.parse(data) || {}
let text = res?.result?.addressComponent?.poi || res?.result?.formatted_address || ''
setText(text)
} }
} }
} }
......
import React, { useState, useEffect, useCallback } from 'react' import React, { useState, useEffect, useCallback } from 'react'
import { Input, AutoComplete, message, Popover, Select } from 'antd' import { Input, AutoComplete, message, Popover, Select } from 'antd'
import { searchAdress } from '../../../../apis/process' import { searchAdress, placeAroundRelay } from '../../../../apis/process'
import { debounce, lngmkt, isObject } from '../../../../utils/index' import { debounce, lngmkt, isObject, mercatorToLngLat, isJson } from '../../../../utils/index'
import { request } from '@wisdom-utils/utils'
const SearchLocation = (props) => { const SearchLocation = (props) => {
const areaName = window?.globalConfig?.mapsettings?.areasettings?.areaName || '' const areaName = window?.globalConfig?.mapsettings?.areasettings?.areaName || ''
...@@ -11,11 +11,19 @@ const SearchLocation = (props) => { ...@@ -11,11 +11,19 @@ const SearchLocation = (props) => {
const [options, setOptions] = useState([]) const [options, setOptions] = useState([])
const getAdress = async (value) => { const getAdress = async (value) => {
const { code, data } = await searchAdress({ keywords: `${areaName}${value}`, region: areaName }) let postStr = {
if (code === '0') { "keyWord": value,
setOptions(data?.pois) "queryType": 12,
"start": 0,
"count": 10,
specify: areaName,
}
const { code, data } = await placeAroundRelay(`http://api.tianditu.gov.cn/v2/search?postStr=${JSON.stringify(postStr)}&type=query&tk=a1d480f55b805db96e1ed295e62c72b1`)
if (code === '0' && isJson(data)) {
let res = JSON.parse(data) || {}
setOptions(res.pois || [])
} else { } else {
message.error('请求错误!') message.error('请求失败!')
} }
} }
...@@ -28,7 +36,7 @@ const SearchLocation = (props) => { ...@@ -28,7 +36,7 @@ const SearchLocation = (props) => {
} }
const onSelect = (value) => { const onSelect = (value) => {
let location = options.find(v => v.name === value)?.location let location = options.find(v => v.name === value)?.lonlat
if (location) { if (location) {
let array = location.split(',') let array = location.split(',')
let coord = lngmkt({ lng: array[0], lat: array[1] }) let coord = lngmkt({ lng: array[0], lat: array[1] })
...@@ -48,7 +56,7 @@ const SearchLocation = (props) => { ...@@ -48,7 +56,7 @@ const SearchLocation = (props) => {
}) })
} }
if (targetPath) { if (targetPath) {
addons.setValue(targetPath, `${coord.x},${coord.y}`) addons.setValue(targetPath, `${coord.x}, ${coord.y}`)
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment