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里面初始定义的投影坐标系统.不是任意指定的.

转载自:https://blog.csdn.net/huapenguag/article/details/85001454

You may also like...

退出移动版