diff --git a/spec/Layers/FeatureLayer/FeatureLayerSpec.js b/spec/Layers/FeatureLayer/FeatureLayerSpec.js index 86cc471b7..24ea86c5e 100644 --- a/spec/Layers/FeatureLayer/FeatureLayerSpec.js +++ b/spec/Layers/FeatureLayer/FeatureLayerSpec.js @@ -52,7 +52,7 @@ describe('L.esri.Layers.FeatureLayer', function () { })]; beforeEach(function(){ - layer = L.esri.featureLayer('http://services.arcgis.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0', { + layer = L.esri.featureLayer('http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0', { timeField: 'time', pointToLayer: function(feature, latlng){ return L.circleMarker(latlng); @@ -63,7 +63,7 @@ describe('L.esri.Layers.FeatureLayer', function () { }); it('should fire a createfeature event', function(done){ - layer = L.esri.featureLayer('http://services.arcgis.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0', { + layer = L.esri.featureLayer('http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0', { timeField: 'time', pointToLayer: function(feature, latlng){ return L.circleMarker(latlng); @@ -79,7 +79,7 @@ describe('L.esri.Layers.FeatureLayer', function () { }); it('should have an alias at L.esri.Layers.featureLayer', function(){ - var layer = L.esri.Layers.featureLayer('http://services.arcgis.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0'); + var layer = L.esri.Layers.featureLayer('http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0'); expect(layer).to.be.an.instanceof(L.esri.Layers.FeatureLayer); }); @@ -227,7 +227,7 @@ describe('L.esri.Layers.FeatureLayer', function () { }); it('should unbind popups on multi polygon features', function(){ - layer = L.esri.featureLayer('http://services.arcgis.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0', { timeField: 'time' }).addTo(map); + layer = L.esri.featureLayer('http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0', { timeField: 'time' }).addTo(map); layer.createLayers(multiPolygon); layer.bindPopup(function(feature){ @@ -239,7 +239,7 @@ describe('L.esri.Layers.FeatureLayer', function () { }); it('should reset style on multi polygon features', function(){ - layer = L.esri.featureLayer('http://services.arcgis.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0', { + layer = L.esri.featureLayer('http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0', { style: { color: 'black' } @@ -259,7 +259,7 @@ describe('L.esri.Layers.FeatureLayer', function () { }); it('should reset to default style on multi polygon features', function(){ - layer = L.esri.featureLayer('http://services.arcgis.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0').addTo(map); + layer = L.esri.featureLayer('http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0').addTo(map); layer.createLayers(multiPolygon); @@ -294,7 +294,7 @@ describe('L.esri.Layers.FeatureLayer', function () { it('should run a function against every feature', function(){ var spy = sinon.spy(); - layer = L.esri.featureLayer('http://services.arcgis.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0', { + layer = L.esri.featureLayer('http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0', { onEachFeature: spy }).addTo(map); layer.createLayers(features); diff --git a/spec/Layers/FeatureLayer/FeatureManagerSpec.js b/spec/Layers/FeatureLayer/FeatureManagerSpec.js index d73467a3a..e6230bf6b 100644 --- a/spec/Layers/FeatureLayer/FeatureManagerSpec.js +++ b/spec/Layers/FeatureLayer/FeatureManagerSpec.js @@ -15,7 +15,7 @@ describe('L.esri.Layers.FeatureManager', function () { }).setView([45.51, -122.66], 14); } - var url = 'http://services.arcgis.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0'; + var url = 'http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0'; var layer; var sandbox; var server; @@ -203,8 +203,8 @@ describe('L.esri.Layers.FeatureManager', function () { }); it('should create features based on the current view of the map', function(){ - // http://services.arcgis.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&f=json - server.respondWith('GET', 'http://services.arcgis.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&f=json', JSON.stringify({ + // 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&f=json + 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&f=json', JSON.stringify({ fields: fields, features: [feature1, feature2], objectIdFieldName: 'OBJECTID' @@ -248,7 +248,7 @@ describe('L.esri.Layers.FeatureManager', function () { }); it('should fire a drawlimitexceeded event when there are more features then can be requested', function(done){ - server.respondWith('GET', 'http://services.arcgis.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&f=json', JSON.stringify({ + 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&f=json', JSON.stringify({ fields: fields, features: [], objectIdFieldName: 'OBJECTID', @@ -266,7 +266,7 @@ describe('L.esri.Layers.FeatureManager', function () { }); it('should filter existing features with a single time field', function(){ - server.respondWith('GET', 'http://services.arcgis.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&f=json', JSON.stringify({ + 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&f=json', JSON.stringify({ fields: fields, features: [feature2, feature3], objectIdFieldName: 'OBJECTID' @@ -288,7 +288,7 @@ describe('L.esri.Layers.FeatureManager', function () { }); it('should load more features with a single time field', function(){ - server.respondWith('GET', 'http://services.arcgis.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&time=1385884800000%2C1389340800000&f=json', JSON.stringify({ + 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&time=1385884800000%2C1389340800000&f=json', JSON.stringify({ fields: fields, features: [feature1], objectIdFieldName: 'OBJECTID' @@ -315,7 +315,7 @@ describe('L.esri.Layers.FeatureManager', function () { 'id': 1 }]); - server.respondWith('GET', 'http://services.arcgis.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&time=1389686400000%2C1389859200000&f=json', JSON.stringify({ + 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&time=1389686400000%2C1389859200000&f=json', JSON.stringify({ fields: fields, features: [feature2], objectIdFieldName: 'OBJECTID' @@ -351,7 +351,7 @@ describe('L.esri.Layers.FeatureManager', function () { } }); - server.respondWith('GET', 'http://services.arcgis.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&f=json', JSON.stringify({ + 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&f=json', JSON.stringify({ fields: fields, features: [feature4, feature5], objectIdFieldName: 'OBJECTID' @@ -380,7 +380,7 @@ describe('L.esri.Layers.FeatureManager', function () { } }); - server.respondWith('GET', 'http://services.arcgis.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&time=1389254400000%2C1389513600000&f=json', JSON.stringify({ + 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&time=1389254400000%2C1389513600000&f=json', JSON.stringify({ fields: fields, features: [feature4], objectIdFieldName: 'OBJECTID' @@ -407,7 +407,7 @@ describe('L.esri.Layers.FeatureManager', function () { 'type': 'Feature' }]); - server.respondWith('GET', 'http://services.arcgis.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&time=1389600000000%2C1389859200000&f=json', JSON.stringify({ + 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&time=1389600000000%2C1389859200000&f=json', JSON.stringify({ fields: fields, features: [feature5], objectIdFieldName: 'OBJECTID' @@ -439,13 +439,13 @@ describe('L.esri.Layers.FeatureManager', function () { }); it('should filter features with a where parameter', function(){ - server.respondWith('GET', 'http://services.arcgis.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/query?returnGeometry=true&where=Type%3D\'Active\'&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&f=json', JSON.stringify({ + server.respondWith('GET', 'http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/query?returnGeometry=true&where=Type%3D\'Active\'&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&f=json', JSON.stringify({ fields: fields, features: [feature1], objectIdFieldName: 'OBJECTID' })); - server.respondWith('GET', 'http://services.arcgis.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/query?returnGeometry=true&where=Type%3D\'Inactive\'&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&f=json', JSON.stringify({ + server.respondWith('GET', 'http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/query?returnGeometry=true&where=Type%3D\'Inactive\'&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&f=json', JSON.stringify({ fields: fields, features: [feature2], objectIdFieldName: 'OBJECTID' @@ -627,7 +627,7 @@ describe('L.esri.Layers.FeatureManager', function () { }); it('should wrap the addFeature method on the underlying service', function(done){ - server.respondWith('POST', 'http://services.arcgis.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/addFeatures', JSON.stringify({ + server.respondWith('POST', 'http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/addFeatures', JSON.stringify({ 'addResults' : [{ 'objectId' : 1, 'success' : true @@ -658,7 +658,7 @@ describe('L.esri.Layers.FeatureManager', function () { }); it('should wrap the updateFeature method on the underlying service and refresh', function(done){ - server.respondWith('POST', 'http://services.arcgis.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/updateFeatures', JSON.stringify({ + server.respondWith('POST', 'http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/updateFeatures', JSON.stringify({ 'updateResults' : [{ 'objectId' : 1, 'success' : true @@ -690,7 +690,7 @@ describe('L.esri.Layers.FeatureManager', function () { }); it('should wrap the removeFeature method on the underlying service', function(done){ - server.respondWith('POST', 'http://services.arcgis.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/deleteFeatures', JSON.stringify({ + server.respondWith('POST', 'http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/deleteFeatures', JSON.stringify({ 'deleteResults' : [{ 'objectId' : 1, 'success' : true @@ -710,13 +710,13 @@ describe('L.esri.Layers.FeatureManager', function () { }); it('should support generalizing geometries', function(){ - server.respondWith('GET', 'http://services.arcgis.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&maxAllowableOffset=0.00004291534423829546&f=json', JSON.stringify({ + 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&maxAllowableOffset=0.00004291534423829546&f=json', JSON.stringify({ fields: fields, features: [feature6], objectIdFieldName: 'OBJECTID', })); - var layer = new MockLayer('http://services.arcgis.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/', { + var layer = new MockLayer('http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/', { simplifyFactor: 0.5 }); @@ -750,7 +750,7 @@ describe('L.esri.Layers.FeatureManager', function () { }); it('should propagate events from the service', function(){ - server.respondWith('GET', 'http://services.arcgis.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&f=json', JSON.stringify({ + 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&f=json', JSON.stringify({ fields: fields, features: [], objectIdFieldName: 'OBJECTID', diff --git a/spec/Tasks/QuerySpec.js b/spec/Tasks/QuerySpec.js index aed46e926..66bda52ab 100644 --- a/spec/Tasks/QuerySpec.js +++ b/spec/Tasks/QuerySpec.js @@ -36,9 +36,9 @@ describe('L.esri.Tasks.Query', function () { var geoJsonPolygon = L.geoJson(rawGeoJsonPolygon); - var featureLayerUrl = 'http://services.arcgis.com/mock/arcgis/rest/services/MockFeatureService/FeatureServer/0/'; - var mapServiceUrl = 'http://services.arcgis.com/mock/arcgis/rest/services/MockMapService/MapServer/'; - var imageServiceUrl = 'http://services.arcgis.com/mock/arcgis/rest/services/MockImageService/ImageServer/'; + var featureLayerUrl = 'http://gis.example.com/mock/arcgis/rest/services/MockFeatureService/FeatureServer/0/'; + var mapServiceUrl = 'http://gis.example.com/mock/arcgis/rest/services/MockMapService/MapServer/'; + var imageServiceUrl = 'http://gis.example.com/mock/arcgis/rest/services/MockImageService/ImageServer/'; var sampleImageServiceQueryResponse = { 'fieldAliases': { @@ -742,4 +742,20 @@ describe('L.esri.Tasks.Query', function () { server.respond(); }); + it('should query GeoJSON from ArcGIS Online', function(done){ + task = L.esri.Tasks.query('http://services.arcgis.com/mock/arcgis/rest/services/MockFeatureService/FeatureServer/0/'); + + server.respondWith('GET', 'http://services.arcgis.com/mock/arcgis/rest/services/MockFeatureService/FeatureServer/0/query?returnGeometry=true&where=1%3D1&outSr=4326&outFields=*&f=geojson', JSON.stringify(sampleFeatureCollection)); + + var request = task.run(function(error, featureCollection, raw){ + expect(featureCollection).to.deep.equal(sampleFeatureCollection); + expect(raw).to.deep.equal(sampleFeatureCollection); + done(); + }); + + expect(request).to.be.an.instanceof(XMLHttpRequest); + console.log(request.url); + server.respond(); + }); + }); \ No newline at end of file diff --git a/src/Request.js b/src/Request.js index 14c86bff8..16136c649 100644 --- a/src/Request.js +++ b/src/Request.js @@ -7,7 +7,7 @@ function serialize(params){ var data = ''; - params.f = 'json'; + params.f = params.f || 'json'; for (var key in params){ if(params.hasOwnProperty(key)){ diff --git a/src/Tasks/Query.js b/src/Tasks/Query.js index 742399458..543b6e353 100644 --- a/src/Tasks/Query.js +++ b/src/Tasks/Query.js @@ -105,9 +105,20 @@ EsriLeaflet.Tasks.Query = EsriLeaflet.Tasks.Task.extend({ run: function(callback, context){ this._cleanParams(); - return this.request(function(error, response){ - callback.call(context, error, (response && EsriLeaflet.Util.responseToFeatureCollection(response)), response); - }, context); + + // if the service is hosted on arcgis online request geojson directly + if(EsriLeaflet.Util.isArcgisOnline(this.url)){ + this.params.f = 'geojson'; + return this.request(function queryCallback(error, response){ + callback.call(context, error, response, response); + }, context); + + // otherwise convert it in the callback then pass it on + } else { + return this.request(function queryCallback(error, response){ + callback.call(context, error, (response && EsriLeaflet.Util.responseToFeatureCollection(response)), response); + }, context); + } }, count: function(callback, context){ diff --git a/src/Util.js b/src/Util.js index 0f155f6ea..35af3fce7 100644 --- a/src/Util.js +++ b/src/Util.js @@ -391,6 +391,10 @@ return url; }; + EsriLeaflet.Util.isArcgisOnline = function(url){ + return (/\.arcgis\.com/g).test(url); + }; + EsriLeaflet.Util.geojsonTypeToArcGIS = function (geoJsonType) { var arcgisGeometryType; switch (geoJsonType) {