[OpenLayers-Users] Why does OpenLayers.Layer.WMS shows vectors well and OpenLayers.Layer.OSM does not? (Same code)

Eric Lemoine eric.lemoine at camptocamp.com
Wed Apr 25 01:35:13 EDT 2012


On Wednesday, April 25, 2012, alexe100 wrote:

> I
> I have a web page that shows points features and one line in the map
> If I use:
> var layer = new OpenLayers.Layer.WMS( "OpenLayers
> WMS","http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
> map.addLayer(layer);
>
> the vectors are well shown.


I guess your vectors are in EPSG:4326. The OSGeo WMS layer is also in
EPSG:4326, so the vectors display correctly onto this layer.



>
> IF I use this instead:
> var layer = new OpenLayers.Layer.OSM();
> map.addLayer(layer);
>
> only one point feature is shown on the  map and the text font has bad
> quality.


The OSM layer's projection is EPSG:900913 (Spherical Mercator)...

Try adding projection:"EPSG:4326" in your vector layer options, to tell
OpenLayers to transform the vector coords from EPSG:4326 to the map
projection, that is EPSG:900913. This will only work if you use a BBOX or
Fixed strategy in your vector layer. If not please show how you create the
vector layer and add features to it.

Cheers,


-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120425/d54c3d70/attachment-0001.html


More information about the Users mailing list