如何使用openlayers制作从极坐标展示地图效果,和图片效果达到一致的 谢谢
参考:https://blog.csdn.net/qq_23926575/article/details/78205716
是数学上说的极点/极轴那个极坐标,还是南北极为原点的投影坐标
该回答引用于gpt与OKX安生共同编写:
使用 OpenLayers 制作从极坐标展示地图效果,可以通过将 EPSG:4326 坐标系(经纬度)转换为EPSG:3413(北极圆)或者EPSG:3031(南极圆)坐标系来实现。这里提供一种基于OpenLayers 6.x版本的实现方式,并且已经集成在 Vue.js 框架中。
首先,需要在 Vue.js 中引入 OpenLayers 库:
npm install ol
然后,在 Vue.js 组件中定义地图容器和必要的方法:
<template>
<div ref="map" class="map"></div>
</template>
<script>
import 'ol/ol.css';
import { Map, View } from 'ol';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
import { fromLonLat, transformExtent } from 'ol/proj';
export default {
name: 'PolarMap',
mounted() {
this.initMap();
},
methods: {
initMap() {
const map = new Map({
target: this.$refs.map,
layers: [
new TileLayer({
source: new OSM(),
}),
],
view: new View({
projection: 'EPSG:3413', // 设置北极圆投影
center: [0, 9000000], // 中心点
zoom: 2, // 缩放级别
}),
});
this.map = map;
// 根据经纬度设置地图范围
const extent = [-180, -90, 180, 90];
const transformedExtent = transformExtent(extent, 'EPSG:4326', 'EPSG:3413');
map.getView().fit(transformedExtent);
},
},
};
</script>
<style scoped>
.map {
width: 100%;
height: 500px;
}
</style>
如有用的话,还望采纳吖!