#2056555: Add uptodate options to geojson layer type introduces a setting called bounding box ratio. This allows GeoJSON layers to load a larger area than the map viewport as bounding box. The benefit is that vectors that are just outside the map viewport are preloaded which is useful for panning the map or drawing large shapes which are only partly within the viewport.

When using a different projection EPSG:28992 (and I presume other bessel based projections). The ratio option displaces vectors on the map. The bigger the ratio the large the displacement. Ratios between 0 and 1 displace to top left, ratios between 1 and 2 displace to bottom right. Ratio 1 displays the points correctly.

I've doublechecked the proj4 definition of the projection. I'm out of ideas on how to solve this.

Here's an example of the displacement:
bbox ratio 1:

bbox ratio 1.5:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

matthensley’s picture

I just had this same issue, and it seems like the openlayers geojson layer type is being a little too liberal with its "options" object. If you take a look at the js for the geojson layer type, you can see that we use the passed in options to create a BBOX strategy:

var strategy = new OpenLayers.Strategy.BBOX(options);

Included in this is options.ratio, which is our set bbox ratio.

Then, as we're creating the layer, we use that SAME options object to build a vector layer:

var layer = new OpenLayers.Layer.Vector(title, options);

A ratio on a vector layer is different than a ratio on a bbox strategy, and is scaling our features in an undesired way.

To get past the bug, I'm re-setting the vector layer ratio to 1 immediately before layer creation, but after we've used our passed in ratio to set the bbox strategy. It's probably not the best final solution, though I assume that our geojson vector layer should always have a ratio of 1 unless we're going to add additional form options to the layer type.

Pol’s picture

Status: Active » Closed (won't fix)

This message is part of the issue cleanup initiative.

Openlayers 2.x has been deprecated since the release of Openlayers 3.x the 31 December 2015.
If you want to stay on 2.x, you should try with the latest version of the 2.x release.

However, I strongly encourage you to move on version 3.
Version 3 is much more stable than version 2. It does not yet contain all the features but the main ones are there.

I'll close this thread, feel free to reopen it if needed.

Thanks for your understanding.