1

I use OpenLayers to display an OpenStreetMap map and on top of that I want to add a vector layer with features. But it seems that I have a problem with the projection of the vector layer or the features which all use GPS data.

The features are only correctly applied to the map if the map is maximally zoomed. As soon as I zoom out the features move from the original point on the map and if I zoom out the map long enough, they form a circle.

Here is how I set the features:

var iconFeature = new ol.Feature({
geometry: new ol.geom.Point(ol.proj.transform([<somelonvalue>, <somelanvalue>], 'EPSG:4326', 'EPSG:3857')),
popuptext: '<sometext>',
});

iconFeature.setId('$featureID');

And here is how I created the vector layer:

vectorSource = new ol.source.Vector({
features: iconFeatures
});

var vectorLayer = new ol.layer.Vector({
source: vectorSource
});

map.addLayer(vectorLayer);

Here is the outcome if I zoom out the map:

Here is what is my outcome if I zoom out the map.

I believe I did the transformation correctly.

Does anybody have a clue as to what I am doing wrong?

1
  • this look like a representation function when points overlap.
    – radouxju
    Commented Dec 20, 2016 at 14:57

1 Answer 1

0

I used PHP to generate the javascript code for the icon features and PHP sent the output of the anchor variables with German locale:

Wrong:

anchor: [0,5, 0,5],
anchorXUnits: 'fraction',
anchorYUnits: 'fraction',

Right:

anchor: [0.5, 0.5],
anchorXUnits: 'fraction',
anchorYUnits: 'fraction',

This misplaced the features on the map but on maximum zoom the difference was not a lot. But zooming out of course the features weren't geolocation stable and in my case all tended to move north. But as I also used rotate on the features images, they all tended to move in different directions (dependend on the degree of rotation) and in the end formed a circle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.