I've created the very simple tool which utilizes OpenLayers.Format.WKT with DrawFeature - polygon and ModifyFeature together, so I can create and modify, load and save polygons in/from WKT format. I've had it working on OpenLayers.Layer.WMS, but now I'd like to work on OSM map as I need the city names to be shown.

The problem is that after changing the layer type, the polygon is loaded properly - it's displayed somewhere else than it is supposed to be. Here is my loading code (simplified)

var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS","http://vmap0.tiles.osgeo.org/wms/vmap0?", {layers: 'basic'});

// when using this, it doesnt work properly: var wmsLayer = new OpenLayers.Layer.OSM( "OpenLayers OSM");

var features = wkt.read(data);
features.geometry.transform(map.displayProjection, map.getProjectionObject())

I believe this is due to transformation problem, but I don't know how to fix it...


I think the osgeo map is in CRS WGS84 and OSM is 900913. Therefore I am assuming your WKT features are in WGS84 as they display properly.

You need to change this line:-

features.geometry.transform(map.displayProjection, map.getProjectionObject())


features.geometry.transform(new OpenLayers.Projection('EPSG:4326'), map.getProjectionObject())

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.