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

Refresh interval on WMS #177

Merged
merged 4 commits into from
Sep 12, 2018
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
1 change: 1 addition & 0 deletions demo/src/app/geo/layer/layer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class AppLayerComponent {
const datasource: WMSoptions = {
type: 'wms',
url: 'https://geoegl.msp.gouv.qc.ca/igo2/api/ws/igo_gouvouvert.fcgi',
refreshIntervalSec: 15,
params: {
layers: 'vg_observation_v_inondation_embacle_wmst',
version: '1.3.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import olSource from 'ol/source/Source';
import { DataSource } from './datasource';

export interface DataSourceOptions {
type?:
type?:
| 'wms'
| 'wfs'
| 'vector'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface WMSDataSourceOptions extends DataSourceOptions {
serverType?: string;
ratio?: number;
ol?: olSourceImageWMS;
refreshIntervalSec?: number;
}

export interface WMSDataSourceOptionsParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export class WMSDataSource extends DataSource {
if (sourceParams && sourceParams.version) {
sourceParams.VERSION = sourceParams.version;
}
if (options.refreshIntervalSec && options.refreshIntervalSec > 0) {
setInterval(() => {
this.ol.updateParams({'igoRefresh': Math.random()});
}, options.refreshIntervalSec * 1000); // Convert seconds to MS
}
}

protected createOlSource(): olSourceImageWMS {
Expand Down