Skip to content

Fixed: Request GeoJSON by default for feature services 1376 #1403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/Layers/FeatureLayer/FeatureManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,29 @@ export var FeatureManager = FeatureGrid.extend({
var supportedFormats = metadata.supportedQueryFormats;

// Check if someone has requested that we don't use geoJSON, even if it's available
// Check if someone has requested that we don't use geoJSON, even if it's available
var forceJsonFormat = false;
if (
this.service.options.isModern === false ||
this.service.options.isModern === false || // Explicitly disabled
this.options.fetchAllFeatures
) {
forceJsonFormat = true;
} else if (this.service.options.isModern === undefined) {
this.service.options.isModern = true; // Default to modern
}

// Unless we've been told otherwise, check to see whether service can emit GeoJSON natively

// Unless we've been told otherwise, check to see whether service can emit GeoJSON natively
if (
!forceJsonFormat &&
supportedFormats &&
supportedFormats.indexOf('geoJSON') !== -1
) {
this.service.options.isModern = true;
this.service.options.isModern = true; // Confirm GeoJSON support
} else if (this.service.options.isModern === undefined) {
this.service.options.isModern = true; // Default assumption
}

if (metadata.objectIdField) {
this.service.options.idAttribute = metadata.objectIdField;
}

// add copyright text listed in service metadata
if (
Expand Down
8 changes: 6 additions & 2 deletions src/Tasks/Query.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,18 @@ export var Query = Task.extend({
this._cleanParams();

// services hosted on ArcGIS Online and ArcGIS Server 10.3.1+ support requesting geojson directly
if (this.options.isModern || (isArcgisOnline(this.options.url) && this.options.isModern === undefined)) {
if (this.options.isModern === undefined) {
this.options.isModern = true; // Default to modern
}

if (this.options.isModern || isArcgisOnline(this.options.url)) {
this.params.f = 'geojson';

return this.request(function (error, response) {
this._trapSQLerrors(error);
callback.call(context, error, response, response);
}, this);

// otherwise convert it in the callback then pass it on
} else {
return this.request(function (error, response) {
Expand Down
Loading