Skip to content

Commit 443758f

Browse files
committed
fix: Error handling
1 parent d40c935 commit 443758f

File tree

3 files changed

+5
-54
lines changed

3 files changed

+5
-54
lines changed

src/GEOComp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ GEOComp = withMethodExposing(GEOComp, [
515515
execute: async (comp: any, params: any) => {
516516
var map = comp.exposingValues.events['map:init']
517517
if (map) return getFeatures(map, params[0])
518-
return Promise.reject()
518+
throw Error('Map not ready')
519519
}
520520
},
521521
{

src/vendors/Geo.jsx

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -725,56 +725,6 @@ function Geo(props) {
725725
//Add map init event
726726
map.once('rendercomplete', () => {
727727
fireEvent('map:init', map)
728-
/* For def testing
729-
setFeatures(map, 'draw', {
730-
"type": "FeatureCollection",
731-
"features": [
732-
{
733-
"type": "Feature",
734-
"geometry": {
735-
"type": "Point",
736-
"coordinates": [
737-
4.619280420426408,
738-
52.36971865967607
739-
]
740-
},
741-
"properties": null
742-
},
743-
{
744-
"type": "Feature",
745-
"geometry": {
746-
"type": "Point",
747-
"coordinates": [
748-
4.777228609150011,
749-
52.31281170136947
750-
]
751-
},
752-
"properties": null
753-
},
754-
{
755-
"type": "Feature",
756-
"geometry": {
757-
"type": "Point",
758-
"coordinates": [
759-
4.715578084951174,
760-
52.25237825048336
761-
]
762-
},
763-
"properties": null
764-
},
765-
{
766-
"type": "Feature",
767-
"geometry": {
768-
"type": "Point",
769-
"coordinates": [
770-
4.639832579498036,
771-
52.29509806971279
772-
]
773-
},
774-
"properties": null
775-
}
776-
]
777-
})*/
778728
})
779729
}
780730
}, [props.features, props.projection, props.startDate, props.endDate, map]);
@@ -819,6 +769,7 @@ function Geo(props) {
819769
}
820770
}
821771
}, [props.center, geoLoc]);
772+
822773
//Menu title
823774
useEffect(() => {
824775
if (map) {

src/vendors/helpers/Layers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,14 @@ export function setFeatures(map, name, data, clear) {
321321
if (source.setFeatures) {
322322
source.setFeatures(reader.readFeatures(rec))
323323
} else {
324-
source.addFeaturesInternal(reader.readFeatures(rec))
324+
source.addFeatures(reader.readFeatures(rec))
325325
}
326326
})
327327
} else {
328328
if (source.setFeatures) {
329329
source.setFeatures(reader.readFeatures(data))
330330
} else {
331-
source.addFeaturesInternal(reader.readFeatures(data))
331+
source.addFeatures(reader.readFeatures(data))
332332
}
333333
}
334334
}
@@ -356,7 +356,7 @@ export async function getFeatures(map, name) {
356356
featureProjection: map.getView().getProjection() || 'EPSG:3857'
357357
}).writeFeaturesObject(source.getFeatures())
358358
}
359-
return Promise.reject()
359+
throw new Error('Layer ' + name + ' not found')
360360
}
361361

362362

0 commit comments

Comments
 (0)