diff --git a/src/components/Map/MapBox.vue b/src/components/Map/MapBox.vue index af67bbb..3fce5d1 100644 --- a/src/components/Map/MapBox.vue +++ b/src/components/Map/MapBox.vue @@ -400,24 +400,16 @@ const getModalData = () => { isClockInRange(); - const { setLayerVisible, setHighlight } = events_params; Object.keys(events_params) .filter((key) => events_params[key].method) .forEach((key) => busOn(events_params[key].key, events_params[key].method)); // 获取地图项目数据 dataToMap({}); - //5分钟刷新一次实时数据1000 * 60 * 5) - /* refreshTimer.value = setInterval(() => { - dataToMap({ params: { rainfall: {}, pipeline: {}, drainUutlet: {} } }); - }, 1000 * 60 * 5);*/ createPopup(); busEmit(events_params.closeAllLayer.key); proxy.$emit("loadCallback"); ww(); ysFlow(); - geoRegeo({lnglat:[114.364339,30.536334],callback:(results)=>{ - debugger; - }}); }; const ysFlow = (geojson) => { @@ -546,6 +538,7 @@ const data = result.data; const k = keys[idx]; if (!data) return; + if(k == keys[0]) appStore.SET_MapData(filterGeometryNotEmpty(data)); bus.emit("changeData"); const groups = data_default_params[k].groupMethod(data); const g_keys = Object.keys(groups); @@ -608,7 +601,7 @@ if (name) flag = "geo", params = `address=${name}`; if (lngLat) flag = "regeo", params = `location=${lngLat.join(',')}`; if(!(flag || params)) console.log('name,lngLat is null!'); - const results = await request(`/amap/v3/geocode/${flag}?${params}&extensions=all&output=json&key=f627fbb24176be73142eb0b5088d8683`); + const results = await request(`/amap/v3/geocode/${flag}?${params}&extensions=all&output=json&key=f627fbb24176be73142eb0b5088d8683&city=420111`); console.log('geoRegeo results',results); callback && callback(results); }; diff --git a/src/components/Map/MapBox.vue b/src/components/Map/MapBox.vue index af67bbb..3fce5d1 100644 --- a/src/components/Map/MapBox.vue +++ b/src/components/Map/MapBox.vue @@ -400,24 +400,16 @@ const getModalData = () => { isClockInRange(); - const { setLayerVisible, setHighlight } = events_params; Object.keys(events_params) .filter((key) => events_params[key].method) .forEach((key) => busOn(events_params[key].key, events_params[key].method)); // 获取地图项目数据 dataToMap({}); - //5分钟刷新一次实时数据1000 * 60 * 5) - /* refreshTimer.value = setInterval(() => { - dataToMap({ params: { rainfall: {}, pipeline: {}, drainUutlet: {} } }); - }, 1000 * 60 * 5);*/ createPopup(); busEmit(events_params.closeAllLayer.key); proxy.$emit("loadCallback"); ww(); ysFlow(); - geoRegeo({lnglat:[114.364339,30.536334],callback:(results)=>{ - debugger; - }}); }; const ysFlow = (geojson) => { @@ -546,6 +538,7 @@ const data = result.data; const k = keys[idx]; if (!data) return; + if(k == keys[0]) appStore.SET_MapData(filterGeometryNotEmpty(data)); bus.emit("changeData"); const groups = data_default_params[k].groupMethod(data); const g_keys = Object.keys(groups); @@ -608,7 +601,7 @@ if (name) flag = "geo", params = `address=${name}`; if (lngLat) flag = "regeo", params = `location=${lngLat.join(',')}`; if(!(flag || params)) console.log('name,lngLat is null!'); - const results = await request(`/amap/v3/geocode/${flag}?${params}&extensions=all&output=json&key=f627fbb24176be73142eb0b5088d8683`); + const results = await request(`/amap/v3/geocode/${flag}?${params}&extensions=all&output=json&key=f627fbb24176be73142eb0b5088d8683&city=420111`); console.log('geoRegeo results',results); callback && callback(results); }; diff --git a/src/utils/request.js b/src/utils/request.js index 908f693..ee1ff6d 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -30,9 +30,7 @@ if (getToken() && !isToken) { config.headers['Authorization'] = 'Bearer ' + getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改 } - if (config.url.indexOf('/v3/geocode/regeo') > -1) { - config.baseURL = '/'; - } + if (config.method === 'get' && config.params) { // get请求映射params参数 diff --git a/src/components/Map/MapBox.vue b/src/components/Map/MapBox.vue index af67bbb..3fce5d1 100644 --- a/src/components/Map/MapBox.vue +++ b/src/components/Map/MapBox.vue @@ -400,24 +400,16 @@ const getModalData = () => { isClockInRange(); - const { setLayerVisible, setHighlight } = events_params; Object.keys(events_params) .filter((key) => events_params[key].method) .forEach((key) => busOn(events_params[key].key, events_params[key].method)); // 获取地图项目数据 dataToMap({}); - //5分钟刷新一次实时数据1000 * 60 * 5) - /* refreshTimer.value = setInterval(() => { - dataToMap({ params: { rainfall: {}, pipeline: {}, drainUutlet: {} } }); - }, 1000 * 60 * 5);*/ createPopup(); busEmit(events_params.closeAllLayer.key); proxy.$emit("loadCallback"); ww(); ysFlow(); - geoRegeo({lnglat:[114.364339,30.536334],callback:(results)=>{ - debugger; - }}); }; const ysFlow = (geojson) => { @@ -546,6 +538,7 @@ const data = result.data; const k = keys[idx]; if (!data) return; + if(k == keys[0]) appStore.SET_MapData(filterGeometryNotEmpty(data)); bus.emit("changeData"); const groups = data_default_params[k].groupMethod(data); const g_keys = Object.keys(groups); @@ -608,7 +601,7 @@ if (name) flag = "geo", params = `address=${name}`; if (lngLat) flag = "regeo", params = `location=${lngLat.join(',')}`; if(!(flag || params)) console.log('name,lngLat is null!'); - const results = await request(`/amap/v3/geocode/${flag}?${params}&extensions=all&output=json&key=f627fbb24176be73142eb0b5088d8683`); + const results = await request(`/amap/v3/geocode/${flag}?${params}&extensions=all&output=json&key=f627fbb24176be73142eb0b5088d8683&city=420111`); console.log('geoRegeo results',results); callback && callback(results); }; diff --git a/src/utils/request.js b/src/utils/request.js index 908f693..ee1ff6d 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -30,9 +30,7 @@ if (getToken() && !isToken) { config.headers['Authorization'] = 'Bearer ' + getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改 } - if (config.url.indexOf('/v3/geocode/regeo') > -1) { - config.baseURL = '/'; - } + if (config.method === 'get' && config.params) { // get请求映射params参数 diff --git a/src/views/pictureOnMap/inputSearch.vue b/src/views/pictureOnMap/inputSearch.vue index b30703a..92e9af0 100644 --- a/src/views/pictureOnMap/inputSearch.vue +++ b/src/views/pictureOnMap/inputSearch.vue @@ -67,7 +67,13 @@ // 值改变后的操作 function selectchange(value) { - if (value) { + if(value){ + let feature = turf.feature(Terraformer.WKT.parse(value)); + bus.emit('setHighlight',feature); + newfiberMap.map.easeTo({center:turf.getCoords(turf.center(feature)),zoom:15}); + } + +/* if (value) { // 选中的操作 let arr = SelectList.value.filter(item => { return item.geometry == value; @@ -79,17 +85,18 @@ } else { // 清除的操作 console.log('清除change', getItem.value); - } + }*/ } - -function filterMethod(value) { - console.log('filterMethod', value); +const filterMethod = _.debounce((value) => { if (value) { filterList.value = SelectList.value.filter(item => item.name.includes(value)); + if(filterList.value.length == 0) bus.emit('geoRegeo',{name:value,callback:(results)=>{ + filterList.value = results.geocodes.map((i,idx) => ({id:idx,name:i.formatted_address,geometry:`POINT(${gcoord.transform(i.location.split(','),gcoord.AMap,gcoord.WGS84).join(' ')})`,pointTypeName:"POI"})) + }}) } else { filterList.value = SelectList.value; } -} +},500) onMounted(() => { bus.on('YQ_head', val => { diff --git a/src/components/Map/MapBox.vue b/src/components/Map/MapBox.vue index af67bbb..3fce5d1 100644 --- a/src/components/Map/MapBox.vue +++ b/src/components/Map/MapBox.vue @@ -400,24 +400,16 @@ const getModalData = () => { isClockInRange(); - const { setLayerVisible, setHighlight } = events_params; Object.keys(events_params) .filter((key) => events_params[key].method) .forEach((key) => busOn(events_params[key].key, events_params[key].method)); // 获取地图项目数据 dataToMap({}); - //5分钟刷新一次实时数据1000 * 60 * 5) - /* refreshTimer.value = setInterval(() => { - dataToMap({ params: { rainfall: {}, pipeline: {}, drainUutlet: {} } }); - }, 1000 * 60 * 5);*/ createPopup(); busEmit(events_params.closeAllLayer.key); proxy.$emit("loadCallback"); ww(); ysFlow(); - geoRegeo({lnglat:[114.364339,30.536334],callback:(results)=>{ - debugger; - }}); }; const ysFlow = (geojson) => { @@ -546,6 +538,7 @@ const data = result.data; const k = keys[idx]; if (!data) return; + if(k == keys[0]) appStore.SET_MapData(filterGeometryNotEmpty(data)); bus.emit("changeData"); const groups = data_default_params[k].groupMethod(data); const g_keys = Object.keys(groups); @@ -608,7 +601,7 @@ if (name) flag = "geo", params = `address=${name}`; if (lngLat) flag = "regeo", params = `location=${lngLat.join(',')}`; if(!(flag || params)) console.log('name,lngLat is null!'); - const results = await request(`/amap/v3/geocode/${flag}?${params}&extensions=all&output=json&key=f627fbb24176be73142eb0b5088d8683`); + const results = await request(`/amap/v3/geocode/${flag}?${params}&extensions=all&output=json&key=f627fbb24176be73142eb0b5088d8683&city=420111`); console.log('geoRegeo results',results); callback && callback(results); }; diff --git a/src/utils/request.js b/src/utils/request.js index 908f693..ee1ff6d 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -30,9 +30,7 @@ if (getToken() && !isToken) { config.headers['Authorization'] = 'Bearer ' + getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改 } - if (config.url.indexOf('/v3/geocode/regeo') > -1) { - config.baseURL = '/'; - } + if (config.method === 'get' && config.params) { // get请求映射params参数 diff --git a/src/views/pictureOnMap/inputSearch.vue b/src/views/pictureOnMap/inputSearch.vue index b30703a..92e9af0 100644 --- a/src/views/pictureOnMap/inputSearch.vue +++ b/src/views/pictureOnMap/inputSearch.vue @@ -67,7 +67,13 @@ // 值改变后的操作 function selectchange(value) { - if (value) { + if(value){ + let feature = turf.feature(Terraformer.WKT.parse(value)); + bus.emit('setHighlight',feature); + newfiberMap.map.easeTo({center:turf.getCoords(turf.center(feature)),zoom:15}); + } + +/* if (value) { // 选中的操作 let arr = SelectList.value.filter(item => { return item.geometry == value; @@ -79,17 +85,18 @@ } else { // 清除的操作 console.log('清除change', getItem.value); - } + }*/ } - -function filterMethod(value) { - console.log('filterMethod', value); +const filterMethod = _.debounce((value) => { if (value) { filterList.value = SelectList.value.filter(item => item.name.includes(value)); + if(filterList.value.length == 0) bus.emit('geoRegeo',{name:value,callback:(results)=>{ + filterList.value = results.geocodes.map((i,idx) => ({id:idx,name:i.formatted_address,geometry:`POINT(${gcoord.transform(i.location.split(','),gcoord.AMap,gcoord.WGS84).join(' ')})`,pointTypeName:"POI"})) + }}) } else { filterList.value = SelectList.value; } -} +},500) onMounted(() => { bus.on('YQ_head', val => { diff --git a/vite.config.js b/vite.config.js index f3be87d..60defb5 100644 --- a/vite.config.js +++ b/vite.config.js @@ -66,10 +66,10 @@ changeOrigin: true, rewrite: p => p.replace(/^\/code/, '/code'), }, - '/amap': { + '/prod-api/amap': { target: 'https://restapi.amap.com', //geocode服务 changeOrigin: true, - rewrite: p => p.replace("/amap", ''), + rewrite: p => p.replace("/prod-api/amap", ''), }, '/prod-api': { target: ipLink,