In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how Vue creates OpenLayers components. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Install the OpenLayers library
Cnpm install ol
2. Vue creates OpenLayers component effect diagram
Code import "ol/ol.css"; import Map from "ol/Map"; import OSM from "ol/source/OSM"; import TileLayer from "ol/layer/Tile"; import View from "ol/View"; export default {mounted () {this.initMap () }, methods: {initMap () {new Map ({layers: [new TileLayer ({source: new OSM ()})], target: "map" View: new View ({center: [0,0], zoom: 2})}) Console.log ("init finished");}; .map {width: 100%; height: 400px } 3. OpenLayers uses local pictures as map effects: Code import "ol/ol.css"; import ImageLayer from "ol/layer/Image"; import Map from "ol/Map"; import Projection from "ol/proj/Projection"; import Static from "ol/source/ImageStatic" Import View from "ol/View"; import {getCenter} from "ol/extent"; let extent = [0,0,338,600]; let projection = new Projection ({code: "xkcd-image", units: "pixels", extent: extent}) Export default {data () {return {map: {}};}, mounted () {this.initMap () }, methods: {initMap () {this.map = new Map ({layers: [new ImageLayer ({source: new Static ({attributions:'©xkcd') Url: "http://localhost:8080/img/123.5cba1af6.jpg", projection: projection, imageExtent: extent})})], target:" map " View: new View ({projection: projection, center: getCenter (extent), zoom: 1, maxZoom: 4, minZoom: 1})}) }; .map {width: 100%; height: 400px;} Thank you for reading! This is the end of this article on "how Vue creates OpenLayers components". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.