Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanwins committed May 20, 2022
2 parents 49a68ec + a60c115 commit e2fc0a3
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 17 deletions.
5 changes: 2 additions & 3 deletions docs/src/pages/api/DynamicMapService.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ rasterSourceOptions | object | An optional object that will be passed to the cre
return md.render(`Option | Type | Default | Description
-------| ---- | --------| -----------
url | string | | **Required** URL of the MapService. **Note** Map Service urls do not end in a number (use the layers option below).
layers | array<string> | | An array of layer id's to restrict which layers to show from the service (eg [1, 2, 3]).
fetchOptions | object | | A key value pair of options to pass to the [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) method as the init property. This can be used to pass through Authorisation headers where required.
layers | array<string> | | An array of layer id's to restrict which layers to show from the service (eg [1, 2, 3]).
format | string | png24 | Output format of the image
transparent | boolean | true | Allow the server to produce transparent images
layerDefs | object | | SQL filters to define what features will be included in the image rendered by the service. An object is used with keys that map each query to its respective layer. eg \`{ 3: "STATE_NAME='Kansas'", 9: "POP2007>25000" }\`
Expand All @@ -65,5 +66,3 @@ setAttributionFromService() | Sets the attribution on the map from the service m
}
</script>


6 changes: 3 additions & 3 deletions docs/src/pages/api/TiledMapService.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ rasterSourceOptions | object | An optional object that will be passed to the cre
esriOptionsTable () {
return md.render(`Option | Type | Default | Description
-------| ---- | --------| -----------
url | string | | **Required** URL of the TiledMapService.`)
url | string | | **Required** URL of the TiledMapService.
fetchOptions | object | | A key value pair of options to pass to the [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) method as the init property. This can be used to pass through Authorisation headers where required.
`)
}
},
components: {
Expand All @@ -42,5 +44,3 @@ url | string | | **Required** URL of the TiledMapService.`)
}
</script>


5 changes: 2 additions & 3 deletions docs/src/pages/api/VectorTileService.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ vectorSrcOptions | object | An optional object that will be passed to the creati
esriOptionsTable () {
return md.render(`Option | Type | Default | Description
-------| ---- | --------| -----------
url | string | | **Required** URL of the VectorTileService.`)
url | string | | **Required** URL of the VectorTileService.
fetchOptions | object | | A key value pair of options to pass to the [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) method as the init property. This can be used to pass through Authorisation headers where required.`)
}
},
components: {
Expand All @@ -41,5 +42,3 @@ url | string | | **Required** URL of the VectorTileService.`)
}
</script>


6 changes: 3 additions & 3 deletions src/DynamicMapService.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ export class DynamicMapService {
}
}

getMetadata () {
getMetadata() {
if (this._serviceMetadata !== null) return Promise.resolve(this._serviceMetadata)
return new Promise((resolve, reject) => {
getServiceDetails(this.esriServiceOptions.url)
getServiceDetails(this.esriServiceOptions.url, this.esriServiceOptions.fetchOptions)
.then((data) => {
this._serviceMetadata = data
resolve(this._serviceMetadata)
Expand Down Expand Up @@ -160,7 +160,7 @@ export class DynamicMapService {
})

return new Promise((resolve, reject) => {
fetch(`${this.esriServiceOptions.url}/identify?${params.toString()}`)
fetch(`${this.esriServiceOptions.url}/identify?${params.toString()}`, this.esriServiceOptions.fetchOptions)
.then(response => response.json())
.then(data => resolve(data))
.catch(error => reject(error))
Expand Down
2 changes: 1 addition & 1 deletion src/TiledMapService.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class TiledMapService {
getMetadata () {
if (this._serviceMetadata !== null) return Promise.resolve()
return new Promise((resolve, reject) => {
getServiceDetails(this.esriServiceOptions.url)
getServiceDetails(this.esriServiceOptions.url, this.esriServiceOptions.fetchOptions)
.then((data) => {
this._serviceMetadata = data
resolve(data)
Expand Down
4 changes: 2 additions & 2 deletions src/VectorTileService.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class VectorTileService {

_retrieveStyle () {
return new Promise((resolve, reject) => {
fetch(`${this.options.url}/${this._styleUrl}`)
fetch(`${this.options.url}/${this._styleUrl}`, this.esriServiceOptions.fetchOptions)
.then(response => response.json())
.then((data) => {
this._defaultStyleData = data.layers[0]
Expand All @@ -104,7 +104,7 @@ export class VectorTileService {
getMetadata () {
if (this._serviceMetadata !== null) return Promise.resolve(this._serviceMetadata)
return new Promise((resolve, reject) => {
getServiceDetails(this.esriServiceOptions.url)
getServiceDetails(this.esriServiceOptions.url, this.esriServiceOptions.fetchOptions)
.then((data) => {
this._serviceMetadata = data
resolve(this._serviceMetadata)
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ export function cleanTrailingSlash (url) {
return url.replace(/\/$/, '')
}

export function getServiceDetails (url) {
export function getServiceDetails (url, fetchOptions = {}) {
return new Promise((resolve, reject) => {
fetch(`${url}?f=json`)
fetch(`${url}?f=json`, fetchOptions)
.then(response => response.json())
.then(data => resolve(data))
.catch(error => reject(error))
Expand Down

0 comments on commit e2fc0a3

Please sign in to comment.