I'm working with openlayer3 in my ionic application and am stucked with the problem with creating a bounding extent to get a few points in the viewport.

My code looks like this:

var destLoc = [6.18581,50.88093];
var currentLoc = [-122.29925626,37.47836852];

var ext = ol.extent.boundingExtent([destLoc,currentLoc]);

But this code gives me a extent of the currentLoc and not the whole extent which includes both points.

What am I doing wrong?

1 Answer 1


Your bounding box is 100% correct.

But, presumably, your map is in EPSG:3857, so you can't use WGS coordinates directly. Transform it to 3857:

var ext = ol.extent.boundingExtent([destLoc,currentLoc]);
ext = ol.proj.transformExtent(ext, ol.proj.get('EPSG:4326'), ol.proj.get('EPSG:3857'));


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.