[OpenLayers-Users] WMS, Google Map, and Vector Layer
Arnd Wippermann
arnd.wippermann at web.de
Sat Aug 22 17:08:36 EDT 2009
Hi Chris,
There are a couple of reasons for what you see or not see
1. map creation without options will lead to projection EPSG:4326.
2. Google maps can used with EPSG:4326, but data in EPSG:4326 will be
shifted.
3. transformation of coordinates in OpenLayers are only possible for
EPSG:4326 and EPSG:900913 or by adding proj4js to your application for other
projections, otherwise nothing happens.
Your features are drawn in the given coordinates on a map with projection
EPSG:4326. Because EPSG:4326 and EPSG:4269 seems to be the same, your
features are in the view but will be shifted on the Google layer.
Create your map in EPSG:900913.
var options = {
controls:[], //create map without controls -> add them later
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"),
units: "m",
numZoomLevels: 18,
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
20037508, 20037508.34)
};
var map = new OpenLayers.Map('TrackViewMap', options);
Set Google layer to sphericalMercator:true
Test the map without the use of proj4js by replacing EPSG:4269 with
EPSG:4326
Transform your points (from, to)
new OpenLayers.Geometry.Point("-80.2112656","44.3428574").transform(new
OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"))
Add the layers
Add the controls
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.PanZoomBar());
map.addControl(new OpenLayers.Control.MouseDefaults());
Set your center and zoom
map.setCenter(new
OpenLayers.LonLat("-80.2112656","44.3428574").transform(new
OpenLayers.Projection("EPSG:4269"),new
OpenLayers.Projection("EPSG:900913")),0);
map.zoomTo(12);
And I hope, you will be pleased with the result.
Some hints:
your wms are added as baselayers, because they will added by default as
baselayers, when the param transparent is not set to true. isBaseLayer and
buffer are options.
var WMSLayer = new OpenLayers.Layer.WMS(title, url, {params}, {options});
var WMSLayer = new OpenLayers.Layer.WMS( 'Toporama Canada',
["http://wms.ess-ws.nrcan.gc.ca/wms/toporama_en?"], {
layers:'hydrography,vegetation,road_network,feature_names,landforms',
format:'image/png',
transparent: true }, {isBaseLayer:true, buffer:0} );
You need only transform the features instead of all the points.
var mlsFeature = new OpenLayers.Feature.Vector(multiLineString.transform(new
OpenLayers.Projection("EPSG:4326"),new
OpenLayers.Projection("EPSG:900913")),null);
Regards,
Arnd
-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Chris Garstin
Gesendet: Samstag, 22. August 2009 15:45
An: users at openlayers.org
Betreff: [OpenLayers-Users] WMS, Google Map, and Vector Layer
Hello there,
I know this has been discussed many times, so please bear with me, as I've
been spending hours trying to see how to fix my unique problem.
I have two WMS layers, and a Google layer in my map. I also have an
overlay, which is just a multiLineString. This overlay appears fine over
the WMS layers, but is shifted on the Google layer. I know this has to do
with projections, but am really struggling with understanding how to fix it.
My attempts have included:
- Reprojecting the Google map.
- Reprojecting the WMS maps.
- Reprojecting the Vectory data on the fly.
- Creating a second Vector layer where the points are transformed.
None of these I am able to get to work, so an extra set of eyes would be
greatly apprecaited.
You can see my attempts at:
http://oo.chrisgarstin.com/maptrack.php?id=75
Regards
Chris
--
View this message in context:
http://n2.nabble.com/WMS-Google-Map-and-Vector-Layer-tp3495088p3495088.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list