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

138
Views
No se puede obtener una matriz de capas en el oyente de capas abiertas

Estoy creando una aplicación Angular con Openlayers 6.5. Necesito ejecutar la función en el evento de un solo clic, pero de alguna manera la función en el oyente se ejecuta con datos de mapas antiguos:

 @Injectable({ providedIn: 'root' }) export class MapService { private map: Map; //..... // Runs when loading application createNewMap(): void { this.map = new Map({pixelRatio: 1}); } createObjectByClick() { // Runs when user clicks on a button console.info(this.map.getLayers().getArray()); // Here I get correct array of layers, 20 layers this.map.once('singleclick', this.listener); } const listener = (event) => { console.info(this.map.getLayers().getArray()); // Here I get incorrect array, only 2 //layers, which are added when application load map. this.createNewObject(event); // Function does not work, because it uses array of layers which is not correct } createNewObject(params: IconFeatureParams) { console.info(this.map.getLayers().getArray()); // Again incorrect array, 2 layers ...... // Below code is not working because this.map.getLayers().getArray() has only 2 layers }

El mapa se crea cuando la aplicación se acaba de cargar, se agregaron 2 TileLayers en ese momento. Posteriormente, se cargan más capas vectoriales. En el momento del problema, el mapa tiene 20 capas, sin embargo, en la función de escucha, solo hay 2 TileLayers iniciales. ¿Por qué el código en la función de escucha se ejecuta con datos antiguos? Lo siento, por la explicación poco clara, hice lo mejor que pude para explicar esta magia malvada :)

about 4 years ago · Juan Pablo Isaza
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!