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

250
Views
Use la fuente OpenLayers Canvas con Image static

He estado tratando de dibujar en Canvas usando OpenLayers (v6.1.1) pero, desafortunadamente, tengo problemas con la implementación de Canvas.

He intentado este enfoque simple:

 const extent = [0, 0, 1024, 968]; const projection = new ol.proj.Projection({ code: 'pixel-projection', units: 'pixels', extent: extent, }); let canvas = document.createElement('canvas'); canvas.width = 1024; canvas.height = 968; let ctx = canvas.getContext('2d'); ctx.fillStyle = 'green'; ctx.fillRect(0, 0, 100, 100); const imageLayer = new ol.layer.Image({ source: new ol.source.ImageCanvas({ canvas: canvas, projection: projection, imageExtent: extent, }), });

pero estoy recibiendo un error indefinido:

ingrese la descripción de la imagen aquí

Además, aquí hay un violín para facilitar la navegación: https://jsfiddle.net/Loque/ur5gw270/4/

Cualquier ayuda sería muy apreciada, gracias.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

ImageCanvas necesita una opción canvasFunction :

 source: new ol.source.ImageCanvas({ canvasFunction: function() { return canvas; }, projection: projection, imageExtent: extent, ratio: 1, }),

ImageStatic necesita una opción de url :

 source: new ol.source.ImageStatic({ url: canvas.toDataURL(), projection: projection, imageExtent: extent, }),
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!