当前位置: 首页 > wzjs >正文

公司网站服务器维护设计公司起名字寓意好的字

公司网站服务器维护,设计公司起名字寓意好的字,顺德网站制作案例价格,商业网站建设案例课程下载文章目录 一、高德地图应用注册。二、注册步骤三、接入Vue3项目1.安装依赖2.配置 securityJsCode3.增加对应类型4.初始化高德地图资源5.初始化地图 四、高德地图-物流轨迹配置五、高德地图-绘制标记六、完整代码参考总结 一、高德地图应用注册。 高德地图开放平台: https://lb…

文章目录

  • 一、高德地图应用注册。
  • 二、注册步骤
  • 三、接入Vue3项目
    • 1.安装依赖
    • 2.配置 securityJsCode
    • 3.增加对应类型
    • 4.初始化高德地图资源
    • 5.初始化地图
  • 四、高德地图-物流轨迹配置
  • 五、高德地图-绘制标记
  • 六、完整代码参考
  • 总结


一、高德地图应用注册。

高德地图开放平台: https://lbs.amap.com/api/jsapi-v2/guide/abc/prepare
Vue中使用: https://lbs.amap.com/api/jsapi-v2/guide/webcli/map-vue1

注册&认证完毕===>创建web应用====>得到 key 和 jscode

二、注册步骤

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

三、接入Vue3项目

1.安装依赖

pnpm add @amap/amap-jsapi-loader

2.配置 securityJsCode

window._AMapSecurityConfig = {securityJsCode: '自己的秘钥'
}

3.增加对应类型

interface Window {_AMapSecurityConfig: {securityJsCode: string}
}  

4.初始化高德地图资源

