最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue+Openlayers實現(xiàn)實時坐標點展示

 更新時間:2022年03月30日 11:05:32   作者:小小并不小  
這篇文章主要為大家詳細介紹了Vue+Openlayers實現(xiàn)實時坐標點展示,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Vue+Openlayers實現(xiàn)實時坐標點展示的具體代碼,供大家參考,具體內(nèi)容如下

直接上代碼

<!--
?* @Description: 實時坐標點
?* @Author: Dragon
?* @Date: 2020-12-18 10:08:40
?* @LastEditTime: 2020-12-18 15:59:29
?* @LastEditors: Dragon
-->
?
<template>
? <div id="map"></div>
</template>
?
<script>
import "ol/ol.css";
import { Map, View, Feature } from "ol";
import { Image as ImageLayer, Vector as VectorLayer } from "ol/layer";
import { ImageStatic, Vector as VectorSource } from "ol/source";
import { getCenter } from "ol/extent";
import { Projection } from "ol/proj";
?
import { Point } from "ol/geom";
import { Icon, Style, Text, Fill, Stroke } from "ol/style";
?
// import { websocket } ?from "./mixins";
import staticMap from "@/assets/map.png";
import img from "@/assets/tx-icon-1.png";
?
?
export default {
? data() {
? ? return {
? ? ? map: null, // 地圖
? ? ? imgx: 0, // 當前地圖寬
? ? ? imgy: 0, // 當前地圖高
? ? ? persons: [], // 人員
? ? ? features: [],
? ? ? feature: null,
? ? ? vectorSource: new VectorSource(),
? ? ? timer: null
? ? };
? },
? // mixins: [websocket],
? watch: {
? ? persons(val) {
? ? ? if (val) {
? ? ? ? this.setFeature();
? ? ? }
? ? },
? },
? methods: {
? ? ?// 初始化地圖
? ? initMap() {
? ? ? let extent = [0, 0, this.imgx, this.imgy];
? ? ? let projection = new Projection({
? ? ? ? extent: extent
? ? ? });
? ? ? let $this = this;
? ? ? // 默認地圖
? ? ? let mapLayer = new ImageLayer({ ?
? ? ? ? source: new ImageStatic({
? ? ? ? ? url: staticMap,
? ? ? ? ? projection: projection,
? ? ? ? ? imageExtent: extent
? ? ? ? })
? ? ? })
? ? ? // 繪制點
? ? ? let featureLayer = new VectorLayer({
? ? ? ? source: this.vectorSource,
? ? ? });
?
? ? ? this.map = new Map({
? ? ? ? target: "map",
? ? ? ? layers: [
? ? ? ? ? mapLayer,
? ? ? ? ? featureLayer
? ? ? ? ],
? ? ? ? view: new View({
? ? ? ? ? projection: projection,
? ? ? ? ? center: getCenter(extent),
? ? ? ? ? zoom: 2,
? ? ? ? ? maxZoom: 18
? ? ? ? })
? ? ? });
? ? },
?
? ? // WebSocket數(shù)據(jù)接收
? ? // getMessage(message) {
? ? ? // let res = JSON.parse(message.data);
? ? ? // this.persons = res.data;
? ? // },
?
? ? // 點
? ? setFeature() {
? ? ? let that = this;
? ? ? that.features = [];
? ? ? that.vectorSource.clear(); // 先清除
? ? ? that.persons.map((item) => {
? ? ? ? that.feature = new Feature({
? ? ? ? ? geometry: new Point([item.x, item.y]),
? ? ? ? ? name: item.name,
? ? ? ? });
? ? ? ? // 設(shè)置Feature的樣式,使用小旗子圖標
? ? ? ? that.feature.setStyle(
? ? ? ? ? new Style({
? ? ? ? ? ? image: new Icon({
? ? ? ? ? ? ? anchor: [0, 1],
? ? ? ? ? ? ? src: img,
? ? ? ? ? ? }),
? ? ? ? ? ? text: new Text({
? ? ? ? ? ? ? // 位置
? ? ? ? ? ? ? textAlign: "center",
? ? ? ? ? ? ? // 基準線
? ? ? ? ? ? ? textBaseline: "middle",
? ? ? ? ? ? ? // 文字樣式
? ? ? ? ? ? ? font: "normal 20px 微軟雅黑",
? ? ? ? ? ? ? // 文本內(nèi)容
? ? ? ? ? ? ? text: item.name,
? ? ? ? ? ? ? // 文本填充樣式(即文字顏色)
? ? ? ? ? ? ? fill: new Fill({ color: "#aa3300" }),
? ? ? ? ? ? ? stroke: new Stroke({ color: "#ffcc33", width: 2 }),
? ? ? ? ? ? }),
? ? ? ? ? })
? ? ? ? );
? ? ? ? that.features.push(that.feature);
? ? ? });
? ? ? that.vectorSource.addFeatures(that.features);
? ? },
? },
? mounted() {
? ? let img = new Image();
? ? img.src = staticMap;
? ? let that = this;
? ? img.onload = function(res) {
? ? ? that.imgx = res.target.width;
? ? ? that.imgy = res.target.height;
? ? ? that.initMap();
? ? ? // that.initWebSocket();
? ? };
? },
? created() {
? ? let that = this
? ? that.timer = setInterval(function() {
? ? ? that.persons = [
? ? ? ? {id: 1, name: "點-1", x: 497.08, y: 187.88, z: 0},
? ? ? ? {id: 2, name: "點-2", x: 725.32, y: 565.88, z: 0},
? ? ? ? {id: 3, name: "點-3", x: 643.24, y: 503.96, z: 0}
? ? ? ]
? ? ? console.warn(that.persons, 22)
? ? },3000)
? },
? beforeDestroy() {
? ? clearInterval(this.timer)
? }
};
</script>
?
<style>
#map {
? width: 100%;
? height: calc(100Vh - 50px);
}
</style>

