0
votes

I am moving code from OpenLayers 3 to OpenLayers 4 (typescript)

I had this piece of code that would extend my extent so that all vector shapes I drew would be visible when the map loaded...

angular.forEach(webMapValues.vectorFieldLayer, function (Field, key) 
{
webMapValues.mapObj.addLayer(Field);
webMapValues.extent = Field.getSource().getExtent();
webMapValues.totalExtent = ol.extent.extend(webMapValues.extent, 
webMapValues.totalExtent);
})

in the above "ol.extent.extend" performed the magic for me and in OpenLayers 4 (typescript) I haven't been able to find the equivalent?

Any help is greatly appreciated!

2

2 Answers

1
votes

i believe the function is still there, only the syntax has changed:

import {extend} from 'ol/extent';

const largeExtent = extend(extent1, extent2);
0
votes

I'm using React, typescript and OL4 and found this works for me

import extent from 'ol/extent';

const combinedExtent = extent.extend(<layer1>,<layer2>);