Commit c5beccc0 authored by 田翔's avatar 田翔

fix: 代码提交

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