-
Notifications
You must be signed in to change notification settings - Fork 23
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
style method is not called for polygons and linear features #23
Comments
I debugged a bit - seems to be the problem is that features are loaded asynchronously and so the initial call to My workaround hack was to simply call
|
Also (originally) posted on GIS stackexchange |
something like this would work: const url = 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Time_Zones/FeatureServer/0'
L.esri.request(url, {}, function (err, response) {
if (response.geometryType === "esriGeometryPoint") {
L.esri.Cluster.featureLayer({ url }).addTo(map)
} else {
L.esri.featureLayer({ url }).addTo(map);
}
})
Internally we're calling Leaflet's own L.GeoJSON.geometryToLayer({
"type": "LineString",
"coordinates": [
[20.0, 0.0],
[100.0, 45.0]
]
}, {
style: function (feature) {
return { color: 'red' }
}
}).addTo(map); I think that's a bug, but I'm also happy to just remove |
Thanks for clarifying - So my solution was to call For my first attempt I was using I propose to maybe just update the documentation to note that I could push a proposed docs update, but I didn't find the docs in the repo; maybe I'm just looking in wrong place? Seems to be maintained on Esri's website. Anyway - thanks for a cool library! Update: the solution for checking the feature service layer's geometry type also works and is viable. I am not very familiar with Esri's nuances. I didn't realize that ArcGIS tends to have (or can only support?) just one geometry per layer. I've worked with other geodatabases that separate feature layers into classes based on business data & purpose rather than by geometry type. For example, when working with bridges, some are linear features / linear referenced, and some are point features. (Don't blame the messenger here; that may just be my clients being weird..) I spoke to a colleague who works with ArcGIS and he also showed me (1) a way to interrogate feature service layer for geometry type, and (2) that it was not a convention for ArcGIS to use different geometries in a single layer. (Though I'm still not clear on whether this applies to mixing Polygons and MultiPolgons in a single layer.. but moot point because they're both vector types in Leaflet.) Should I close this issue? Standing by on decision about revising the docs.. thanks. |
you can find it here: https://github.com/Esri/esri-leaflet-doc/blob/master/src/pages/api-reference/layers/cluster-feature-layer.md
That's correct. Polygons and MultiPolygons can live side by side in a single layer, but LineStrings and Polygons can not. |
cc/ @patrickarlt for visibility, since he isn't listed as watching this repo. |
@nothingisnecessary regarding
I leave it up to you. We welcome pull requests for documentation changes but we can also close out this issue if you wish. |
Reference doc shows a
style
method which is similar to what vanilla Leaflet uses for styling vector features:https://esri.github.io/esri-leaflet/api-reference/layers/cluster-feature-layer.html
The style method works fine with L.esri.featureLayer, but I do not see it ever getting called when using a polygon or linear feature service. Is there some trick to get it to work - or some known issues? I couldn't find any code examples of it working with the Esri cluster plugin.
And yes - I know it doesn't really make sense to cluster vectors, but I have a generic utility that is not aware of the geometry type of the feature service... though if there is a way to auto detect that I could use L.esri.featureLayer instead, I suppose... but since the documentation says it works, and since I do see implementations of
options.style
andsetStyle
/resetStyle
in the source, I figured I would try to use it.Sample code:
The text was updated successfully, but these errors were encountered: