ps:实习第一周
因业务需求需要使用阿伯斯投影(Albers)
顺便提供个查询坐标系的网址:http://epsg.io/
没学过openlayers所以开始学习
遇到问题
前面和正常投影转换一样
https://blog.csdn.net/SmileCoffin/article/details/56278882
问题是 转换的坐标在实际使用出现偏差
必须电脑上点击获取坐标才行
设置可视范围 使用坐标转换出现误差 只能自己修改
let extent = [8088444.867106596,1576952.1725742612,19821007.30158975,7643807.013628789]
<script>
import proj4 from 'proj4';
import Projection from 'ol/proj/Projection';
import {register} from 'ol/proj/proj4';
import 'ol/ol.css';
import {Map, View} from 'ol';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
import {transform} from 'ol/proj'
import {getCenter} from 'ol/extent'
export default {
mounted() {
this.initmap()
},
methods: {
initmap(){
proj4.defs("ESRI:102028","+proj=aea+ at_1=7+lat_2=-32+lat_0=-15+lon_0=125+x_0=0+y_0=0+datum=WGS84+units=m+no_defs");
// proj4.defs("EPSG:4490","+proj=longlat +ellps=GRS80 +no_defs");
register(proj4)
var projectionAb = new Projection({
code: 'EPSG:102028',
units: 'm',
axisOrientation: 'neu',
global: false
});
let extent = [8088444.867106596,1576952.1725742612,19821007.30158975,7643807.013628789]
const map = new Map({
target: 'map',
layers: [
new TileLayer({
source: new OSM()
})
],
view: new View({
projection: projectionAb,
center:getCenter(extent),
extent:extent,
zoom: 1
})
});
map.on('click', function(event){
console.log(event.coordinate)
})
console.log(getCenter(extent),'点击获取坐标')
}
},
}
</script>