JS API: the URLSearchParams interface vs. urlToObject()

328
0
07-06-2020 01:26 PM
Egge-Jan_Pollé
MVP Regular Contributor

Hi,

I have found a nice way to get, and set, my x and y coordinates and zoom level from, and to, the query string of my url.

With the URLSearchParams interface I can manipulate the search parameters and with the History.replaceState() method I can modify the url.

It works alright. The search parameters in this link ArcGIS JavaScript with UK data - URL Parameters: x, y and zoomlevel (?x=345835&y=381863&l=14) will fly you directly to John Lennon Airport in Liverpool.

More info in this blog: https://community.esri.com/people/EPolle_TensingInternational/blog/2020/07/06/arcgis-javascript-with... 

And now the question:

Is this the correct approach, or should I have used urlUtils.urlToObject() instead? What would be the pros and cons of either way?

What is your opinion?

TIA,

Egge-Jan

0 Kudos
0 Replies