[OpenLayers-Users] Just another trasformation problem ;)

Giuseppe Naponiello beppenapo at gmail.com
Wed Apr 7 06:01:35 EDT 2010


Hi all,
I ought to display a map with osm layer as base and a gml file of a little
part of Armenia.
First step was convert my shapefile, with projection epsg:2498, in a gml
format (ogr2ogr -f GML ...).

Second step was set up my map.
Within tag <head> of my html page, I' ve insert a link to these libraries:

- OpenLayers-2.8/OpenLayers.js
- http://www.openstreetmap.org/openlayers/OpenStreetMap.js
- proj4js.js
- proj4s/lib/defs/EPSG2498.js

And this is a snippet of my map code [1].

The problem is that my gml is in the north of Africa instead of Armenia.
I've tried with qgis and the layer is correctly positioned, so I suppose
that the problem is in the code, but I' m not able to detect the bug!!!

thanks

-beppe -

[1] function init() {
    var epsg2498= new OpenLayers.Projection("EPSG:2498");
    var epsg900913= new OpenLayers.Projection("EPSG:900913");
    var epsg4326= new OpenLayers.Projection("EPSG:4326");

   var bounds = new OpenLayers.Bounds(44.532, 40.144, 45.038,
40.423).transform(epsg4326, epsg900913);

   map = new OpenLayers.Map ("map", {
       controls:[
           new OpenLayers.Control.Navigation(),
           new OpenLayers.Control.LayerSwitcher({activeColor:"#729aa1"}),
           new
OpenLayers.Control.MousePosition({div:document.getElementById("coord")}),
           new OpenLayers.Control.Attribution()],

       maxExtent: bounds,
       maxResolution: 156543.0399,
       numZoomLevels: 5,
       minZoomLevel: 3,
       maxZoomLevel: 8,
       units: 'm',
       projection: epsg900913,
       displayProjection: epsg2498
   } );


   var layerCycleMap = new OpenLayers.Layer.OSM.CycleMap("CycleMap");
    map.addLayer(layerCycleMap);

   var layerTilesAtHome = new OpenLayers.Layer.OSM.Osmarender("Osmarender");
   map.addLayer(layerTilesAtHome);

   var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
   map.addLayer(layerMapnik);

    var isoline = new OpenLayers.Layer.Vector("isoline", {
           strategies: [new OpenLayers.Strategy.Fixed()],
           protocol: new OpenLayers.Protocol.HTTP({
               url: "../aramus_data/vector/gml/isoipse_2498.gml",
               projection: epsg2498,
               format: new OpenLayers.Format.GML()
           })
       });
   isoline = OpenLayers.Projection.transform(isoline, epsg2498,
map.projection);
    map.addLayer(isoline);
....
....
....
-- 
-beppe-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100407/20973173/attachment.html


More information about the Users mailing list