Skip to content

Commit

Permalink
Merge pull request Esri#1036 from Biboba/issue979
Browse files Browse the repository at this point in the history
Issue979 - Add custom params support
  • Loading branch information
jgravois committed Jan 5, 2018
2 parents 640484d + 6445dbc commit 6a5c31f
Show file tree
Hide file tree
Showing 20 changed files with 300 additions and 52 deletions.
1 change: 1 addition & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = function (config) {
'spec/Layers/BasemapLayerSpec.js',
'spec/Layers/TiledMapLayerSpec.js',
'spec/Layers/RasterLayerSpec.js',
'spec/Layers/FeatureLayer/*Spec.js',
// 'spec/Layers/*Spec.js',
'spec/Tasks/*Spec.js',
'spec/Services/*Spec.js',
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"John Gravois <[email protected]> (http://johngravois.com)"
],
"dependencies": {
"@esri/arcgis-to-geojson-utils": "^1.0.4",
"@esri/arcgis-to-geojson-utils": "^1.0.5",
"leaflet-virtual-grid": "^1.0.3",
"tiny-binary-search": "^1.0.2"
},
Expand Down
29 changes: 29 additions & 0 deletions spec/Layers/DynamicMapLayerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ describe('L.esri.DynamicMapLayer', function () {
var WithTimeTimeOptions = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAH0AAAB9CAMAAAC4XpwXAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3Jl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Rjogj3aoDvnLbaDT6XQ6nU6n0+l0Op1Op9PpdDqdTqfT/1KPWIYYD+bpcTLmyQtyf947xmF6jI0e9+jNzLo09+Q+5jqlXBZm+oidKJdLLtCjYaNGNejWX3uu131mYrskS1Rfmt6Om5M51rMtcq6iUp5v61lbr3mUtX7in+rNmPWWTeeVE9FWfvrOcXt06bGXe5bcc7/y3XotXfv71lv5NzrOfxydTqfT6XQ6nU6n0+l0Op1Op9PpdDqdTv9gewCL6FN9G6INjAAAAABJRU5ErkJggg==';

var url = 'http://services.arcgis.com/mock/arcgis/rest/services/MockMapService/MapServer';
var urlWithParams = 'http://services.arcgis.com/mock/arcgis/rest/services/MockMapService/MapServer?foo=bar';
var layer;
var server;
var map;
Expand Down Expand Up @@ -103,6 +105,33 @@ describe('L.esri.DynamicMapLayer', function () {
server.respond();
});

it('should store additional params passed in url', function () {
layer = L.esri.dynamicMapLayer({
url: urlWithParams
}).addTo(map);

expect(layer.options.requestParams).to.deep.equal({ foo: 'bar' });
expect(layer.options.url).to.deep.equal(url + '/');
});

it('should use additional params passed in options', 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&foo=bar&f=json/), JSON.stringify({
href: WithParams
}));
layer = L.esri.dynamicMapLayer({
url: url,
requestParams: {
foo: 'bar'
}
});
layer.addTo(map);
layer.on('load', function () {
expect(layer._currentImage._url).to.equal(WithParams);
done();
});
server.respond();
});

