Openlayers 3 绘制过程中坐标系统转换方法示例 (EPSG4326到 3857)

Openlayers 3 Reproject EPSG:4326 vector to EPSG:3857 

关键点: dataProject 源的投影坐标系 , featureProjection目的投影坐标系 

示例中待绘制数据的投影坐标系为 4326(通用编号) 分别在4326坐标系统 及3857坐标系下绘制如下.

 

If you use EPSG:4326 in your view then your geojson vector declaration should be:

目标坐标系为 4326:

var vectorSource = new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(geojsonObject, { 
dataProjection: 'EPSG:4326',
featureProjection:'EPSG:4326' })
});

If you use EPSG:3857 in your view use this:

目标坐标系为 3857:

var vectorSource = new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(geojsonObject, { 
dataProjection: 'EPSG:4326',
featureProjection:'EPSG:3857' })
});

Just to explain dataProjection is the source coords. Means the epsg of your coordinates within the geojson file. While featureProjection is the EPSG of your view and thus the EPSG of your map. Means is the EPSG original coords should be trasformed.

解释: dataProjection是源坐标系,即要绘制的geojson中存放的坐标的坐标系统. featureProjection是目标地图视窗的坐标系统,即目标坐标系.

So try to remember this rule: featureProjection and ol.View projection declaration should be equal.

注意: 目标坐标系就是 ol.view里面初始定义的投影坐标系统.不是任意指定的.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值