I posted this question at Stackoverflow, but I'm thinking this is a more suitable place...
I'm sure this is possible -- I just need pointing in the right direction (no pun intended).
I've got a bunch of linestrings in GeoJSON which I'm displaying in OpenLayers 3 (or 4). I'd like to be able to select a particular linestring then zoom in to a fixed level and keep the linestring as horizontal as possible as the user pans the map.
I'm thinking this is similar to the Geolocation Tracking (https://openlayers.org/en/latest/examples/geolocation-orientation.html?q=orientation) example, but I can't get my head around it.
I can't really provide a fiddle as I'm still at the 'working out how to approach this' stage. But, imagine you want to allow a user to pan along a road, but keep the map rotated so that the road always remains horizontal. Somehow automatically adjusting the map rotation after each pan.
I'm thinking it's got something to do with calculating the bearing of the selected polyline at the extents of the current view, but I have no idea how to do this.