Skip to content
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

allow override of 'isModern' #935

Merged
merged 4 commits into from
Mar 13, 2017

Conversation

spoilsportmotors
Copy link
Contributor

Add an option to let users decide to not use geoJSON, even if the
underlying service supports it. Occasionally handy when ArcGIS Server
has geoJSON geometry problems.

Add an option to let users decide to not use geoJSON, even if the
underlying service supports it. Occasionally handy when ArcGIS Server
has geoJSON geometry problems.
@jgravois
Copy link
Contributor

jgravois commented Mar 9, 2017

thanks so much for this!

it's not a good idea to set isModern to true by default (because of old feature services)

my first instinct is to just include a conditional check within the metadata response handler and skip setting the property for users 'if' they already set it themselves.

hope that makes sense.

@spoilsportmotors
Copy link
Contributor Author

It does make more sense; let me got back and change the behavior.

Keep the default for “isModern” to be optimistically true, to preserve
back compatibility. Fix the test to allow metadata to disable geoJSON.
@spoilsportmotors
Copy link
Contributor Author

I updated PR #935; for back-compatibility, I think the option needs to be left explicit & set to 'true'. The metadata check will explicitly set isModern correctly if there isn't server support (older servers).

@jgravois
Copy link
Contributor

jgravois commented Mar 9, 2017

I think the option needs to be left explicit & set to 'true'

why exactly? i see two distinct benefits to not assuming that a feature service endpoint supports geojson.

  1. support for geojson was introduced in ArcGIS Server 10.3.1. a substantial number of customers are running something older.
  2. since all feature services support native esri json, switching from f=json to f=geojson (when appropriate) is a seamless transition. the inverse will result in requests that fail.

@spoilsportmotors
Copy link
Contributor Author

The submitted PR does exactly what you're asking; it'll cheerfully ask for f=geojson only when the service supports it, just like before. The only difference is that someone (ok, me), can specify isModern: false in the options, and I'll get f=json on all the requests.

The current behavior will always use f=geojson if it can; the PR keeps that behavior. Anyone upgrading won't see a change in how requests are made.

If instead we change the default behavior to use f=json, then people will see a difference in the requests made, and they'd have to change their code to allow the use of geoJSON.

I'm happy to change the default value - but opting out of geoJSON seemed a better choice than forcing people to change their code to opt-in. Regardless, if the service doesn't support geoJSON, the requests will use f=json.

@jgravois
Copy link
Contributor

jgravois commented Mar 10, 2017

The current behavior will always use f=geojson if it can; the PR keeps that behavior

i ran a quick test using your branch and confirmed that this is not true.

// 10.01 ArcGIS Server instance that doesn't support f=geojson
var fl = L.esri.featureLayer({
  url:'http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5'
}).addTo(map);

because the initial queries are executed before the metadata response is retrieved, the fact that you are setting isModern as the default property for FeatureManager alters the behavior and causes f=geojson requests to go out when the property is not set manually by the developer.

screenshot 2017-03-10 11 01 22

@spoilsportmotors
Copy link
Contributor Author

Gaaah.

IDK why I didn't see that here, but ... I get it. Thanks for your patience; update in the works.

Fix tests for ‘isModern’ to not require a default value; update
‘isModern’ as part of the tests for geoJSON support, allowing for a
user override.
Explicit test for false is sufficient.
@spoilsportmotors
Copy link
Contributor Author

Yay. Tests pass.
I built out a hokey test app here, and it does what's expected when you pass isModern: false in the options, and also the property is missing - so no changes are needed to existing apps that want to use geoJSON.

Thanks for your patience - I didn't fully grok the startup process when a new layer is created & added (honestly, probably still don't.)

@jgravois jgravois merged commit df09fca into Esri:master Mar 13, 2017
@jgravois
Copy link
Contributor

thanks for your contribution!

it may have been intentional on your part, but the actual commits you pushed are associated with @ahwarren and not @spoilsportmotors.

jgravois pushed a commit to jgravois/esri-leaflet that referenced this pull request Apr 23, 2022
* allow override of 'isModern'

Add an option to let users decide to not use geoJSON, even if the
underlying service supports it. Occasionally handy when ArcGIS Server
has geoJSON geometry problems.

* Explicitly set isModern properly

Keep the default for “isModern” to be optimistically true, to preserve
back compatibility. Fix the test to allow metadata to disable geoJSON.

* Remove default value for 'isModern'

Fix tests for ‘isModern’ to not require a default value; update
‘isModern’ as part of the tests for geoJSON support, allowing for a
user override.

* Kill useless test for undefined

Explicit test for false is sufficient.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants