flat: 地图

This commit is contained in:
史典卓
2024-10-24 14:42:47 +08:00
parent ba14872e89
commit 7845b6333c
36 changed files with 6301 additions and 5312 deletions

View File

@@ -1,230 +1,254 @@
<template>
<view class="body" @click="goInfo(companyitem)">
<view class="heads">
<view class="head_left">
<rich-text :nodes="string">
</rich-text>
</view>
<view class="head_right">
{{ companyitem.wage }}{{ wageUnit[companyitem.wageUnitCategory] }}
</view>
</view>
<view class="ask">
<view class="askList">
{{ companyitem.tradeNames }}
</view>
<view class="askList" v-for="(item, index) in skillNames" :key="index">
{{ item }}
</view>
<view style="flex:1;"></view>
<u-tag text="零工岗位" v-if="companyitem.type == 0" plain size="mini" type="warning"></u-tag>
<u-tag text="全职岗位" v-if="companyitem.type == 1" plain size="mini"></u-tag>
<u-tag text="招工" v-if="companyitem.type == 2" plain size="mini"></u-tag>
</view>
<view style="width: 100%;height: 1rpx;background-color: #999;margin: 0 auto;opacity: .5;"></view>
<view class="timeAddress" style="position: relative;">
<view style="display: flex;align-items: center;">
<image src="../../static/img/city.png" style="width: 40rpx;height: 40rpx;margin-right: 10rpx;" mode="">
</image>
<view style="font-size: 26rpx;color:#333;">{{ companyitem.missionCompanyName }}</view>
</view>
<view style="display: flex;align-items: center;position:absolute;right:0;">
<image src="../../static/img/location_new.png" style="width: 30rpx;height: 30rpx;" mode=""></image>
<view>--km</view>
</view>
</view>
<view class="comment" v-if='comment' @tap.stop="goComment(companyitem.missionNo)">
<view class="comment_content commentimg" v-if='companyitem.scoreAll > 0'>
<image class="commentimg_image" src="../../static/img/star.full.svg"
v-for="index1 in companyitem.scoreAll" mode="" :key="index1"></image>
<image class="commentimg_image" src="../../static/img/star.empty.svg"
v-for="index2 in (5 - companyitem.scoreAll)" mode="" :key="index2"></image>
</view>
<view class="comment_content allName gocomment" v-else>
评价
</view>
</view>
</view>
</template>
<script>
import {
toDoller,
dateFormat
} from "../../untils/format.js";
import dictionary from '@/common/textdata.js';
export default {
beforeCreate: function() {},
props: {
companyitem: {
type: Object,
default () {
return []
}
},
comment: {
type: Boolean,
default: false
},
noApply: {
type: Boolean,
default: true
},
near: {
type: Boolean,
default: false
}
},
data() {
return {
...dictionary,
string: "<div style='overflow: hidden;white-space: nowrap;text-overflow: ellipsis;'>" + this.companyitem
.missionTitle +
"</div>"
};
},
computed: {
skillNames() {
return this.companyitem.skillNames?.split(',')
}
},
methods: {
goComment: function(no) {
uni.navigateTo({
url: `../../pageMy/mycomment/mycomment?missionNo=${encodeURIComponent(no)}`
})
},
goInfo: function(item) {
// const isCan = this.noApply === false ? '0' : '1'
if (item.type == 0) {
uni.navigateTo({
url: `/pages/projectInfo/projectInfo?missionNo=${encodeURIComponent(item.missionNo)}&isCan=1`
})
} else if (item.type == 1) {
uni.navigateTo({
url: `/pages/projectInfo/workInfo?workId=${encodeURIComponent(item.id)}&isCan=1`
})
}
},
getCity: function(val) {
if (val) {
let areas = this.$store.getters.getAreaParents(val)
if (areas.length === 3) {
return areas[0].label + '-' + areas[1].label + '-' + areas[2].label
}
}
},
toDoller,
dateFormat
}
}
</script>
<style>
.commentimg_image {
width: 40rpx;
height: 40rpx;
}
.commentimg {
display: flex;
align-items: center;
justify-content: flex-end;
}
.gocomment {
font-size: 26rpx !important;
border-radius: 5rpx;
border: 1rpx solid #c3c3c3;
width: 160rpx;
text-align: center;
float: right;
height: 50rpx;
line-height: 50rpx;
}
.timeAddress {
display: flex;
align-items: center;
justify-content: space-between;
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #999999;
margin: 10rpx 0;
padding: 10rpx 0;
}
.allName {
font-family: PingFangSC-Regular;
font-size: 28rpx;
color: #666666;
}
.askList {
/* width: 14%; */
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #666666;
background-color: #f6f6f6;
padding: 5rpx 15rpx;
margin-right: 10rpx;
margin-bottom: 10rpx;
}
.ask {
overflow: hidden;
width: 100%;
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: flex-start;
margin: 20rpx 0;
}
.head_right {
ont-family: PingFangSC-Medium;
font-size: 28rpx;
color: #F46161;
font-weight: bold;
}
.head_left {
font-family: PingFangSC-Medium;
font-size: 32rpx;
font-weight: bold;
color: #333333;
width: 350rpx;
overflow: hidden;
white-space: nowrap;
/*不换行*/
text-overflow: ellipsis;
/*超出部分文字以...显示*/
}
.highlight {
color: #F46161;
}
.body {
width: 690rpx;
margin: 0rpx auto;
background-color: #fefefe;
overflow: hidden;
box-sizing: border-box;
padding: 20rpx;
padding-bottom: 0;
border-radius: 20rpx;
margin-top: 20rpx;
}
.heads {
display: flex;
align-items: center;
justify-content: space-between;
}
<template>
<view class="body" @click="goInfo(companyitem)">
<view class="heads">
<view class="head_left">
<rich-text :nodes="string">
</rich-text>
</view>
<view class="head_right">
{{ companyitem.wage }}{{ wageUnit[companyitem.wageUnitCategory] }}
</view>
</view>
<view class="ask">
<view class="askList">
{{ companyitem.tradeNames }}
</view>
<view class="askList" v-for="(item, index) in skillNames" :key="index">
{{ item }}
</view>
<view style="flex:1;"></view>
<u-tag text="零工岗位" v-if="companyitem.type == 0" plain size="mini" type="warning"></u-tag>
<u-tag text="全职岗位" v-if="companyitem.type == 1" plain size="mini"></u-tag>
<u-tag text="招工" v-if="companyitem.type == 2" plain size="mini"></u-tag>
</view>
<view style="width: 100%;height: 1rpx;background-color: #999;margin: 0 auto;opacity: .5;"></view>
<view class="timeAddress" style="position: relative;">
<view style="display: flex;align-items: center;">
<image src="../../static/img/city.png" style="width: 40rpx;height: 40rpx;margin-right: 10rpx;" mode="">
</image>
<view style="font-size: 26rpx;color:#333;">{{ companyitem.missionCompanyName }}</view>
</view>
<view style="display: flex;align-items: center;position:absolute;right:0;">
<image src="../../static/img/location_new.png" style="width: 30rpx;height: 30rpx;" mode=""></image>
<view>{{distance(companyitem)}}</view>
</view>
</view>
<view class="comment" v-if='comment' @tap.stop="goComment(companyitem.missionNo)">
<view class="comment_content commentimg" v-if='companyitem.scoreAll > 0'>
<image class="commentimg_image" src="../../static/img/star.full.svg"
v-for="index1 in companyitem.scoreAll" mode="" :key="index1"></image>
<image class="commentimg_image" src="../../static/img/star.empty.svg"
v-for="index2 in (5 - companyitem.scoreAll)" mode="" :key="index2"></image>
</view>
<view class="comment_content allName gocomment" v-else>
评价
</view>
</view>
</view>
</template>
<script>
import {
toDoller,
dateFormat
} from "../../untils/format.js";
import dictionary from '@/common/textdata.js';
import {
addZeroPrefix,
getDistanceFromLatLonInKm
} from '@/untils/tools.js'
export default {
beforeCreate: function() {},
props: {
companyitem: {
type: Object,
default () {
return []
}
},
comment: {
type: Boolean,
default: false
},
noApply: {
type: Boolean,
default: true
},
near: {
type: Boolean,
default: false
},
position: {
default: null
}
},
data() {
return {
...dictionary,
string: "<div style='overflow: hidden;white-space: nowrap;text-overflow: ellipsis;'>" + this.companyitem
.missionTitle +
"</div>"
};
},
computed: {
skillNames() {
return this.companyitem.skillNames?.split(',')
}
},
methods: {
distance(item) {
const {
lon,
lat
} = item
if (this.position && lon > 0) {
const {
longitude,
latitude
} = this.position
const {
m,
km
} = getDistanceFromLatLonInKm(lat, lon, latitude, longitude)
return m > 1000 ? `${km.toFixed(2)}km` : `${m.toFixed(2)}m`
}
return '--km'
},
goComment: function(no) {
uni.navigateTo({
url: `../../pageMy/mycomment/mycomment?missionNo=${encodeURIComponent(no)}`
})
},
goInfo: function(item) {
// const isCan = this.noApply === false ? '0' : '1'
if (item.type == 0) {
uni.navigateTo({
url: `/pages/projectInfo/projectInfo?missionNo=${encodeURIComponent(item.missionNo)}&isCan=1`
})
} else if (item.type == 1) {
uni.navigateTo({
url: `/pages/projectInfo/workInfo?workId=${encodeURIComponent(item.id)}&isCan=1`
})
}
},
getCity: function(val) {
if (val) {
let areas = this.$store.getters.getAreaParents(val)
if (areas.length === 3) {
return areas[0].label + '-' + areas[1].label + '-' + areas[2].label
}
}
},
toDoller,
dateFormat
}
}
</script>
<style>
.commentimg_image {
width: 40rpx;
height: 40rpx;
}
.commentimg {
display: flex;
align-items: center;
justify-content: flex-end;
}
.gocomment {
font-size: 26rpx !important;
border-radius: 5rpx;
border: 1rpx solid #c3c3c3;
width: 160rpx;
text-align: center;
float: right;
height: 50rpx;
line-height: 50rpx;
}
.timeAddress {
display: flex;
align-items: center;
justify-content: space-between;
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #999999;
margin: 10rpx 0;
padding: 10rpx 0;
}
.allName {
font-family: PingFangSC-Regular;
font-size: 28rpx;
color: #666666;
}
.askList {
/* width: 14%; */
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #666666;
background-color: #f6f6f6;
padding: 5rpx 15rpx;
margin-right: 10rpx;
margin-bottom: 10rpx;
}
.ask {
overflow: hidden;
width: 100%;
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: flex-start;
margin: 20rpx 0;
}
.head_right {
ont-family: PingFangSC-Medium;
font-size: 28rpx;
color: #F46161;
font-weight: bold;
}
.head_left {
font-family: PingFangSC-Medium;
font-size: 32rpx;
font-weight: bold;
color: #333333;
width: 350rpx;
overflow: hidden;
white-space: nowrap;
/*不换行*/
text-overflow: ellipsis;
/*超出部分文字以...显示*/
}
.highlight {
color: #F46161;
}
.body {
width: 690rpx;
margin: 0rpx auto;
background-color: #fefefe;
overflow: hidden;
box-sizing: border-box;
padding: 20rpx;
padding-bottom: 0;
border-radius: 20rpx;
margin-top: 20rpx;
}
.heads {
display: flex;
align-items: center;
justify-content: space-between;
}
</style>

