Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
Cómo aplicar un filtro para varias capas cuando se usa un objeto en JavaScript para ArcGis

Estoy usando la API de JavaScript de ArcGis para mostrar algunos mapas. Tengo ID de capas de características en un objeto como este:

 const layersByYears = [ { year: 1918, layers: [ { layerID: "443709212b894e9297888b3194b51100", opacity: 1.0, name: "ORP", featureLayer: null }, { layerID: "61a605dca69c4aa0ac1b3858ba328fd3", opacity: 1.0, name: "obceSouc", featureLayer: null } ] }, { year: 1936, layers: [ { layerID: "443709212b894e9297888b3194b51100", opacity: 1.0, name: "ORP", featureLayer: null }, { layerID: "61a605dca69c4aa0ac1b3858ba328fd3", opacity: 1.0, name: "obceSouc", featureLayer: null } ] }, { year: 1950, layers: [ { layerID: "23bcd52310854d6185e5f22a4eca0303", opacity: 1.0, name: "ORP", featureLayer: null }, { layerID: "61a605dca69c4aa0ac1b3858ba328fd3", opacity: 1.0, name: "obceSouc", featureLayer: null } ] }, { year: 1981, layers: [ { layerID: "401e9530ba074936800a8f596fc49d70", opacity: 1.0, name: "ORP", featureLayer: null }, { layerID: "61a605dca69c4aa0ac1b3858ba328fd3", opacity: 1.0, name: "obceSouc", featureLayer: null } ] }, ]

Tengo un elemento de entrada simple para elegir un año y cuando se hace clic en el botón, también se cambia la capa. El proyecto está aquí: https://www.pramenykrkonos.eu/wp-content/uploads/2022/06/index-3.html Está en idioma checo; lo que necesito es aplicar un filtro para la capa real.

Aquí es donde se crea la variable para cada capa:

 const createFL = (layer) => { if(layer.featureLayer !== null && layer.featureLayer !== undefined) return; layer.featureLayer = new FeatureLayer({ portalItem: { id: layer.layerID, opacity: layer.opacity !== undefined ? layer.opacity : 1.0, visible: false, } }) }

La expresión para el filtro se define aquí y debe aplicarse cuando se hace clic en el botón "doBtn".

 document.getElementById("doBtn").addEventListener("click",doQuery); const attributeName = document.getElementById("attSelect"); const expressionSign = document.getElementById("signSelect"); const inputValue = document.getElementById("valSelect"); let expression; function doQuery() { expression = attributeName.value + expressionSign.value + "'"+inputValue.value+"'"; document.getElementById("printResults").innerHTML = expression; featureLayer.definitionExpression = expression; }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Si entiendo el problema, supongo que una solución simple sería obtener las capas visibles y aplicar el filtro. Las capas visibles en este contexto son las capas "actuales", supongo.

Si ese es el caso, entonces su función será algo como esto,

 function doQuery() { expression = attributeName.value + expressionSign.value + "'" + inputValue.value + "'"; document.getElementById("printResults").innerHTML = expression; // get visible feature layers, and then apply filter concatedLayers.filter(l => l.visible).forEach(l => l.definitionExpression = expression); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!