-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Image WMS source: ol-source-image-wms (#23)
ol-source-image-wms is added
- Loading branch information
1 parent
1c1c2d8
commit f080e83
Showing
2 changed files
with
134 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<template> | ||
<div v-if="false"> | ||
|
||
</div> | ||
</template> | ||
|
||
<script> | ||
import ImageWMS from 'ol/source/ImageWMS'; | ||
import Projection from 'ol/proj/Projection'; | ||
import { | ||
inject, | ||
onMounted, | ||
onUnmounted, | ||
watch, | ||
} from 'vue' | ||
import usePropsAsObjectProperties from '@/composables/usePropsAsObjectProperties' | ||
export default { | ||
name: 'ol-source-image-wms', | ||
setup(props) { | ||
const layer = inject('imageLayer'); | ||
const { | ||
properties | ||
} = usePropsAsObjectProperties(props); | ||
const createSource = () => { | ||
return new ImageWMS({ | ||
...properties, | ||
params: { | ||
'LAYERS': props.layers, | ||
'STYLES': props.styles | ||
}, | ||
projection: typeof properties.projection == "string" ? properties.projection : new Projection({ | ||
...properties.projection | ||
}) | ||
}); | ||
}; | ||
let source = createSource(); | ||
watch(properties, () => { | ||
layer.setSource(null) | ||
source = createSource(); | ||
layer.setSource(source) | ||
}); | ||
onMounted(() => { | ||
layer.setSource(source) | ||
}); | ||
onUnmounted(() => { | ||
layer.setSource(null) | ||
}); | ||
return { | ||
layer, | ||
source | ||
} | ||
}, | ||
props: { | ||
attributions: { | ||
type: String | ||
}, | ||
crossOrigin: { | ||
type: String | ||
}, | ||
imageExtent: { | ||
type: Array | ||
}, | ||
projection: { | ||
type: [String, Object], | ||
default: 'EPSG:3857' | ||
}, | ||
reprojectionErrorThreshold: { | ||
type: Number, | ||
default: 0.5 | ||
}, | ||
format: { | ||
type: String, | ||
default: 'image/png' | ||
}, | ||
version: { | ||
type: String, | ||
default: '1.3.0' | ||
}, | ||
matrixSet: { | ||
type: String | ||
}, | ||
serverType: { | ||
type: String, | ||
default: 'mapserver' | ||
}, | ||
imageSmoothing: { | ||
type: Boolean, | ||
default: true | ||
}, | ||
layers: { | ||
type: [String,Array], | ||
required: true | ||
}, | ||
styles: { | ||
type: [String,Array], | ||
default: '' | ||
}, | ||
ratio: { | ||
type: Number, | ||
default: 1 | ||
}, | ||
imageSize: { | ||
type: Array | ||
}, | ||
url: { | ||
type: String | ||
}, | ||
params: { | ||
type: Object | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang=""> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters