Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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())
vectors.removeAllFeatures();
vectors.addFeatures(features);

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

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

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())

to:-

features.geometry.transform(new OpenLayers.Projection('EPSG:4326'), map.getProjectionObject())
share|improve this answer
    
Thank you, it did worked. –  migajek Jul 26 '13 at 16:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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