Revamping this question instead of opening a new one.

Previous issue: vector layers were not "sticking" to the map, so when you would zoom in or out the vector layers would "come out" at you. Note their lat and long didn't change, but it looked pretty tacky when zooming-as they would not stick to the map.

It seemed like the only way to do this (the stick factor) was to use a WMS or Grid Layer: correct me if I am wrong. I chose Grid in this instance.

Note: the "stick factor" is not an issue when the base layer is OSM or OpenLayers, only Google base layers. Here is an example demonstrating this at bottom of page:

The code I currently have for this Grid is currently this:

var options = {
            resolutions: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125],
            maxExtent: new OpenLayers.Bounds(-180, -90, 180, 90),
            //restrictedExtent: new OpenLayers.Bounds(-360, -90, 360, 90),
            numZoomLevels: 8,
            singleTile: true,
            isBaseLayer: true,
            wrapDateLine: true,
            controls: [
            new OpenLayers.Control.OverviewMap(),
            new OpenLayers.Control.Navigation(),
            new OpenLayers.Control.ScaleLine( { maxWidth: 150 })
            getURL: function() {
                    var center = this.map.getCenter(),
                    size = this.map.getSize();
                    return [
                    this.url, "&center=", center.lat, ",", center.lon,
                    "&zoom=", this.map.getZoom(), "&size=", size.w, "x", size.h

Now the first thing that comes to mind is that I feel I should have an options variable for the map object and an options variable for the Grid layer (what are your thoughts on this?), as shown below:

 var grid = new OpenLayers.Layer.Grid(
        "Google Streets",
        null, options

The left picture below is how the resolution was before: just using a standard OpenLayers Google layer.

The picture to the right is using the Grid layer and point to the Google default layer: mentioned in the code above.

OpenLayers Google Layer, no grid layer bad resolution using Grid Layer and accessing Google Maps

I just posted a snippet of Africa to show the resolution issue, and as for the points (all my points are in the US, they are completely out of whack also (the left most point on the map should be on the west coast of the USA, while the right most point should be on the east coast of the USA.:

enter image description here

1) Should I create a separate options variable for the grid layer?

2) Is adjusting the resolution within the options the correct way to fix this?

3) As you can see in getURL there is no mention of projects or transformations: how do I account for the points showing up correctly in the USA?

  • Live example here. I realised the same error but never had time to fix it :-/. – Jorge Sanz Dec 13 '13 at 12:13
  • It seems to be produced because the features position are recomputed quickly than the zoom resize effect is done. Try to set the transitionEffect = null and see what happens. – EricSonaron Dec 13 '13 at 17:07
  • Seems like you can't just straight up set that property on a Google Layer/Vector Layer/WFS Layer (my layers in question). WMS or grid only it seems. However via a grid layer you can specify a google layer. This did indeed help but now my resolution is all funky. Feel free to add any insight and I'll keep at it. – Nubtacular Dec 13 '13 at 19:24
  • This question has now been up for more than a year with no answer. To me it looks too broad because it contains three questions. I think you should edit it to try and heavily revise it into a single clear question. – PolyGeo Jan 30 '15 at 20:39

Your Answer

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

Browse other questions tagged or ask your own question.