Esri/esri-leaflet

SOLVED - Double url encoding breaks some dynamic layers

Jelfff opened this issue · 3 comments

Describe the bug

When using dynamicLayers to restyle data each single quote is double encoded to %2527. As a result, the data does not display. This double encoding happens for data type esriSMS. It does not happen for data type esriSLS.

Here is an example of a call that is sent to the server. Note all the instances of %2527

https://nowcoast.noaa.gov/arcgis/rest/services/nowcoast/obs_meteoceanhydro_insitu_pts_geolinks/MapServer/export?bbox=-12458624.11425745%2C5470445.240313496%2C-11206279.84283312%2C4987363.221551178&size=1024%2C395&dpi=96&format=png24&transparent=true&bboxSR=3857&imageSR=3857&dynamicLayers=%5B%7B%2527source%2527%3A%7B%2527type%2527%3A%2527mapLayer%2527%2C%2527mapLayerId%2527%3A1%7D%2C%2527drawingInfo%2527%3A%7B%2527renderer%2527%3A%7B%2527type%2527%3A%2527simple%2527%2C%2527symbol%2527%3A%7B%2527type%2527%3A%2527esriSMS%2527%2C%2527style%2527%3A%2527esriSMSCross%2527%2C%2527color%2527%3A%5B255%2C0%2C0%2C255%5D%2C%2527size%2527%3A10%7D%7D%7D%7D%5D&layers=show%3A1&f=image

The ArcGIS server sends back this message:
{"error":{"code":400,"message":"Missing 'source' in dynamic layer definition for 'id': -1.","details":[]}}

Expected behavior

If I decode the above call I get:

https://nowcoast.noaa.gov/arcgis/rest/services/nowcoast/obs_meteoceanhydro_insitu_pts_geolinks/MapServer/export?bbox=-12458624.11425745,5470445.240313496,-11206279.84283312,4987363.221551178&size=1024,395&dpi=96&format=png24&transparent=true&bboxSR=3857&imageSR=3857&dynamicLayers=[{'source':{'type':'mapLayer','mapLayerId':1},'drawingInfo':{'renderer':{'type':'simple','symbol':{'type':'esriSMS','style':'esriSMSCross','color':[255,0,0,255],'size':10}}}}]&layers=show:1&f=image

This call produces the desired result

Actual behavior

To Reproduce

This is my code attempting to restyle the data. You can see the call to the server on the console. The restyled data should appear when the map opens.

https://mappingsupport.com/p2/gissurfer.php?center=42.446413,-106.292725&zoom=7&basemap=USA_basemap&overlay=Weather_station&inline=overlay^name=Weather_station^url=https://nowcoast.noaa.gov/arcgis/rest/services/nowcoast/obs_meteoceanhydro_insitu_pts_geolinks/MapServer^layers=1^dynamicLayers=[{'source':{'type':'mapLayer','mapLayerId':1},'drawingInfo':{'renderer':{'type':'simple','symbol':{'type':'esriSMS','style':'esriSMSCross','color':[255,0,0,255],'size':10}}}}]

Screenshots

If applicable, add screenshots to help explain your problem.

Environment Information

  • Version of Leaflet (L.version): 1.7.1
  • Version of Esri Leaflet (L.esri.VERSION): 2.5.3
  • Your OS: [e.g. iOS] windows 10 PC
  • Browser and Version [e.g. chrome 80.0, safari 12.1.1] Firefox 86.0.1

Additional context

Add any other context about the problem here. If you're are not using the CDN, please note what loading/bundling library you are using (webpack, browserify, RequireJS)? I am hosting my own copy of leaflet 2.5.3

Hi, thanks for the report. When I click the link under "To Reproduce", I get an error page with no call to the server in the console - could you please provide a simplified replication case using JS Bin (or similar) so it's easy for us to see the code that's causing the problem? Thanks!

Ack! The "To reproduce" link was broken by github's url encoding. I will post something later today to demo the problem.

Oops! Problem is at my end. Sorry for false alarm!