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

add support for dynamicLayers #566

Closed
pauldzy opened this issue Jun 26, 2015 · 13 comments · Fixed by #569
Closed

add support for dynamicLayers #566

pauldzy opened this issue Jun 26, 2015 · 13 comments · Fixed by #569

Comments

@pauldzy
Copy link

pauldzy commented Jun 26, 2015

Hello,

I was wondering if Esri-Leaflet would support some method to populate the dynamicLayers parameter. The use case is that I would like to reorder the internal feature classes in a AGS dynamic layer as shown here
http://developers.arcgis.com/javascript/samples/layers_dynamic_reorder/

I think this is 10.1 feature and just letting us sort out and drop in our own JSON string would be fine.

Thanks,
Paul

@jgravois
Copy link
Contributor

i'm not sure whether or not it'd be a good idea to add official 'support' for dynamic-layers in the API that's just an opportunity to pass in your own hand constructed JSON, but i did a quick test and it was pretty simple to add in...

getDynamicLayers: function(){
  return this.options.dynamicLayers;
},

setDynamicLayers: function(dynamicLayers){
  this.options.dynamicLayers = dynamicLayers;
  this._update();
  return this;
}

// ... 
_buildExportParams: function () {
  // ...
  if(this.options.dynamicLayers){
    params.dynamicLayers = this.options.dynamicLayers;
  }
  // ...

// then
L.esri.dynamicMapLayer('http://server/arcgis/rest/services/name/MapServer', {
  dynamicLayers: [
    {
      "id": foo,
      "name": "bar",
      "source": {
        "type": "mapLayer",
        "mapLayerId": 2
      },
      "drawingInfo": {
        ...
      }
    }
  ]
}).addTo(map);

you can find a complete working sample below:
jgravois@9ff18e8

let me know if you have any more questions about it

@tomwayson
Copy link
Member

Well, it's not on the roadmap, and from my experience, working w/ the LayerDrawingOptions can be complex (esp w/r/t renderers). I won't speak for @patrickarlt, but I wouldn't count on specific support for this.

I think your idea of "dropping in your own JSON string" is a good one though. So L.esri.Layers.DynamicMapLayer (and even all the other layers/tasks) could have a method like extraParameters() that you could pass a hash of prop/value pairs that would be sent along w/ every request to until you modified or cleared them. That could be a catch all for some of the less common params.

@jgravois
Copy link
Contributor

jgravois commented Jul 1, 2015

i like the idea @tomwayson, but what else did you have in mind in the way of uncommon parameters?

@tomwayson
Copy link
Member

I don't have anything else in mind. Really it's just things like this, where the implementation of a specific parameter could be complicated and not often used. Would be nice to have a way for the user to specify custom parameters as an extensibility point.

@jgravois
Copy link
Contributor

jgravois commented Jul 1, 2015

i still like the idea. im just going to rename the issue, add a FAQ tag and shelf for now, but the next time someone wants to insert a custom parameter into a request i'll take a 🔪 at implementing your suggestion.

@jgravois jgravois changed the title Esri-Leaflet support for dynamicLayers is it possible to insert a custom parameter in L.esri.dynamicMapLayer export requests? Jul 1, 2015
@patrickarlt
Copy link
Contributor

@tomwayson You got it wrong! I actually like the idea of supporting dynamicLayers. I know dynamicLayers is ludicrously complex but I'll need dynamicLayers support for being able to customize the traffic layer in the routing plugin and for the demographic maps. Adding a generic extraParameters() helper just seems kind of sloppy like we didn't think of everything and just added a catchall. I would rather just wrap everything up as methods and be done with it.

@jgravois
Copy link
Contributor

jgravois commented Jul 1, 2015

I actually like the idea of supporting dynamicLayers

hah. color me surprised.

are you saying you want what i already demoed above (which requires the developer to know what JSON they'd like to pass in) or actual helper methods to create JSON for them?

@patrickarlt
Copy link
Contributor

As much as I would love to have helper methods for the JSON its just to much of a mess to support everything. Its one of those advanced features that only a few people use and is really easy to implement so just needing to know the JSON object is fine by me.

@jgravois
Copy link
Contributor

jgravois commented Jul 1, 2015

i agree. actual support would be a beast.

i'll PR based on my suggestion above sometime soon, and make sure to include the appropriate documentation updates and corresponding tests.

if anyone else wants to help, that would be dandy too
cc/ @benstoltz @NoashX @natas333x2 etc. etc.

@tomwayson
Copy link
Member

can't be right all the time ¯_(ツ)_/¯

@jgravois jgravois changed the title is it possible to insert a custom parameter in L.esri.dynamicMapLayer export requests? add support for dynamicLayers Jul 1, 2015
@pauldzy
Copy link
Author

pauldzy commented Jul 3, 2015

Thanks everyone!

@bbehling
Copy link
Contributor

Similar to the JSAPI, is it possible to get the initial Dynamic Layer Infos using this leaflet plugin?

After the layer is loaded and call getDynamicLayers(), nothing is returned.

@jgravois
Copy link
Contributor

is it possible to get the initial Dynamic Layer Infos using this leaflet plugin?

we don't provide a wrapper method, but you can fetch the metadata for the service pretty easily and dig in for the 'layers' using L.esri.request

var mapUrl = 'http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer';

L.esri.request(mapUrl, {}, function (error, response) {
  console.log(response.layers);
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants