|
@@ -209,7 +209,8 @@
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
import {onMounted, reactive, ref} from "vue";
|
|
import {onMounted, reactive, ref} from "vue";
|
|
import huiZhouGeoJSON from "./geo"
|
|
import huiZhouGeoJSON from "./geo"
|
|
-import {getPosition} from "@/utils/position";
|
|
|
|
|
|
+import {getPosition, setBoundary} from "@/utils/position";
|
|
|
|
+import redThIcon from "@/assets/images/redTh.png"
|
|
import thIcon from "@/assets/images/th.jpg"
|
|
import thIcon from "@/assets/images/th.jpg"
|
|
import {message, type SelectProps} from "ant-design-vue";
|
|
import {message, type SelectProps} from "ant-design-vue";
|
|
import {getSysDictionaryList} from "@/api/system/dictionary";
|
|
import {getSysDictionaryList} from "@/api/system/dictionary";
|
|
@@ -362,41 +363,14 @@ const initMap = () => {
|
|
}
|
|
}
|
|
|
|
|
|
// 设置城市边界
|
|
// 设置城市边界
|
|
- setBoundary()
|
|
|
|
|
|
+ setBoundary(map, T, huiZhouGeoJSON);
|
|
|
|
|
|
// 设置登录用户的定位
|
|
// 设置登录用户的定位
|
|
setLoginLocation();
|
|
setLoginLocation();
|
|
};
|
|
};
|
|
|
|
|
|
-// 设置惠州市边界
|
|
|
|
-function setBoundary() {
|
|
|
|
- if (map != null) {
|
|
|
|
- const points = new Array<any>();
|
|
|
|
- huiZhouGeoJSON.geometry.coordinates.forEach(subset => {
|
|
|
|
- subset.forEach((item: any) => {
|
|
|
|
- item.forEach((coord: any) => {
|
|
|
|
- const point = new T.LngLat(coord[0], coord[1]);
|
|
|
|
-
|
|
|
|
- points.push(point);
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- });
|
|
|
|
- const polygon = new T.Polygon(points, {
|
|
|
|
- color: "deepskyblue",
|
|
|
|
- weight: 3,
|
|
|
|
- opacity: 0.8,
|
|
|
|
- fillColor: "LightCyan",
|
|
|
|
- fillOpacity: 0.65
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- // 添加多边形到地图
|
|
|
|
- (map as any).addOverLay(polygon);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// 获取当前登录用户定位
|
|
// 获取当前登录用户定位
|
|
function setLoginLocation() {
|
|
function setLoginLocation() {
|
|
- let labelText = "定位位置"
|
|
|
|
getPosition().then((data: any) => {
|
|
getPosition().then((data: any) => {
|
|
if (data.longitude && data.latitude) {
|
|
if (data.longitude && data.latitude) {
|
|
companySearchParam.longitude = data.longitude;
|
|
companySearchParam.longitude = data.longitude;
|
|
@@ -411,22 +385,16 @@ function setLoginLocation() {
|
|
// 设置中心点
|
|
// 设置中心点
|
|
(map as any).centerAndZoom(new T.LngLat(companySearchParam.longitude, companySearchParam.latitude), 12);
|
|
(map as any).centerAndZoom(new T.LngLat(companySearchParam.longitude, companySearchParam.latitude), 12);
|
|
const icon = new T.Icon({
|
|
const icon = new T.Icon({
|
|
- iconUrl: thIcon,
|
|
|
|
- iconSize: new T.Point(30, 30),
|
|
|
|
- iconAnchor: new T.Point(10, 56)
|
|
|
|
- })
|
|
|
|
- const label = new T.Label({
|
|
|
|
- text: labelText, //文本标注的内容
|
|
|
|
- position: new T.LngLat(companySearchParam.longitude, companySearchParam.latitude), //文本标注的地理位置
|
|
|
|
- offset: new T.Point(-45, 20) //文本标注的位置偏移值
|
|
|
|
- })
|
|
|
|
- const point = new T.LngLat(companySearchParam.longitude, companySearchParam.latitude, {
|
|
|
|
- icon: icon
|
|
|
|
|
|
+ iconUrl: redThIcon,
|
|
|
|
+ iconSize: new T.Point(50, 50),
|
|
|
|
+ iconAnchor: new T.Point(25, 50)
|
|
})
|
|
})
|
|
|
|
+ const point = new T.LngLat(companySearchParam.longitude, companySearchParam.latitude)
|
|
// 创建标注
|
|
// 创建标注
|
|
- const marker = new T.Marker(point);
|
|
|
|
|
|
+ const marker = new T.Marker(point, {
|
|
|
|
+ icon: icon
|
|
|
|
+ });
|
|
//向地图上标记
|
|
//向地图上标记
|
|
- (map as any).addOverLay(label);
|
|
|
|
(map as any).addOverLay(marker);
|
|
(map as any).addOverLay(marker);
|
|
onSearch();
|
|
onSearch();
|
|
})
|
|
})
|
|
@@ -440,37 +408,22 @@ function setCompanyMarker() {
|
|
(map as any).removeOverLay(markerList[i]);
|
|
(map as any).removeOverLay(markerList[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (labelList.length > 0) {
|
|
|
|
- for (let i = 0; i < labelList.length; i++) {
|
|
|
|
- (map as any).removeOverLay(labelList[i]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 设置中心点
|
|
|
|
- (map as any).centerAndZoom(new T.LngLat(companySearchParam.longitude, companySearchParam.latitude), 12);
|
|
|
|
|
|
|
|
if (companyList.value.length > 0) {
|
|
if (companyList.value.length > 0) {
|
|
// 设置图标
|
|
// 设置图标
|
|
const icon = new T.Icon({
|
|
const icon = new T.Icon({
|
|
- iconUrl: thIcon,
|
|
|
|
- iconSize: new T.Point(20, 20),
|
|
|
|
- iconAnchor: new T.Point(10, 56)
|
|
|
|
|
|
+ iconUrl: redThIcon,
|
|
|
|
+ iconSize: new T.Point(30, 30),
|
|
|
|
+ iconAnchor: new T.Point(15, 30)
|
|
})
|
|
})
|
|
// 解析企业数据,在地图中标记
|
|
// 解析企业数据,在地图中标记
|
|
companyList.value.forEach((item: any) => {
|
|
companyList.value.forEach((item: any) => {
|
|
if (item.longitude && item.latitude) {
|
|
if (item.longitude && item.latitude) {
|
|
- const label = new T.Label({
|
|
|
|
- text: item.companyName, //文本标注的内容
|
|
|
|
- position: new T.LngLat(item.longitude, item.latitude), //文本标注的地理位置
|
|
|
|
- offset: new T.Point(-70, 20) //文本标注的位置偏移值
|
|
|
|
- })
|
|
|
|
- const point = new T.LngLat(item.longitude, item.latitude, {
|
|
|
|
|
|
+ const point = new T.LngLat(item.longitude, item.latitude)
|
|
|
|
+ const marker = new T.Marker(point, {
|
|
icon: icon
|
|
icon: icon
|
|
- })
|
|
|
|
- const marker = new T.Marker(point); // 创建标注
|
|
|
|
- (map as any).addOverLay(label); // 将标注添加到地图中
|
|
|
|
|
|
+ }); // 创建标注
|
|
(map as any).addOverLay(marker);// 将标注添加到地图中
|
|
(map as any).addOverLay(marker);// 将标注添加到地图中
|
|
- labelList.push(label);
|
|
|
|
markerList.push(marker);
|
|
markerList.push(marker);
|
|
}
|
|
}
|
|
})
|
|
})
|