亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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)文章

  • vue組件編寫之todolist組件實例詳解

    vue組件編寫之todolist組件實例詳解

    這篇文章主要介紹了vue組件編寫之todolist組件的實例講解,本文給大家介紹的非常詳細,需要的朋友可以參考下
    2018-01-01
  • Vue監(jiān)聽頁面刷新和關(guān)閉功能

    Vue監(jiān)聽頁面刷新和關(guān)閉功能

    我在做項目的時候,有一個需求,在離開(跳轉(zhuǎn)或者關(guān)閉)購物車頁面或者刷新購物車頁面的時候向服務(wù)器提交一次購物車商品數(shù)量的變化。這篇文章主要介紹了vue監(jiān)聽頁面刷新和關(guān)閉功能,需要的朋友可以參考下
    2019-06-06
  • Vue實現(xiàn)本地購物車功能

    Vue實現(xiàn)本地購物車功能

    這篇文章主要為大家詳細介紹了Vue實現(xiàn)本地購物車功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-12-12
  • element中el-container容器與div布局區(qū)分詳解

    element中el-container容器與div布局區(qū)分詳解

    這篇文章主要介紹了element中el-container容器與div布局區(qū)分詳解,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-05-05
  • 詳解vue-validator(vue驗證器)

    詳解vue-validator(vue驗證器)

    本篇文章主要介紹了vue-validator(vue驗證器),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-01-01
  • VUE中的export default和export使用方法解析

    VUE中的export default和export使用方法解析

    export default和export都能導(dǎo)出一個模塊里面的常量,函數(shù),文件,模塊等,在其它文件或模塊中通過import來導(dǎo)入常量,函數(shù),文件或模塊。但是,在一個文件或模塊中export,import可以有多個,export default卻只能有一個。
    2022-12-12
  • element中el-table局部刷新的實現(xiàn)示例

    element中el-table局部刷新的實現(xiàn)示例

    本文主要介紹了element中el-table局部刷新的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-04-04
  • .env在mode文件中如何添加注釋詳解

    .env在mode文件中如何添加注釋詳解

    這篇文章主要為大家介紹了.env在mode文件中如何添加注釋詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-09-09
  • vue實現(xiàn)時間倒計時功能

    vue實現(xiàn)時間倒計時功能

    這篇文章主要為大家詳細介紹了vue實現(xiàn)時間倒計時功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • Vue項目打包部署到GitHub Pages的實現(xiàn)步驟

    Vue項目打包部署到GitHub Pages的實現(xiàn)步驟

    本文主要介紹了Vue項目打包部署到GitHub Pages的實現(xiàn)步驟,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-04-04

最新評論