@nextgis/ol-map-adapter
Advanced tools
Comparing version 0.3.6 to 0.4.0
@@ -1,8 +0,6 @@ | ||
import { LayerAdapter } from '@nextgis/webmap'; | ||
import { LayerAdapter, ImageAdapterOptions } from '@nextgis/webmap'; | ||
export declare class ImageAdapter implements LayerAdapter { | ||
name: string; | ||
addLayer(options?: any): any; | ||
layer: any; | ||
addLayer(options?: ImageAdapterOptions): any; | ||
} | ||
export declare function queryToObject(str: string): { | ||
[name: string]: any; | ||
}; |
@@ -48,20 +48,26 @@ (function (global, factory) { | ||
this.name = options.id || 'image-' + ID++; | ||
var source = new ImageWMS({ | ||
var imageOptions = { | ||
url: options.url, | ||
params: { | ||
resource: options.layer_style_id || options.id, | ||
resource: options.resourceId || options.id, | ||
}, | ||
ratio: 1, | ||
imageLoadFunction: function (image, src) { | ||
}; | ||
if (options.updateWmsParams) { | ||
imageOptions.imageLoadFunction = function (image, src) { | ||
var url = src.split('?')[0]; | ||
var query = src.split('?')[1]; | ||
var queryObject = queryToObject(query); | ||
image.getImage().src = url | ||
+ '?resource=' + queryObject.resource | ||
+ '&extent=' + queryObject.BBOX | ||
+ '&size=' + queryObject.WIDTH + ',' + queryObject.HEIGHT | ||
+ '#' + Date.now(); | ||
}, | ||
}); | ||
var _a = queryToObject(query), resource = _a.resource, BBOX = _a.BBOX, WIDTH = _a.WIDTH, HEIGHT = _a.HEIGHT; | ||
var queryString = objectToQuery(options.updateWmsParams({ | ||
resource: resource, | ||
bbox: BBOX, | ||
width: WIDTH, | ||
height: HEIGHT | ||
})); | ||
image.getImage().src = url + '?' + queryString; | ||
}; | ||
} | ||
var source = new ImageWMS(imageOptions); | ||
var layer$$1 = new ImageLayer({ source: source }); | ||
this.layer = layer$$1; | ||
return layer$$1; | ||
@@ -102,2 +108,16 @@ }; | ||
} | ||
function objectToQuery(obj, prefix) { | ||
var str = []; | ||
var p; | ||
for (p in obj) { | ||
if (obj.hasOwnProperty(p)) { | ||
var k = prefix ? prefix + '[' + p + ']' : p; | ||
var v = obj[p]; | ||
str.push((v !== null && typeof v === 'object') ? | ||
objectToQuery(v, k) : | ||
encodeURIComponent(k) + '=' + encodeURIComponent(v)); | ||
} | ||
} | ||
return str.join('&'); | ||
} | ||
@@ -104,0 +124,0 @@ var domain; |
{ | ||
"name": "@nextgis/ol-map-adapter", | ||
"version": "0.3.6", | ||
"version": "0.4.0", | ||
"description": "", | ||
@@ -16,3 +16,3 @@ "main": "lib/ol-map-adapter.js", | ||
"devDependencies": { | ||
"@nextgis/webmap": "^0.3.0", | ||
"@nextgis/webmap": "^0.4.0", | ||
"rollup": "^0.66.6", | ||
@@ -43,3 +43,3 @@ "rollup-plugin-commonjs": "^9.2.0", | ||
"license": "GPL-3.0", | ||
"gitHead": "79709ce0f19cf6191f73587be1b8a5a53bb0894c" | ||
"gitHead": "8258dc74b09b298a0c74ebf0f4d63be7e1ae61c4" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122332
877