效果圖

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue3中hooks的簡介及用法教程

    vue3中hooks的簡介及用法教程

    vue3 中的 hooks 就是函數(shù)的一種寫法,就是將文件的一些單獨功能的js代碼進行抽離出來,放到單獨的js文件中,或者說是一些可以復(fù)用的公共方法/功能,這篇文章主要介紹了vue3中hooks的簡介及用法,需要的朋友可以參考下
    2023-01-01
  • Vue2.0+ElementUI實現(xiàn)查詢條件展開和收起功能組件(代碼示例)

    Vue2.0+ElementUI實現(xiàn)查詢條件展開和收起功能組件(代碼示例)

    文章介紹了如何將查詢條件表單封裝成一個通用組件,以提高開發(fā)效率,組件支持多條件的折疊和展開功能,并提供了使用示例,感興趣的朋友一起看看吧
    2025-01-01
  • Vue-cli項目部署到Nginx服務(wù)器的方法

    Vue-cli項目部署到Nginx服務(wù)器的方法

    這篇文章主要介紹了Vue-cli項目部署到Nginx服務(wù)器的方法,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-11-11
  • element?ui?watch?el-input賦值之后無法刪除或修改問題

    element?ui?watch?el-input賦值之后無法刪除或修改問題

    這篇文章主要介紹了element?ui?watch?el-input賦值之后無法刪除或修改問題及解決,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-02-02
  • vue中報錯Duplicate?keys?detected:'1'.?This?may?cause?an?update?error的解決方法

    vue中報錯Duplicate?keys?detected:'1'.?This?may?c

    我們在vue開發(fā)過程中常會遇到一些錯誤,這篇文章主要給大家介紹了關(guān)于vue中報錯Duplicate?keys?detected:‘1‘.?This?may?cause?an?update?error的解決方法,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下
    2023-03-03
  • Vue3+Vite+TS實現(xiàn)二次封裝element-plus業(yè)務(wù)組件sfasga

    Vue3+Vite+TS實現(xiàn)二次封裝element-plus業(yè)務(wù)組件sfasga

    這篇文章主要介紹了在Vue3+Vite+TS的基礎(chǔ)上實現(xiàn)二次封裝element-plus業(yè)務(wù)組件sfasga,下面文章也將圍繞實現(xiàn)二次封裝element-plus業(yè)務(wù)組件sfasga的相關(guān)介紹展開相關(guān)內(nèi)容,具有一定的參考價值,需要的小伙伴可惡意參考一下
    2021-12-12
  • Vue.js 父子組件通信的十種方式

    Vue.js 父子組件通信的十種方式

    最近一直在做 Vue項目代碼層面上的優(yōu)化,寫文章是很easy的事情,今天小編給大家分享Vue.js 父子組件通信的十種方式,感興趣的的朋友跟隨小編一起看看吧
    2018-10-10
  • vue 實現(xiàn)在函數(shù)中觸發(fā)路由跳轉(zhuǎn)的示例

    vue 實現(xiàn)在函數(shù)中觸發(fā)路由跳轉(zhuǎn)的示例

    今天小編就為大家分享一篇vue 實現(xiàn)在函數(shù)中觸發(fā)路由跳轉(zhuǎn)的示例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-09-09
  • 基于 flexible 的 Vue 組件:Toast -- 顯示框效果

    基于 flexible 的 Vue 組件:Toast -- 顯示框效果

    這篇文章主要介紹了基于 flexible 的 Vue 組件:Toast -- 顯示框效果,需要的朋友可以參考下
    2017-12-12
  • vue基于el-table拓展之table-plus組件

    vue基于el-table拓展之table-plus組件

    本文主要介紹了vue基于el-table拓展之table-plus組件,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-04-04

最新評論

梨树县| 越西县| 花莲市| 武宣县| 西乌珠穆沁旗| 任丘市| 大庆市| 邯郸县| 永康市| 泰宁县| 祁门县| 辛集市| 德格县| 安阳市| 柏乡县| 恭城| 渭南市| 普定县| 漠河县| 呈贡县| 克山县| 德庆县| 固镇县| 太仆寺旗| 西藏| 九龙县| 根河市| 乐昌市| 盈江县| 会昌县| 湘潭市| 呼和浩特市| 蓝山县| 德格县| 于田县| 襄城县| 五华县| 海阳市| 全州县| 班戈县| 酉阳|