Skip to content

Commit e1c1154

Browse files
committed
fix: init delay
1 parent 3ad628d commit e1c1154

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

src/vendors/Geo.jsx

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import DrawRegular from 'ol-ext/interaction/DrawRegular'
3636

3737
///Local import
3838
import RotateNorthControl from './RotateNorthControl'
39-
import { createLayer } from './helpers/Layers'
39+
import { createLayer, setFeatures } from './helpers/Layers'
4040
import { animate, geoJsonStyleFunction, useScreenSize } from './helpers'
4141

4242
//WorkArround, undo needs getSource
@@ -723,7 +723,63 @@ function Geo(props) {
723723
loadLayers(map)
724724

725725
//Add map init event, just delay a bit so render is finished
726-
map.once('loadend', () => { fireEvent('map:init', map) })
726+
map.once('rendercomplete', () => {
727+
setTimeout(() => {
728+
fireEvent('map:init', map)
729+
/* For testing
730+
setFeatures(map, 'draw', {
731+
"type": "FeatureCollection",
732+
"features": [
733+
{
734+
"type": "Feature",
735+
"geometry": {
736+
"type": "Point",
737+
"coordinates": [
738+
4.619280420426408,
739+
52.369718659676096
740+
]
741+
},
742+
"properties": null
743+
},
744+
{
745+
"type": "Feature",
746+
"geometry": {
747+
"type": "Point",
748+
"coordinates": [
749+
4.777228609150011,
750+
52.3128117013695
751+
]
752+
},
753+
"properties": null
754+
},
755+
{
756+
"type": "Feature",
757+
"geometry": {
758+
"type": "Point",
759+
"coordinates": [
760+
4.715578084951174,
761+
52.25237825048336
762+
]
763+
},
764+
"properties": null
765+
},
766+
{
767+
"type": "Feature",
768+
"geometry": {
769+
"type": "Point",
770+
"coordinates": [
771+
4.639832579498036,
772+
52.29509806971279
773+
]
774+
},
775+
"properties": null
776+
}
777+
]
778+
}
779+
, true)
780+
*/
781+
}, 350)
782+
})
727783
}
728784
}, [props.features, props.projection, props.startDate, props.endDate, map]);
729785

0 commit comments

Comments
 (0)