Hi, your code has several errors regarding map projection. I attached a modified version that works:
* the OpenLayers.Map constructor takes two arguments: the name of the map and the options. You had 3 arguments. Instead of adding controls and numZoomLevels as 3rd argument, you should include those in the options. * same for the layer definition of google_hy. The sphericalMercator: true option was ignored because you added it as 3rd argument. * map.setCenter: you cannot use the displayProjection here. displayProjection is only for controls that work with coordinates (e.g. MousePosition). So you have to transform the center coordinates to the map projection. * vector feature coordinates: unless you use Layer.GML or Layer.WFS, you also have to provide your coordinates in the correct projection. Regards, Andreas. On Wed, Jun 25, 2008 at 6:39 AM, czieler <[EMAIL PROTECTED]> wrote: > > I wanted to post a link to a sample of this problem: > http://webgirlunleashed.com/openlayers/test/test.html > > If you click and drag the map, or just pan, you'll notice that the 'car' > feature is moved a few pixels each time you drag the map or pan. > > If anyone can give me any insight on what might be causing the > problem...that would be great. I'm using Firefox 2.0, but I've checked it > on several versions as well as Firefox 3.0 and it occurs on all of them. > > czieler wrote: >> >> Has anyone had any issues where Overlay Alignment is slightly changed when >> you pan the map? >> >> I have a Google Hybrid map as my base layer, and I then have a WFS layer >> on top of this, as well as a Vector layer. I'm zoomed in to level 19 ( >> although this happens at other zoom levels ), and when I pan the map, my >> WFS and Vector layers seem to become slightly offset each time I pan ( so >> it becomes progressively worse ). >> >> Edit: >> I just thought to include sample code, as I thought that would be the >> first question people would respond with: >> >> var options = { >> projection: new OpenLayers.Projection("EPSG:900913"), >> displayProjection: new OpenLayers.Projection("EPSG:4326"), >> units: "m", >> maxResolution: 156543.0339, >> maxExtent: new OpenLayers.Bounds(-20037508, -20037508, >> 20037508, 20037508.34) >> }; >> map = new OpenLayers.Map( 'map',{controls: [new >> OpenLayers.Control.Navigation(), new OpenLayers.Control.PanZoomBar()], >> numZoomLevels:30},options); >> >> >> var google = new OpenLayers.Layer.Google( "Google", {"sphericalMercator": >> true}); >> var google_hy = new OpenLayers.Layer.Google( "Google Hybrid" , {type: >> G_HYBRID_MAP}, {"sphericalMercator": true}); >> var yahoo_hy = new OpenLayers.Layer.Yahoo( "Yahoo >> Hybrid",{type:YAHOO_MAP_HYB}, {"sphericalMercator": true}); >> map.setCenter(new OpenLayers.LonLat(lat,lon), 19); // lat lon are passed >> into this function >> >> wfs = new OpenLayers.Layer.WFS("MyWFSLayer", url, {maxfeatures: "200"}, >> {extractAttributes: true, displayInLayerSwitcher: >> true,sphericalMercator:true}); // url is passed into this function >> wfs.markers = new OpenLayers.Layer.Markers(""); // if I don't put this >> here, I get a js error >> wfs.setOpacity(0.9); >> map.addLayer(wfs); >> > > -- > View this message in context: > http://www.nabble.com/Overlay-Aligment-changing-on-Pan-tp18099824p18104866.html > Sent from the OpenLayers Users mailing list archive at Nabble.com. > > _______________________________________________ > Users mailing list > [email protected] > http://openlayers.org/mailman/listinfo/users >
_______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