View File

@@ -1,244 +1,268 @@
<template>
<view class="body" @click="goInfo(companyitem)">
<view class="heads">
<view class="head_left">
<rich-text :nodes="string">
</rich-text>
</view>
<view class="head_right">
{{ companyitem.wage }}{{ wageUnit[companyitem.wageUnitCategory] }}
</view>
</view>
<view class="ask">
<view class="askList">
{{ companyitem.tradeNames }}
</view>
<view class="askList" v-for="(item, index) in skillNames" :key="index">
{{ item }}
</view>
<view style="flex:1;"></view>
<u-tag text="零工岗位" v-if="companyitem.type == 0" plain size="mini" type="warning"></u-tag>
<u-tag text="全职岗位" v-if="companyitem.type == 1" plain size="mini"></u-tag>
<u-tag text="招工" v-if="companyitem.type == 2" plain size="mini"></u-tag>
</view>
<view style="width: 100%;height: 1rpx;background-color: #999;margin: 0 auto;opacity: .5;"></view>
<view class="timeAddress" style="position: relative;">
<view style="display: flex;align-items: center;">
<image src="../../static/img/city.png" style="width: 40rpx;height: 40rpx;margin-right: 10rpx;" mode="">
</image>
<view style="font-size: 26rpx;color:#333;">{{ companyitem.missionCompanyName }}</view>
</view>
<view style="display: flex;align-items: center;position:absolute;right:0;">
<image src="../../static/img/location_new.png" style="width: 30rpx;height: 30rpx;" mode=""></image>
<view>--km</view>
</view>
</view>
<view class="comment" v-if='comment' @tap.stop="goComment(companyitem.missionNo)">
<view class="comment_content commentimg" v-if='companyitem.scoreAll > 0'>
<image class="commentimg_image" src="../../static/img/star.full.svg"
v-for="index1 in companyitem.scoreAll" mode="" :key="index1"></image>
<image class="commentimg_image" src="../../static/img/star.empty.svg"
v-for="index2 in (5 - companyitem.scoreAll)" mode="" :key="index2"></image>
</view>
<view class="comment_content allName gocomment" v-else>
评价
</view>
</view>
</view>
</template>
<script>
import {
toDoller,
dateFormat
} from "../../untils/format.js";
import dictionary from '@/common/textdata.js';
import {
defaults
} from "lodash";
export default {
beforeCreate: function() {},
props: {
companyitem: {
type: Object,
default () {
return []
}
},
comment: {
type: Boolean,
default: false
},
noApply: {
type: Boolean,
default: true
},
near: {
type: Boolean,
default: false
}
},
data() {
return {
...dictionary,
string: "<div style='overflow: hidden;white-space: nowrap;text-overflow: ellipsis;'>" + this.companyitem
.missionTitle +
"</div>"
};
},
computed: {
skillNames() {
if (this.companyitem.skillNames) {
return this.companyitem.skillNames?.split(',')
} else {
return []
}
}
},
methods: {
goComment: function(no) {
uni.navigateTo({
url: `../../pageMy/mycomment/mycomment?missionNo=${encodeURIComponent(no)}`
})
},
goInfo: function(item) {
// const isCan = this.noApply === false ? '0' : '1'
switch (item.type) {
case 0:
this.navTo(
`/pages/projectInfo/projectInfo?missionNo=${encodeURIComponent(item.missionNo)}&isCan=1`
)
break
case 1:
this.navTo(`/pages/projectInfo/workInfo?workId=${encodeURIComponent(item.id)}&isCan=1`)
break
case 2:
this.navTo(`/pages/projectInfo/workInfo?workId=${encodeURIComponent(item.id)}&isCan=1`)
break
default:
this.navTo(`/pages/projectInfo/workInfo?workId=${encodeURIComponent(item.id)}&isCan=1`)
}
},
getCity: function(val) {
if (val) {
let areas = this.$store.getters.getAreaParents(val)
if (areas.length === 3) {
return areas[0].label + '-' + areas[1].label + '-' + areas[2].label
}
}
},
toDoller,
dateFormat
}
}
</script>
<style>
.commentimg_image {
width: 40rpx;
height: 40rpx;
}
.commentimg {
display: flex;
align-items: center;
justify-content: flex-end;
}
.gocomment {
font-size: 26rpx !important;
border-radius: 5rpx;
border: 1rpx solid #c3c3c3;
width: 160rpx;
text-align: center;
float: right;
height: 50rpx;
line-height: 50rpx;
}
.timeAddress {
display: flex;
align-items: center;
justify-content: space-between;
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #999999;
margin: 10rpx 0;
padding: 10rpx 0;
}
.allName {
font-family: PingFangSC-Regular;
font-size: 28rpx;
color: #666666;
}
.askList {
/* width: 14%; */
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #666666;
background-color: #f6f6f6;
padding: 5rpx 15rpx;
margin-right: 10rpx;
margin-bottom: 10rpx;
}
.ask {
overflow: hidden;
width: 100%;
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: flex-start;
margin: 20rpx 0;
}
.head_right {
ont-family: PingFangSC-Medium;
font-size: 28rpx;
color: #F46161;
font-weight: bold;
}
.head_left {
font-family: PingFangSC-Medium;
font-size: 32rpx;
font-weight: bold;
color: #333333;
width: 350rpx;
overflow: hidden;
white-space: nowrap;
/*不换行*/
text-overflow: ellipsis;
/*超出部分文字以...显示*/
}
.highlight {
color: #F46161;
}
.body {
width: 690rpx;
margin: 0rpx auto;
background-color: #fefefe;
overflow: hidden;
box-sizing: border-box;
padding: 20rpx;
padding-bottom: 0;
border-radius: 20rpx;
margin-top: 20rpx;
}
.heads {
display: flex;
align-items: center;
justify-content: space-between;
}
<template>
<view class="body" @click="goInfo(companyitem)">
<view class="heads">
<view class="head_left">
<rich-text :nodes="string">
</rich-text>
</view>
<view class="head_right">
{{ companyitem.wage }}{{ wageUnit[companyitem.wageUnitCategory] }}
</view>
</view>
<view class="ask">
<view class="askList">
{{ companyitem.tradeNames }}
</view>
<view class="askList" v-for="(item, index) in skillNames" :key="index">
{{ item }}
</view>
<view style="flex:1;"></view>
<u-tag text="零工岗位" v-if="companyitem.type == 0" plain size="mini" type="warning"></u-tag>
<u-tag text="全职岗位" v-if="companyitem.type == 1" plain size="mini"></u-tag>
<u-tag text="招工" v-if="companyitem.type == 2" plain size="mini"></u-tag>
</view>
<view style="width: 100%;height: 1rpx;background-color: #999;margin: 0 auto;opacity: .5;"></view>
<view class="timeAddress" style="position: relative;">
<view style="display: flex;align-items: center;">
<image src="../../static/img/city.png" style="width: 40rpx;height: 40rpx;margin-right: 10rpx;" mode="">
</image>
<view style="font-size: 26rpx;color:#333;">{{ companyitem.missionCompanyName }}</view>
</view>
<view style="display: flex;align-items: center;position:absolute;right:0;">
<image src="../../static/img/location_new.png" style="width: 30rpx;height: 30rpx;" mode=""></image>
<view>{{distance(companyitem)}}</view>
</view>
</view>
<view class="comment" v-if='comment' @tap.stop="goComment(companyitem.missionNo)">
<view class="comment_content commentimg" v-if='companyitem.scoreAll > 0'>
<image class="commentimg_image" src="../../static/img/star.full.svg"
v-for="index1 in companyitem.scoreAll" mode="" :key="index1"></image>
<image class="commentimg_image" src="../../static/img/star.empty.svg"
v-for="index2 in (5 - companyitem.scoreAll)" mode="" :key="index2"></image>
</view>
<view class="comment_content allName gocomment" v-else>
评价
</view>
</view>
</view>
</template>
<script>
import {
toDoller,
dateFormat
} from "../../untils/format.js";
import dictionary from '@/common/textdata.js';
import {
defaults
} from "lodash";
import {
addZeroPrefix,
getDistanceFromLatLonInKm
} from '@/untils/tools.js'
export default {
beforeCreate: function() {},
props: {
companyitem: {
type: Object,
default () {
return []
}
},
comment: {
type: Boolean,
default: false
},
noApply: {
type: Boolean,
default: true
},
near: {
type: Boolean,
default: false
},
position: {
default: null
}
},
data() {
return {
...dictionary,
string: "<div style='overflow: hidden;white-space: nowrap;text-overflow: ellipsis;'>" + this.companyitem
.missionTitle +
"</div>"
};
},
computed: {
skillNames() {
if (this.companyitem.skillNames) {
return this.companyitem.skillNames?.split(',')
} else {
return []
}
}
},
methods: {
distance(item) {
const {
lon,
lat
} = item
if (this.position && lon > 0) {
const {
longitude,
latitude
} = this.position
const {
m,
km
} = getDistanceFromLatLonInKm(lat, lon, latitude, longitude)
return m > 1000 ? `${km.toFixed(2)}km` : `${m.toFixed(2)}m`
}
return '--km'
},
goComment: function(no) {
uni.navigateTo({
url: `../../pageMy/mycomment/mycomment?missionNo=${encodeURIComponent(no)}`
})
},
goInfo: function(item) {
// const isCan = this.noApply === false ? '0' : '1'
switch (item.type) {
case 0:
this.navTo(
`/pages/projectInfo/projectInfo?missionNo=${encodeURIComponent(item.missionNo)}&isCan=1`
)
break
case 1:
this.navTo(`/pages/projectInfo/workInfo?workId=${encodeURIComponent(item.id)}&isCan=1`)
break
case 2:
this.navTo(`/pages/projectInfo/workInfo?workId=${encodeURIComponent(item.id)}&isCan=1`)
break
default:
this.navTo(`/pages/projectInfo/workInfo?workId=${encodeURIComponent(item.id)}&isCan=1`)
}
},
getCity: function(val) {
if (val) {
let areas = this.$store.getters.getAreaParents(val)
if (areas.length === 3) {
return areas[0].label + '-' + areas[1].label + '-' + areas[2].label
}
}
},
toDoller,
dateFormat
}
}
</script>
<style>
.commentimg_image {
width: 40rpx;
height: 40rpx;
}
.commentimg {
display: flex;
align-items: center;
justify-content: flex-end;
}
.gocomment {
font-size: 26rpx !important;
border-radius: 5rpx;
border: 1rpx solid #c3c3c3;
width: 160rpx;
text-align: center;
float: right;
height: 50rpx;
line-height: 50rpx;
}
.timeAddress {
display: flex;
align-items: center;
justify-content: space-between;
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #999999;
margin: 10rpx 0;
padding: 10rpx 0;
}
.allName {
font-family: PingFangSC-Regular;
font-size: 28rpx;
color: #666666;
}
.askList {
/* width: 14%; */
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #666666;
background-color: #f6f6f6;
padding: 5rpx 15rpx;
margin-right: 10rpx;
margin-bottom: 10rpx;
}
.ask {
overflow: hidden;
width: 100%;
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: flex-start;
margin: 20rpx 0;
}
.head_right {
ont-family: PingFangSC-Medium;
font-size: 28rpx;
color: #F46161;
font-weight: bold;
}
.head_left {
font-family: PingFangSC-Medium;
font-size: 32rpx;
font-weight: bold;
color: #333333;
width: 350rpx;
overflow: hidden;
white-space: nowrap;
/*不换行*/
text-overflow: ellipsis;
/*超出部分文字以...显示*/
}
.highlight {
color: #F46161;
}
.body {
width: 690rpx;
margin: 0rpx auto;
background-color: #fefefe;
overflow: hidden;
box-sizing: border-box;
padding: 20rpx;
padding-bottom: 0;
border-radius: 20rpx;
margin-top: 20rpx;
}
.heads {
display: flex;
align-items: center;
justify-content: space-between;
}
</style>

