Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1074, openlayers support and fixes. #1099

Merged
merged 2 commits into from
Oct 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions web/client/actions/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ function layerLoading(layerId) {
};
}

function layerLoad(layerId) {
function layerLoad(layerId, error) {
return {
type: LAYER_LOAD,
layerId: layerId
layerId,
error
};
}

Expand Down
10 changes: 7 additions & 3 deletions web/client/components/map/leaflet/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,16 @@ let LeafletMap = React.createClass({
if (event && event.layer && event.layer.on ) {
// TODO check event.layer.on is a function
// Needed to fix GeoJSON Layer neverending loading
let hadError = false;
if (!(event.layer.options && event.layer.options.hideLoading)) {
this.props.onLayerLoading(event.layer.layerId);
}
event.layer.on('loading', (loadingEvent) => { this.props.onLayerLoading(loadingEvent.target.layerId); });
event.layer.on('load', (loadEvent) => { this.props.onLayerLoad(loadEvent.target.layerId); });
event.layer.on('tileerror', (errorEvent) => { this.props.onLayerError(errorEvent.target.layerId); });
event.layer.on('loading', (loadingEvent) => {
hadError = false;
this.props.onLayerLoading(loadingEvent.target.layerId);
});
event.layer.on('load', (loadEvent) => { this.props.onLayerLoad(loadEvent.target.layerId, hadError); });
event.layer.on('tileerror', (errorEvent) => { hadError = true; this.props.onLayerError(errorEvent.target.layerId); });
}
});

Expand Down
7 changes: 5 additions & 2 deletions web/client/components/map/openlayers/Layer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const OpenlayersLayer = React.createClass({
type: React.PropTypes.string,
options: React.PropTypes.object,
onLayerLoading: React.PropTypes.func,
onLayerError: React.PropTypes.func,
onLayerLoad: React.PropTypes.func,
position: React.PropTypes.number,
observables: React.PropTypes.array,
Expand All @@ -29,6 +30,7 @@ const OpenlayersLayer = React.createClass({
observables: [],
onLayerLoading: () => {},
onLayerLoad: () => {},
onLayerError: () => {},
onInvalid: () => {}
};
},
Expand Down Expand Up @@ -135,10 +137,11 @@ const OpenlayersLayer = React.createClass({
this.props.onLayerLoad(options.id);
}
});
this.layer.getSource().on('tileloaderror', () => {
this.layer.getSource().on('tileloaderror', (event) => {
this.tilestoload--;
this.props.onLayerError(options.id);
if (this.tilestoload === 0) {
this.props.onLayerLoad(options.id);
this.props.onLayerLoad(options.id, {error: event});
}
});
}
Expand Down
3 changes: 3 additions & 0 deletions web/client/components/map/openlayers/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var OpenlayersMap = React.createClass({
onMouseMove: React.PropTypes.func,
onLayerLoading: React.PropTypes.func,
onLayerLoad: React.PropTypes.func,
onLayerError: React.PropTypes.func,
resize: React.PropTypes.number,
measurement: React.PropTypes.object,
changeMeasurementState: React.PropTypes.func,
Expand All @@ -49,6 +50,7 @@ var OpenlayersMap = React.createClass({
projection: 'EPSG:3857',
onLayerLoading: () => {},
onLayerLoad: () => {},
onLayerError: () => {},
resize: 0,
registerHooks: true,
interactive: true
Expand Down Expand Up @@ -269,6 +271,7 @@ var OpenlayersMap = React.createClass({
map: map,
mapId: this.props.id,
onLayerLoading: this.props.onLayerLoading,
onLayerError: this.props.onLayerError,
onLayerLoad: this.props.onLayerLoad,
projection: this.props.projection,
onInvalid: this.props.onInvalidLayer
Expand Down
2 changes: 1 addition & 1 deletion web/client/reducers/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function layers(state = [], action) {
}
case LAYER_LOAD: {
const newLayers = (state.flat || []).map((layer) => {
return layer.id === action.layerId ? assign({}, layer, {loading: false, loadingError: false}) : layer;
return layer.id === action.layerId ? assign({}, layer, {loading: false, loadingError: action.error}) : layer;
});
return assign({}, state, {flat: newLayers});
}
Expand Down