it('will load a new image when the map moves', function (done) {
layer.addTo(map);

Expand Down
9 changes: 9 additions & 0 deletions spec/Layers/FeatureLayer/FeatureLayerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ describe('L.esri.FeatureLayer', function () {
expect(layer).to.be.an.instanceof(L.esri.FeatureLayer);
});

it('should store additional params passed in url', function () {
layer = L.esri.featureLayer({
url: 'http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0?foo=bar'
}).addTo(map);

expect(layer.options.requestParams).to.deep.equal({ foo: 'bar' });
expect(layer.options.url).to.deep.equal('http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/');
});

it('should create features on a map', function () {
expect(map.hasLayer(layer.getFeature(1))).to.equal(true);
expect(map.hasLayer(layer.getFeature(2))).to.equal(true);
Expand Down
46 changes: 46 additions & 0 deletions spec/Layers/FeatureLayer/FeatureManagerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('L.esri.FeatureManager', function () {
}

var url = 'http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0';
var urlWithParams = 'http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0?foo=bar';
var layer;
var sandbox;
var server;
Expand Down Expand Up @@ -218,6 +219,51 @@ describe('L.esri.FeatureManager', function () {
expect(map.attributionControl._container.innerHTML).to.contain('Esri');
});

it('should store additional params passed in url', function () {
layer = new MockLayer({
url: urlWithParams
}).addTo(map);

expect(layer.options.requestParams).to.deep.equal({ foo: 'bar' });
expect(layer.options.url).to.deep.equal(url + '/');
});

it('should use additional params passed in options', function () {
server.respondWith('GET', 'http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/query?returnGeometry=true&where=1%3D1&outSr=4326&outFields=*&inSr=4326&geometry=%7B%22xmin%22%3A-122.6953125%2C%22ymin%22%3A45.521743896993634%2C%22xmax%22%3A-122.6513671875%2C%22ymax%22%3A45.55252525134013%2C%22spatialReference%22%3A%7B%22wkid%22%3A4326%7D%7D&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&geometryPrecision=6&foo=bar&f=json', JSON.stringify({
fields: fields,
features: [feature2],
objectIdFieldName: 'OBJECTID'
}));

layer = new MockLayer({
url: url,
requestParams: {
foo: 'bar'
}
});

layer.addTo(map);

server.respond();

expect(layer.createLayers).to.have.been.calledWith([
{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [-122.673342, 45.537161]
},
'properties': {
'OBJECTID': 2,
'Name': 'Site 2',
'Type': 'Inactive',
'Time': new Date('January 15 2014 GMT-0800').valueOf()
},
'id': 2
}
]);
});

it('should be able to remove itself from a map', function () {
layer.addTo(map);
map.removeLayer(layer);
Expand Down
21 changes: 21 additions & 0 deletions spec/Layers/TiledMapLayerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('L.esri.TiledMapLayer', function () {
}

var url = 'http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer';
var urlWithParams = 'http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer?foo=bar';
var subdomainsUrl = 'http://{s}.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer';
var subdomainsArray = ['server', 'services'];
var layer;
Expand Down Expand Up @@ -110,6 +111,26 @@ describe('L.esri.TiledMapLayer', function () {
expect(layer.tileUrl).to.equal('http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}?token=foo');
});

it('should store additional params passed in url', function () {
layer = L.esri.tiledMapLayer({
url: urlWithParams
});

expect(layer.options.requestParams).to.deep.equal({ foo: 'bar' });
expect(layer.tileUrl).to.equal('http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}?foo=bar');
});

it('should use additional params passed in options', function () {
layer = L.esri.tiledMapLayer({
url: url,
requestParams: {
foo: 'bar'
}
});

expect(layer.tileUrl).to.equal('http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}?foo=bar');
});

it('should use a token passed with authenticate()', function () {
layer = L.esri.tiledMapLayer({
url: url
Expand Down
23 changes: 23 additions & 0 deletions spec/Tasks/FindSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,28 @@ describe('L.esri.Find', function () {

window._EsriLeafletCallbacks[request.id](sampleResponse);
});

it('should pass through arbitrary request parameters', function (done) {
var myTask = L.esri.find({
url: mapServiceUrl,
requestParams: {
foo: 'bar'
}
});

server.respondWith('GET', mapServiceUrl + 'find?sr=4326&contains=true&returnGeometry=true&returnZ=true&returnM=false&layers=0&searchText=Site&foo=bar&f=json', JSON.stringify(sampleResponse));

var request = myTask.layers('0').text('Site').run(function (error, featureCollection, raw) {
expect(featureCollection).to.deep.equal(sampleFeatureCollection);
expect(raw).to.deep.equal(sampleResponse);
done();
});

console.log(request.url);

expect(request).to.be.an.instanceof(XMLHttpRequest);

server.respond();
});
});
/* eslint-enable handle-callback-err */
22 changes: 22 additions & 0 deletions spec/Tasks/IdentifyFeaturesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,5 +320,27 @@ describe('L.esri.IdentifyFeatures', function () {

request.respond(200, { 'Content-Type': 'text/plain; charset=utf-8' }, JSON.stringify(sampleResponse));
});

it('should identify features passing through arbitrary request parameters', function (done) {
var polygonTask = L.esri.identifyFeatures({
url: mapServiceUrl,
requestParams: {
foo: 'bar'
}
}).on(map).at(geoJsonPolygon);

var request = polygonTask.run(function (error, featureCollection, raw) {
expect(featureCollection).to.deep.equal(sampleFeatureCollection);
expect(raw).to.deep.equal(sampleResponse);
done();
});

expect(request.url).to.contain('geometry=%7B%22rings%22%3A%5B%5B%5B-97%2C39%5D%2C%5B-97%2C41%5D%2C%5B-94%2C41%5D%2C%5B-94%2C39%5D%2C%5B-97%2C39%5D%5D%5D%2C%22spatialReference%22%3A%7B%22wkid%22%3A4326%7D%7D');
expect(request.url).to.contain('geometryType=esriGeometryPolygon');
expect(request.url).to.contain('sr=4326');
expect(request.url).to.contain('foo=bar');

request.respond(200, { 'Content-Type': 'text/plain; charset=utf-8' }, JSON.stringify(sampleResponse));
});
});
/* eslint-enable handle-callback-err */
25 changes: 22 additions & 3 deletions spec/Tasks/IdentifyImageSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,21 +459,40 @@ describe('L.esri.IdentifyImage', function () {

it('should return catalog items w/o geometry', function (done) {
var sampleResponseWithCatalogItemsNoGeometry = deepClone(sampleResponseWithCatalogItems);
var sampleResutlsWithCatalogItemsNoGeomerty = deepClone(sampleResultsWithCatlaogItems);
var sampleResultsWithCatalogItemsNoGeomerty = deepClone(sampleResultsWithCatlaogItems);
for (var i = sampleResponseWithCatalogItemsNoGeometry.catalogItems.features.length - 1; i >= 0; i--) {
delete (sampleResponseWithCatalogItemsNoGeometry.catalogItems.features[i].geometry);
sampleResutlsWithCatalogItemsNoGeomerty.catalogItems.features[i].geometry = null;
sampleResultsWithCatalogItemsNoGeomerty.catalogItems.features[i].geometry = null;
}
server.respondWith('GET', imageServiceUrl + 'identify?returnGeometry=false&geometry=%7B%22x%22%3A-122.66%2C%22y%22%3A45.51%2C%22spatialReference%22%3A%7B%22wkid%22%3A4326%7D%7D&geometryType=esriGeometryPoint&returnCatalogItems=true&f=json', JSON.stringify(sampleResponseWithCatalogItemsNoGeometry));

task.returnCatalogItems(true);
task.run(function (error, results, raw) {
expect(results).to.deep.equal(sampleResutlsWithCatalogItemsNoGeomerty);
expect(results).to.deep.equal(sampleResultsWithCatalogItemsNoGeomerty);
expect(raw).to.deep.equal(sampleResponseWithCatalogItemsNoGeometry);
done();
});

server.respond();
});

it('should pass through arbitrary parameters', function (done) {
var customTask = L.esri.identifyImage({
url: imageServiceUrl,
requestParams: {
foo: 'bar'
}
}).at(latlng);

server.respondWith('GET', imageServiceUrl + 'identify?returnGeometry=false&geometry=%7B%22x%22%3A-122.66%2C%22y%22%3A45.51%2C%22spatialReference%22%3A%7B%22wkid%22%3A4326%7D%7D&geometryType=esriGeometryPoint&foo=bar&f=json', JSON.stringify(sampleResponse));

customTask.run(function (error, results, raw) {
expect(results).to.deep.equal(sampleResults);
expect(raw).to.deep.equal(sampleResponse);
done();
});

server.respond();
});
});
/* eslint-enable handle-callback-err */
Loading

0 comments on commit 6a5c31f

Please sign in to comment.