View File

@@ -5,46 +5,6 @@
</template>
<script>
import 'ol/ol.css';
import Map from 'ol/Map';
import View from 'ol/View';
import TileLayer from 'ol/layer/Tile';
import SourceVector from 'ol/source/Vector';
import LayerVector from 'ol/layer/Vector';
import * as control from 'ol/control';
import {
toLonLat
} from 'ol/proj';
import Overlay from 'ol/Overlay';
import {
toStringHDMS
} from 'ol/coordinate';
import {
Select
} from 'ol/interaction'
import {
GeoJSON
} from 'ol/format';
import {
Style,
Circle,
Fill,
Stroke,
Icon,
Text
} from 'ol/style';
import Feature from 'ol/Feature';
import {
Point,
Polygon
} from 'ol/geom';
import {
Logo,
TileSuperMapRest,
FeatureService,
GetFeaturesByGeometryParameters
} from '@supermap/iclient-ol';
const geoJSONParser = new GeoJSON();
let mypoint = require('@/static/img/mypoint.png');
export default {
name: "uMapView",
@@ -114,297 +74,12 @@
};
},
mounted() {
if (this.init) {
this.initMap()
}
},
methods: {
initMap(options) {
let lat, lon;
if (options) {
lat = options.lat
lon = options.lon
} else {
lat = this.latitude
lon = this.longitude
}
this.map = new Map({
target: 'map',
controls: control.defaults({
attribution: false,
zoom: this.ScaleZoom,
}),
layers: [
new TileLayer({ // 使用瓦片
source: new TileSuperMapRest({
url: this.MapUrl,
wrapX: true,
}),
projection: 'EPSG:4326',
}),
],
view: new View({
center: [lon, lat],
maxZoom: this.maxZoom,
minZoom: this.minZoom,
zoom: this.zoom,
projection: 'EPSG:4326',
})
});
//添加查询结果图层
this.vectorSource = new SourceVector({
wrapX: false
});
const resultLayer = new LayerVector({
source: this.vectorSource,
});
//添加点图层
this.addPointsSource = new SourceVector({
wrapX: false
});
const addPointsLayer = new LayerVector({
source: this.addPointsSource,
});
this.map.addLayer(addPointsLayer);
this.map.addLayer(resultLayer);
this.map.on('pointermove', (e) => {
if (this.isShowToolTip) {
this.helpTooltip.setPosition(undefined);
this.helpTooltipElement.classList.add('hidden');
}
this.$emit('regionchange', e.pixel)
});
this.map.on('singleclick', (e) => {
this.$emit('clickMap', e.coordinate)
});
if (this.open) {
this.addFeature([{
id: 1,
latitude: lat,
longitude: lon,
iconPath: mypoint,
title: '',
width: 20,
height: 20
}])
}
if (this.flagTip) {
this.createHelpTooltip()
}
},
addMarker(point) {
console.log('point', point)
// this.ceateMarker([104.404419, 31.133980])
},
addFeature(covers) {
console.log(covers)
const features = covers.map((item) => ({
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [item.longitude, item.latitude],
},
properties: {
iconPath: item.iconPath,
text: item.title,
value: JSON.stringify(item),
scale: item.id === 1 ? [0.15, 0.15] : [0.1, 0.1]
}
}))
this.careateFeature(features)
},
ceateMarker(point) {
// 创建一个坐标点
const pointed = new Point(point); // 这里的[0, 0]应该替换为您的经度和纬度
// 创建一个特征
const pointFeature = new Feature({
geometry: pointed,
name: 'My Point'
});
pointFeature.setStyle(new Style({
image: new Circle({
fill: new Fill({
color: [255, 0, 0, 0.5]
}),
stroke: new Stroke({
color: 'red',
width: 2
}),
radius: 8
})
}));
pointFeature.setProperties({
POP: 1,
CAPITAL: 'test'
});
this.addPointsSource.clear()
// 将特征添加到矢量图层
this.addPointsSource.addFeature(pointFeature);
// 确保更新地图视图以显示新的标点
this.map.getView().fit(this.addPointsSource.getExtent());
// // 或者移动视图
// _this.map.getView().animate({
// duration: 850,
// zoom: 5,
// center: point,
// });
},
careateFeature(result) {
if (this.vectorSourceIcon) {
this.vectorSourceIcon.clear()
const geojsonObject = {
type: 'FeatureCollection',
features: result,
};
this.vectorSourceIcon.addFeatures(geoJSONParser.readFeatures(geojsonObject))
this.vectorSourceIcon.changed()
return
}
const geojsonObject = {
type: 'FeatureCollection',
features: result,
};
// 创建一个图层作为点位
this.vectorSourceIcon = new SourceVector({
features: geoJSONParser.readFeatures(geojsonObject)
});
this.vectorLayerIcon = new LayerVector({
source: this.vectorSourceIcon,
style: feature => {
return new Style({
image: new Icon({
anchor: [0.5, 0.9],
scale: feature.get('scale'),
src: feature.get('iconPath'),
}),
text: new Text({
text: feature.get('text'),
fill: new Fill({
color: '#000'
}),
stroke: new Stroke({
color: '#fff',
width: 3
}),
font: 'normal 12px Calibri, sans-serif',
textAlign: 'center', // 文本对齐
offsetX: 0,
offsetY: 15,
rotation: 0, // 文本旋转
}),
});
}
});
this.map.addLayer(this.vectorLayerIcon);
// 添加事件
this.selectInteraction = new Select({
layers: [this.vectorLayerIcon]
});
this.selectInteraction.on('select', (event) => {
const selectedFeatures = event.selected;
if (selectedFeatures.length) {
const select = selectedFeatures[0].values_
this.$emit('markertap', JSON.parse(select.value))
// tooltip
if (this.flagTip) {
const coordinate = selectedFeatures[0].values_.geometry.flatCoordinates;
this.helpTooltipElement.innerHTML = select.text;
console.log(this.helpTooltip)
this.helpTooltip.setPosition(coordinate);
this.helpTooltipElement.classList.remove('hidden');
this.map.addOverlay(this.helpTooltip);
this.isShowToolTip = true
}
}
});
this.map.addInteraction(this.selectInteraction);
},
createHelpTooltip() {
this.helpTooltipElement
if (this.helpTooltipElement) {
this.helpTooltipElement.parentNode.removeChild(this.helpTooltipElement);
}
this.helpTooltipElement = document.createElement('div');
this.helpTooltipElement.className = 'tooltip hidden';
this.helpTooltip = new Overlay({
element: this.helpTooltipElement,
offset: [-30, 20],
positioning: 'center-left'
});
}
}
methods: {}
}
</script>
<style scoped>
.app-content {}
.editPane {
position: absolute;
right: 65px;
top: 8px;
text-align: center;
background: #FFF;
z-index: 1000;
border-radius: 4px;
}
.ol-popup {
position: absolute;
background-color: white;
-webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
padding: 15px;
border-radius: 10px;
border: 1px solid #cccccc;
bottom: 12px;
left: -50px;
min-width: 120px;
white-space: nowrap;
}
.ol-popup:after,
.ol-popup:before {
top: 100%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.ol-popup:after {
border-top-color: white;
border-width: 10px;
left: 48px;
margin-left: -10px;
}
.ol-popup:before {
border-top-color: #cccccc;
border-width: 11px;
left: 48px;
margin-left: -11px;
}
.tooltip {
position: relative;
background: rgba(0, 0, 0, 0.5);
border-radius: 4px;
color: white;
padding: 4px 8px;
opacity: 0.7;
white-space: nowrap;
}
</style>

View File

@@ -0,0 +1,410 @@
<template>
<view class="app-content">
<view id="map" style="width: 100%;height: 100%;"></view>
</view>
</template>
<script>
import 'ol/ol.css';
import Map from 'ol/Map';
import View from 'ol/View';
import TileLayer from 'ol/layer/Tile';
import SourceVector from 'ol/source/Vector';
import LayerVector from 'ol/layer/Vector';
import * as control from 'ol/control';
import {
toLonLat
} from 'ol/proj';
import Overlay from 'ol/Overlay';
import {
toStringHDMS
} from 'ol/coordinate';
import {
Select
} from 'ol/interaction'
import {
GeoJSON
} from 'ol/format';
import {
Style,
Circle,
Fill,
Stroke,
Icon,
Text
} from 'ol/style';
import Feature from 'ol/Feature';
import {
Point,
Polygon
} from 'ol/geom';
import {
Logo,
TileSuperMapRest,
FeatureService,
GetFeaturesByGeometryParameters
} from '@supermap/iclient-ol';
const geoJSONParser = new GeoJSON();
let mypoint = require('@/static/img/mypoint.png');
export default {
name: "uMapView",
props: {
latitude: {
required: true,
},
longitude: {
required: true,
},
zoom: {
type: Number,
required: false,
default: 10,
},
maxZoom: {
type: Number,
required: false,
default: 20,
},
minZoom: {
type: Number,
required: false,
default: 0,
},
ScaleZoom: {
type: Boolean,
required: false,
default: false,
},
MapUrl: { // 瓦片地图URL
type: String,
required: true,
default: '',
},
flagTip: {
type: Boolean,
required: false,
default: false,
},
open: {
type: Boolean,
required: false,
default: false,
},
init: {
type: Boolean,
required: false,
default: true,
}
},
data() {
return {
// 实例化对象
map: null,
addPointsSource: null,
vectorSource: null,
vectorSourceIcon: null,
vectorLayerIcon: null,
selectInteraction: null,
helpTooltipElement: null,
helpTooltip: null,
isclearPoint: null,
overlay: null,
// 控制参数
isShowToolTip: false,
};
},
mounted() {
if (this.init) {
this.initMap()
}
},
methods: {
initMap(options) {
let lat, lon;
if (options) {
lat = options.lat
lon = options.lon
} else {
lat = this.latitude
lon = this.longitude
}
this.map = new Map({
target: 'map',
controls: control.defaults({
attribution: false,
zoom: this.ScaleZoom,
}),
layers: [
new TileLayer({ // 使用瓦片
source: new TileSuperMapRest({
url: this.MapUrl,
wrapX: true,
}),
projection: 'EPSG:4326',
}),
],
view: new View({
center: [lon, lat],
maxZoom: this.maxZoom,
minZoom: this.minZoom,
zoom: this.zoom,
projection: 'EPSG:4326',
})
});
//添加查询结果图层
this.vectorSource = new SourceVector({
wrapX: false
});
const resultLayer = new LayerVector({
source: this.vectorSource,
});
//添加点图层
this.addPointsSource = new SourceVector({
wrapX: false
});
const addPointsLayer = new LayerVector({
source: this.addPointsSource,
});
this.map.addLayer(addPointsLayer);
this.map.addLayer(resultLayer);
this.map.on('pointermove', (e) => {
if (this.isShowToolTip) {
this.helpTooltip.setPosition(undefined);
this.helpTooltipElement.classList.add('hidden');
}
this.$emit('regionchange', e.pixel)
});
this.map.on('singleclick', (e) => {
this.$emit('clickMap', e.coordinate)
});
if (this.open) {
this.addFeature([{
id: 1,
latitude: lat,
longitude: lon,
iconPath: mypoint,
title: '',
width: 20,
height: 20
}])
}
if (this.flagTip) {
this.createHelpTooltip()
}
},
addMarker(point) {
console.log('point', point)
// this.ceateMarker([104.404419, 31.133980])
},
addFeature(covers) {
console.log(covers)
const features = covers.map((item) => ({
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [item.longitude, item.latitude],
},
properties: {
iconPath: item.iconPath,
text: item.title,
value: JSON.stringify(item),
scale: item.id === 1 ? [0.15, 0.15] : [0.1, 0.1]
}
}))
this.careateFeature(features)
},
ceateMarker(point) {
// 创建一个坐标点
const pointed = new Point(point); // 这里的[0, 0]应该替换为您的经度和纬度
// 创建一个特征
const pointFeature = new Feature({
geometry: pointed,
name: 'My Point'
});
pointFeature.setStyle(new Style({
image: new Circle({
fill: new Fill({
color: [255, 0, 0, 0.5]
}),
stroke: new Stroke({
color: 'red',
width: 2
}),
radius: 8
})
}));
pointFeature.setProperties({
POP: 1,
CAPITAL: 'test'
});
this.addPointsSource.clear()
// 将特征添加到矢量图层
this.addPointsSource.addFeature(pointFeature);
// 确保更新地图视图以显示新的标点
this.map.getView().fit(this.addPointsSource.getExtent());
// // 或者移动视图
// _this.map.getView().animate({
// duration: 850,
// zoom: 5,
// center: point,
// });
},
careateFeature(result) {
if (this.vectorSourceIcon) {
this.vectorSourceIcon.clear()
const geojsonObject = {
type: 'FeatureCollection',
features: result,
};
this.vectorSourceIcon.addFeatures(geoJSONParser.readFeatures(geojsonObject))
this.vectorSourceIcon.changed()
return
}
const geojsonObject = {
type: 'FeatureCollection',
features: result,
};
// 创建一个图层作为点位
this.vectorSourceIcon = new SourceVector({
features: geoJSONParser.readFeatures(geojsonObject)
});
this.vectorLayerIcon = new LayerVector({
source: this.vectorSourceIcon,
style: feature => {
return new Style({
image: new Icon({
anchor: [0.5, 0.9],
scale: feature.get('scale'),
src: feature.get('iconPath'),
}),
text: new Text({
text: feature.get('text'),
fill: new Fill({
color: '#000'
}),
stroke: new Stroke({
color: '#fff',
width: 3
}),
font: 'normal 12px Calibri, sans-serif',
textAlign: 'center', // 文本对齐
offsetX: 0,
offsetY: 15,
rotation: 0, // 文本旋转
}),
});
}
});
this.map.addLayer(this.vectorLayerIcon);
// 添加事件
this.selectInteraction = new Select({
layers: [this.vectorLayerIcon]
});
this.selectInteraction.on('select', (event) => {
const selectedFeatures = event.selected;
if (selectedFeatures.length) {
const select = selectedFeatures[0].values_
this.$emit('markertap', JSON.parse(select.value))
// tooltip
if (this.flagTip) {
const coordinate = selectedFeatures[0].values_.geometry.flatCoordinates;
this.helpTooltipElement.innerHTML = select.text;
console.log(this.helpTooltip)
this.helpTooltip.setPosition(coordinate);
this.helpTooltipElement.classList.remove('hidden');
this.map.addOverlay(this.helpTooltip);
this.isShowToolTip = true
}
}
});
this.map.addInteraction(this.selectInteraction);
},
createHelpTooltip() {
this.helpTooltipElement
if (this.helpTooltipElement) {
this.helpTooltipElement.parentNode.removeChild(this.helpTooltipElement);
}
this.helpTooltipElement = document.createElement('div');
this.helpTooltipElement.className = 'tooltip hidden';
this.helpTooltip = new Overlay({
element: this.helpTooltipElement,
offset: [-30, 20],
positioning: 'center-left'
});
}
}
}
</script>
<style scoped>
.app-content {}
.editPane {
position: absolute;
right: 65px;
top: 8px;
text-align: center;
background: #FFF;
z-index: 1000;
border-radius: 4px;
}
.ol-popup {
position: absolute;
background-color: white;
-webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
padding: 15px;
border-radius: 10px;
border: 1px solid #cccccc;
bottom: 12px;
left: -50px;
min-width: 120px;
white-space: nowrap;
}
.ol-popup:after,
.ol-popup:before {
top: 100%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.ol-popup:after {
border-top-color: white;
border-width: 10px;
left: 48px;
margin-left: -10px;
}
.ol-popup:before {
border-top-color: #cccccc;
border-width: 11px;
left: 48px;
margin-left: -11px;
}
.tooltip {
position: relative;
background: rgba(0, 0, 0, 0.5);
border-radius: 4px;
color: white;
padding: 4px 8px;
opacity: 0.7;
white-space: nowrap;
}
</style>