import AMapLoader from '@amap/amap-jsapi-loader'cnst initMap = () => {MapLoader.load({key: '自己的key',version: '2.0'}).then((AMap) => {// 使用 Amap 初始化地图})
}
onMounted(async () => {initMap()
})

5.初始化地图

const map = new AMap.Map('map', {mapStyle: 'amap://styles/whitesmoke',zoom: 12
})

四、高德地图-物流轨迹配置

步骤:

  • 绘制轨迹
  • 关闭默认覆盖物
  • 绘制位置

样例代码:

AMap.plugin('AMap.Driving', function () {const driving = new AMap.Driving({map: map,showTraffic: false,hideMarkers: true})if (logistics.value?.logisticsInfo &&logistics.value.logisticsInfo.length >= 2) {const list = [...logistics.value.logisticsInfo]// 起点const start = list.shift()// 终点const end = list.pop()driving.search([start?.longitude, start?.latitude],[end?.longitude, end?.latitude],{ waypoints: list.map((item) => [item.longitude, item.latitude]) },() => {// 规划完毕})}
})

五、高德地图-绘制标记

参考文档
在这里插入图片描述

样例代码:

if (logistics.value?.logisticsInfo &&logistics.value.logisticsInfo.length >= 2) {const list = [...logistics.value.logisticsInfo]// 创建标记函数const getMarker = (point: Location,image: string,width = 25,height = 30) => {const icon = new AMap.Icon({size: new AMap.Size(width, height),image,imageSize: new AMap.Size(width, height)})const marker = new AMap.Marker({position: [point?.longitude, point?.latitude],icon: icon,offset: new AMap.Pixel(-width / 2, -height)})return marker}// 起点const start = list.shift()const startMarker = getMarker(start!, startImg)map.add(startMarker)// 终点const end = list.pop()const endMarker = getMarker(end!, endImg)map.add(endMarker)driving.search([start?.longitude, start?.latitude],[end?.longitude, end?.latitude],{ waypoints: list.map((item) => [item.longitude, item.latitude]) },() => {// 规划完毕// 运输位置const curr = logistics.value?.currentLocationInfoconst currMarker = getMarker(curr!, carImg, 33, 20)map.add(currMarker)// 3s后定位当中间进行缩放setTimeout(() => {map.setFitView([currMarker])map.setZoom(10)}, 3000)})}

六、完整代码参考

<script setup lang="ts">
import { getMedicalOrderLogistics } from '@/services/order'
import type { Logistics, Location } from '@/types/order'
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import AMapLoader from '@amap/amap-jsapi-loader'
import startImg from '@/assets/start.png'
import endImg from '@/assets/end.png'
import carImg from '@/assets/car.png'// 获取物流信息
const route = useRoute()
const logistics = ref<Logistics>()
onMounted(async () => {const res = await getMedicalOrderLogistics(route.params.id as string)logistics.value = res.datainitMap()
})// 配置地图
window._AMapSecurityConfig = {securityJsCode: '自己的秘钥'
}
// 初始化地图
const initMap = () => {AMapLoader.load({key: '自己的key',version: '2.0'}).then((AMap) => {// 使用 Amap 初始化地图const map = new AMap.Map('map', {mapStyle: 'amap://styles/whitesmoke',zoom: 12})AMap.plugin('AMap.Driving', function () {const driving = new AMap.Driving({map: map,showTraffic: false,hideMarkers: true})if (logistics.value?.logisticsInfo &&logistics.value.logisticsInfo.length >= 2) {const list = [...logistics.value.logisticsInfo]// 创建标记函数const getMarker = (point: Location,image: string,width = 25,height = 30) => {const icon = new AMap.Icon({size: new AMap.Size(width, height),image,imageSize: new AMap.Size(width, height)})const marker = new AMap.Marker({position: [point?.longitude, point?.latitude],icon: icon,offset: new AMap.Pixel(-width / 2, -height)})return marker}// 存储所有标记点const allMarkers = [] as any[] // 使用类型断言// 起点const start = list.shift()const startMarker = getMarker(start!, startImg)map.add(startMarker)allMarkers.push(startMarker)// 终点const end = list.pop()const endMarker = getMarker(end!, endImg)map.add(endMarker)allMarkers.push(endMarker)// 运输位置const curr = logistics.value?.currentLocationInfoconst currMarker = getMarker(curr!, carImg, 33, 20)map.add(currMarker)allMarkers.push(currMarker)// 先设置一个合适的初始视野map.setFitView(allMarkers)// 然后进行路线规划driving.search([start?.longitude, start?.latitude],[end?.longitude, end?.latitude],{ waypoints: list.map((item) => [item.longitude, item.latitude]) },() => {// 路线规划完成后再次调整视野,确保路线也在视野内map.setFitView(allMarkers)// 3秒后再聚焦到运输车辆位置setTimeout(() => {map.setFitView([currMarker])map.setZoom(10)}, 3000)})}})})
}
</script><template><div class="order-logistics-page"><div id="map"><div class="title"><van-icon name="arrow-left" @click="$router.back()" /><span>{{ logistics?.statusValue }}</span><van-icon name="service" /></div><div class="current"><p class="status">{{ logistics?.statusValue }} 预计{{ logistics?.estimatedTime }}送达</p><p class="predict"><span>{{ logistics?.name }}</span><span>{{ logistics?.awbNo }}</span></p></div></div><div class="logistics"><p class="title">物流详情</p><van-steps direction="vertical" :active="0"><van-step v-for="item in logistics?.list" :key="item.id"><p class="status">{{ item.statusValue }}</p><p class="content">{{ item.content }}</p><p class="time">{{ item.createTime }}</p></van-step></van-steps></div></div>
</template><style lang="scss" scoped>
.order-logistics-page {--van-step-icon-size: 18px;--van-step-circle-size: 10px;
}
#map {height: 450px;background-color: var(--cp-bg);overflow: hidden;position: relative;.title {background-color: #fff;height: 46px;width: 355px;border-radius: 4px;display: flex;align-items: center;padding: 0 15px;font-size: 16px;position: absolute;left: 10px;top: 10px;box-sizing: border-box;box-shadow: 0px 0px 22px 0px rgba(229, 229, 229, 0.5);z-index: 999;> span {flex: 1;text-align: center;}.van-icon {font-size: 18px;color: #666;&:last-child {color: var(--cp-primary);}}}.current {height: 80px;border-radius: 4px;background-color: #fff;height: 80px;width: 355px;box-sizing: border-box;padding: 15px;position: absolute;left: 10px;bottom: 10px;box-shadow: 0px 0px 22px 0px rgba(229, 229, 229, 0.5);z-index: 999;.status {font-size: 15px;line-height: 26px;}.predict {color: var(--cp-tip);font-size: 13px;margin-top: 5px;> span {padding-right: 10px;}}}
}
.logistics {padding: 0 10px 20px;.title {font-size: 16px;padding: 15px 5px 5px;}.van-steps {:deep(.van-step) {&::after {display: none;}}.status {font-size: 15px;color: var(--cp-text3);margin-bottom: 4px;}.content {font-size: 13px;color: var(--cp-tip);margin-bottom: 4px;}.time {font-size: 13px;color: var(--cp-tag);}}
}
</style>

最终效果:
在这里插入图片描述

总结

这样,你就可以在 Vue 项目中集成高德地图,并进行基本的地图显示和交互了。


文章转载自:

http://rfFFKpPu.bcdqf.cn
http://qXp1r8VL.bcdqf.cn
http://IrxTpeMz.bcdqf.cn
http://6wTcLrXt.bcdqf.cn
http://IhjuTIzL.bcdqf.cn
http://xpxNs19a.bcdqf.cn
http://PnKix8ux.bcdqf.cn
http://yt0PsgVR.bcdqf.cn
http://55co2gMz.bcdqf.cn
http://mD6Cso9s.bcdqf.cn
http://rqZHNwNS.bcdqf.cn
http://vwn6GY2Q.bcdqf.cn
http://LX33NOZz.bcdqf.cn
http://LE2w12wT.bcdqf.cn
http://t2h20xrh.bcdqf.cn
http://RyycoekS.bcdqf.cn
http://2g8dtjrY.bcdqf.cn
http://NgMlZTTO.bcdqf.cn
http://YekVLc5r.bcdqf.cn
http://Jd2gtxMj.bcdqf.cn
http://1AoRtFau.bcdqf.cn
http://sBHNt8qk.bcdqf.cn
http://sSbE2OhD.bcdqf.cn
http://javPTeC3.bcdqf.cn
http://EwR6jG2e.bcdqf.cn
http://q620pKYN.bcdqf.cn
http://muKi4Ymd.bcdqf.cn
http://y4BAFof3.bcdqf.cn
http://7G9SQrLS.bcdqf.cn
http://r39UwF88.bcdqf.cn
http://www.dtcms.com/wzjs/746830.html

相关文章:

  • 如何做中介网站wordpress中主题页脚太高怎么办
  • 淮安网站建设多少钱微信开发 网站备案吗
  • 网站维护公司哈尔滨wordpress+团购
  • 网站建设及维护专业南京博学建设集团网站
  • 做网站点击率怎么收钱清远专业网站建设服务
  • 主流网站开发语言有哪些郑州建站程序
  • 如何建公司网站的步骤网站的flash怎么做
  • 大型网站开发语言wordpress装修
  • 如何写网站建设策划案大型网站制作需要多少钱
  • js搜索网站开发邯郸网站制作建设
  • 榆林市横山县建设局官方网站淘宝客网站女装模板下载
  • 域名注册好了怎么做网站下载图片的网站建设
  • 销售网站建设投标网站怎么做
  • wordpress页面重定向循环芜湖网站优化
  • 上海小企业网站建设宣传平台的软件有哪些
  • 建设农产品网站的背景做网站都要买出口带宽吗
  • dedecms做网站注意事项市住建局官方网
  • 正规网站建设空间网页版微信怎么发朋友圈
  • ps做网站浏览器预览自己开发企业管理系统
  • 网站域名注册的相关证书证明文件wordpress被攻击
  • 做徽章标牌的企业网站高端产业主要指哪些领域
  • 松岗怎么做企业网站设计贵阳网站建设哪里好
  • 网站如何不需要备案2017做那个网站能致富
  • 网站什么模板做的谷歌建站
  • 网站项目分析怎么做 方法wordpress文章衔接出错
  • 电子商务网站建设 以为例软文代发
  • 网站服务器可以为网络客户端提供文档二维码导航网站源码
  • 万网买的网站备案传统网站建设架构
  • 东营网站建设关键字排名问题网站asp.net安装
  • 一个域名可以做两个网站吗山东省住房和城乡城乡建设厅网站