Skip to content

Commit

Permalink
Merge pull request #883 from jgravois/patch862
Browse files Browse the repository at this point in the history
make sure image overlays are proxied
  • Loading branch information
patrickarlt authored Nov 14, 2016
2 parents 9639554 + d8f33ed commit 52a4ec7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"load-grunt-tasks": "^0.4.0",
"mkdirp": "^0.5.1",
"mocha": "^2.3.4",
"parallelshell": "^2.0.0",
"phantomjs": "^1.9.17",
"rollup": "^0.25.4",
"rollup-plugin-json": "^2.0.0",
Expand Down Expand Up @@ -75,7 +76,8 @@
"prepublish": "npm run build",
"pretest": "npm run build",
"release": "./scripts/release.sh",
"start": "watch 'npm run build' src & http-server -p 5000 -c-1 -o",
"start-watch": "watch \"npm run build\" src",
"start": "parallelshell \"npm run start-watch\" \"http-server -p 5000 -c-1 -o\"",
"test": "npm run lint && karma start"
},
"semistandard": {
Expand Down
24 changes: 23 additions & 1 deletion spec/Layers/DynamicMapLayerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ describe('L.esri.DynamicMapLayer', function () {
server.respond();
});

it('should bring itself to the front', function (done) {
it('should bring itself to the back', function (done) {
layer.on('load', function () {
var spy = sinon.spy(layer._currentImage, 'bringToBack');
layer.bringToBack();
Expand Down Expand Up @@ -322,6 +322,28 @@ describe('L.esri.DynamicMapLayer', function () {
expect(spy.getCall(0).args[0]).to.match(new RegExp(/http:\/\/services.arcgis.com\/mock\/arcgis\/rest\/services\/MockMapService\/MapServer\/export\?bbox=-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+&size=500%2C500&dpi=96&format=png24&transparent=true&bboxSR=3857&imageSR=3857&f=image/));
});

// it('should be able to request an image using a proxy', function (done) {
// server.respondWith('GET', new RegExp(/\.\/proxy\?http:\/\/services.arcgis.com\/mock\/arcgis\/rest\/services\/MockMapService\/MapServer\/export\?bbox=-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+&size=500%2C500&dpi=96&format=png24&transparent=true&bboxSR=3857&imageSR=3857&f=json/), JSON.stringify({
// href: 'http://services.arcgis.com/mock/arcgis/rest/directories/arcgisoutput/Census_MapServer/_ags_mapec70f175eca3415a97c0db6779ad9976.png',
// height: 421,
// width: 1675,
// scale: 18055.95482153688
// }));

// var proxiedLayer = L.esri.dynamicMapLayer({
// url: url,
// proxy: './proxy.ashx'
// });

// proxiedLayer.once('load', function () {
// expect(proxiedLayer._currentImage._url).to.equal('foo');
// done();
// });

// proxiedLayer.addTo(map);
// server.respond();
// });

it('should be able to parse real base64 images from the export service', function (done) {
server.respondWith('GET', new RegExp(/http:\/\/services.arcgis.com\/mock\/arcgis\/rest\/services\/MockMapService\/MapServer\/export\?bbox=-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+&size=500%2C500&dpi=96&format=png24&transparent=true&bboxSR=3857&imageSR=3857&f=json/), JSON.stringify({
imageData: base64Image,
Expand Down
8 changes: 8 additions & 0 deletions src/Layers/DynamicMapLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export var DynamicMapLayer = RasterLayer.extend({
if ((options.proxy || options.token) && options.f !== 'json') {
options.f = 'json';
}

L.Util.setOptions(this, options);
},

Expand Down Expand Up @@ -150,6 +151,10 @@ export var DynamicMapLayer = RasterLayer.extend({
params.token = this.service.options.token;
}

if (this.options.proxy) {
params.proxy = this.options.proxy;
}

return params;
},

Expand All @@ -160,6 +165,9 @@ export var DynamicMapLayer = RasterLayer.extend({
if (this.options.token) {
response.href += ('?token=' + this.options.token);
}
if (this.options.proxy) {
response.href = this.options.proxy + '?' + response.href;
}
if (response.href) {
this._renderImage(response.href, bounds);
} else {
Expand Down

0 comments on commit 52a4ec7

Please sign in to comment.