Skip to main content
Removed broken link
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

you should check Using OpenLayers: Changing the Projection.

firstFirst thing is that define your map projection and display projection as following:

map.projection = "EPSG:23030";
map.displayProjection = new OpenLayers.Projection("EPSG:4326");

Adding coordinate conversion

Once you start using different projections, you have to start thinking about the possibility of converting coordinates from one projection to another, either when displaying those coordinates, or when reading in vector data in a different coordinate system from the map's. As stated before, this conversion logic is not provided by OL, so you have to use Proj4js, which you will have to include in your page:

<script src="http://proj4js.org/lib/proj4js-compressed.js"></script>

Proj4js.defs["EPSG:23030"] = "+proj=utm +zone=30 +ellps=intl +towgs84=-131,-100.3,-163.4,-1.244,-0.020,-1.144,9.39 +units=m +no_defs";

after definationdefinition you can do it by transform method:

var lonlat = new OpenLayers.LonLat(-3.57138, 39.8384);
lonlat.transform(map.displayProjection, map.baseLayer.projection);
map.setCenter(lonlat, 5);

i hope it helps you...

you should check Using OpenLayers: Changing the Projection.

first thing is that define your map projection and display projection as following:

map.projection = "EPSG:23030";
map.displayProjection = new OpenLayers.Projection("EPSG:4326");

Adding coordinate conversion

Once you start using different projections, you have to start thinking about the possibility of converting coordinates from one projection to another, either when displaying those coordinates, or when reading in vector data in a different coordinate system from the map's. As stated before, this conversion logic is not provided by OL, so you have to use Proj4js, which you will have to include in your page:

<script src="http://proj4js.org/lib/proj4js-compressed.js"></script>

Proj4js.defs["EPSG:23030"] = "+proj=utm +zone=30 +ellps=intl +towgs84=-131,-100.3,-163.4,-1.244,-0.020,-1.144,9.39 +units=m +no_defs";

after defination you can do it by transform method:

var lonlat = new OpenLayers.LonLat(-3.57138, 39.8384);
lonlat.transform(map.displayProjection, map.baseLayer.projection);
map.setCenter(lonlat, 5);

i hope it helps you...

First thing is that define your map projection and display projection as following:

map.projection = "EPSG:23030";
map.displayProjection = new OpenLayers.Projection("EPSG:4326");

Adding coordinate conversion

Once you start using different projections, you have to start thinking about the possibility of converting coordinates from one projection to another, either when displaying those coordinates, or when reading in vector data in a different coordinate system from the map's. As stated before, this conversion logic is not provided by OL, so you have to use Proj4js, which you will have to include in your page:

<script src="http://proj4js.org/lib/proj4js-compressed.js"></script>

Proj4js.defs["EPSG:23030"] = "+proj=utm +zone=30 +ellps=intl +towgs84=-131,-100.3,-163.4,-1.244,-0.020,-1.144,9.39 +units=m +no_defs";

after definition you can do it by transform method:

var lonlat = new OpenLayers.LonLat(-3.57138, 39.8384);
lonlat.transform(map.displayProjection, map.baseLayer.projection);
map.setCenter(lonlat, 5);
Post Merged (destination) from gis.stackexchange.com/questions/24127/…
Source Link
urcm
  • 22.6k
  • 4
  • 58
  • 109

you should check Using OpenLayers: Changing the Projection.

first thing is that define your map projection and display projection as following:

map.projection = "EPSG:23030";
map.displayProjection = new OpenLayers.Projection("EPSG:4326");

Adding coordinate conversion

Once you start using different projections, you have to start thinking about the possibility of converting coordinates from one projection to another, either when displaying those coordinates, or when reading in vector data in a different coordinate system from the map's. As stated before, this conversion logic is not provided by OL, so you have to use Proj4js, which you will have to include in your page:

<script src="http://proj4js.org/lib/proj4js-compressed.js"></script>

Proj4js.defs["EPSG:23030"] = "+proj=utm +zone=30 +ellps=intl +towgs84=-131,-100.3,-163.4,-1.244,-0.020,-1.144,9.39 +units=m +no_defs";

after defination you can do it by transform method:

var lonlat = new OpenLayers.LonLat(-3.57138, 39.8384);
lonlat.transform(map.displayProjection, map.baseLayer.projection);
map.setCenter(lonlat, 5);

i hope it helps you...