Openlayers.Bounds().transform() 不进行变换
已解决。请参阅http://osgeo-org.1560.n6.nabble.com/Openlayers-Bounds-transform-not-doing-transform-td3912787.html 。
我正在尝试在 Openlayers 中进行边界的坐标变换,并尝试了以下操作,对于两个 console.log() 语句,在两种情况下都给了我相同的边界(但我希望第二个语句给我边界EPGS:4326):
在两个 console.log() 中语句,我得到以下对象(来自 Chrome javascript 调试器的 c&p):
Class
bottom: 4816289.746171
centerLonLat: null
left: 189775.37995
right: 761662.354535
top: 5472414.143295
__proto__: Object
我在 trac.osgeo.org/openlayers/wiki/Documentation/Dev/proj4js 阅读了带有 openlayers 的 proj4js 文档,它告诉我:
如果库可用,OpenLayers 会与 Proj4js 集成。这将使使用它变得更容易一些。将其与 OpenLayers.js 放在同一文件夹中即可使其可用。
我是通过符号链接完成的:
matt@xxxxxxxx:/var/www/xxxxx$ ll /var/www/OpenLayers-2.10/
total 1008
drwxr-xr-x 13 matt matt 4096 Nov 1 01:49 .
drwxrwxrwx 30 root root 4096 Nov 1 01:43 ..
-rw-r--r-- 1 matt matt 945828 Sep 9 2010 OpenLayers.js
...
lrwxrwxrwx 1 matt matt 31 Nov 1 01:49 proj4js.js -> /var/www/proj4js/lib/proj4js.js
...
有人可以帮助我诊断我在这里做错了什么吗?
谢谢, 马特
Solved. See http://osgeo-org.1560.n6.nabble.com/Openlayers-Bounds-transform-not-doing-transform-td3912787.html .
I am trying to do a coordinate transform of bounds in Openlayers, and have tried the following, which, for both console.log() statements, gives me the same bounds in both cases (but I expect the second statement to give me bounds in EPGS:4326):
In both console.log() statements, I get the following object (c&p from Chrome javascript debugger):
Class
bottom: 4816289.746171
centerLonLat: null
left: 189775.37995
right: 761662.354535
top: 5472414.143295
__proto__: Object
I read the documentation for proj4js with openlayers at trac.osgeo.org/openlayers/wiki/Documentation/Dev/proj4js , and it tells me:
OpenLayers integrates with Proj4js if the library is available. This will make using it a bit easier. Having it in the same folder as OpenLayers.js will make it available.
Which I did via a symlink:
matt@xxxxxxxx:/var/www/xxxxx$ ll /var/www/OpenLayers-2.10/
total 1008
drwxr-xr-x 13 matt matt 4096 Nov 1 01:49 .
drwxrwxrwx 30 root root 4096 Nov 1 01:43 ..
-rw-r--r-- 1 matt matt 945828 Sep 9 2010 OpenLayers.js
...
lrwxrwxrwx 1 matt matt 31 Nov 1 01:49 proj4js.js -> /var/www/proj4js/lib/proj4js.js
...
Can someone help me diagnose what I'm doing wrong here?
Thanks,
Matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
主要问题是您的页面根本不加载
proj4js.js
。您可能假设 OpenLayers 会自动加载它,但事实并非如此,因此您需要自己加载它。由于 OpenLayers 没有内置
EPSG:26915
支持,因此需要 proj4js 才能进行您想要的转换。第二个问题是,您希望通过在 javascript 中添加一行来显式定义
EPSG:26915
,如下所示:如果没有这一行,我认为 proj4js 应该尝试从
spatialreference 加载定义。 org
但当我尝试它时,这似乎对我不起作用。Well the main problem is that your page doesn't load
proj4js.js
at all. You are presumably assuming that OpenLayers will load it automatically, but it doesn't, so you need to load it yourself.As OpenLayers doesn't have
EPSG:26915
support built in it needs proj4js in order to do the transform you want.A second issue is that you way want to define
EPSG:26915
explicitly by adding a line to your javascript that looks like this:Without that I think proj4js should try and load the definition from
spatialreference.org
but that didn't seem to be working for me when I tried it.