How is the center calculated in this Openlayers 3 example?

المشرف العام

Administrator
طاقم الإدارة
I've seen the demo of auto tracking (when clicking simulate) http://openlayers.org/en/v3.2.1/examples/geolocation-orientation.html and tried to copy it.

and I want to modify the code and place the marker on different places on the screen (in the center for example).

I know the "magic" is done in this function :

var getCenterWithHeading = function (position, rotation, resolution) { var size = map.getSize(); var height = size[1]; return [ position[0] - Math.sin(rotation) * height * resolution * 1 / 4, position[1] + Math.cos(rotation) * height * resolution * 1 / 4 ]; }

But I don't understand how to modify it so the marker will be in the center of the map.



أكثر...
 
أعلى