Proj4Leaflet 重新投影,就像在 openlayers 中一样 [英] Proj4Leaflet reprojection like in openlayers

查看:26
本文介绍了Proj4Leaflet 重新投影,就像在 openlayers 中一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在底图自己的投影中显示多个图层,也在它自己的投影中显示

I try to display several layers in own projections on base map also in it's own projection

下面是我使用 OpenLayers + proj4 库实现的工作示例

Below my working example implemented using OpenLayers + proj4 library

var projection_name = 'EPSG:32610';
proj4.defs(projection_name, "+proj=utm +zone=10 +datum=WGS84 +units=m +no_defs");
var proj = ol.proj.get(projection_name);
var my_custom_layer = new ol.layer.Tile({
opacity: 0.5,
source: new ol.source.XYZ({
url: '',
projection: proj,
})
});

var osm_layer = new ol.layer.Tile({
source: new ol.source.MapQuest({layer: 'osm'}),
opacity: 0.3
});

with OpenLayers I can create something like this
var map = new ol.Map({
layers: [osm_layer, my_custom_layer],
target: 'map',
view: new ol.View({
projection: 'EPSG:4326',
center: [-122.347, 37.805],
zoom: 9
})
});

结果将在投影 4326 中渲染地图,并在另一个投影中渲染图层 (epsg:32610).my_custom_layer 的每个图块都将转换其图形以适合底图投影.所以我的瓦片服务器每次都返回简单的正方形 (256x256) 瓦片,OL 会将正方形转换为一些新的图形.

And as result will be rendered map in projection 4326 and layer in another projection (epsg:32610). Each tile of my_custom_layer will be transformed its figure to fit for base map projection. So my tile server every time returns simple square (256x256) tile and OL will transform square to some new figure.

是否可以使用 Leaflet + Proj4Leaflet 来实现?

Is it possible to implement it using Leaflet + Proj4Leaflet?

推荐答案

不,Leaflet 和/或 Proj4Leaflet 不支持位图重投影.

No, Leaflet and/or Proj4Leaflet doesn't support bitmap reprojection.

Proj4leaflet 可用于支持 Leaflet 中内置的投影之外的其他投影,但您的图层仍必须与地图处于同一投影中.

Proj4leaflet can be used to support other projections than the ones already built into Leaflet, but your layers will still all have to be in the same projection as the map.

这篇关于Proj4Leaflet 重新投影,就像在 openlayers 中一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