0

解决了。请参阅http://osgeo-org.1560.n6.nabble.com/Openlayers-Bounds-transform-not-doing-transform-td3912787.html

我正在尝试在 Openlayers 中对边界进行坐标变换,并尝试了以下方法,对于两个 console.log() 语句,这两种情况下都给了我相同的边界(但我希望第二个语句给我边界EPGS:4326):

http://pastebin.com/ADRwjLAy

在两个 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
...

有人可以帮我诊断我在这里做错了什么吗?

谢谢,马特

4

1 回答 1

0

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:

Proj4js.defs["EPSG:26915"] = "+proj=utm +zone=15 +ellps=GRS80 +datum=NAD83 +units=m +no_defs";

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.

于 2011-11-01T09:29:17.623 回答