cvalenzuela / Mappa

A canvas wrapper for Maps 🗺 🌍
https://mappa.js.org
359 stars 104 forks source link

Error with myMap.overlay(canvas) #19

Closed johhnry closed 1 year ago

johhnry commented 6 years ago

Hey,

I have a problem with mappa.js, it is the very basic. I was following the tutorial https://mappa.js.org/docs/simple-map.html and my code doesn't work :

let myMap;
let canvas;
const mappa = new Mappa('Leaflet');

function setup(){
     canvas = createCanvas(640,640); 
     background(100);

     myMap = mappa.tileMap(0,0,4); 

     myMap.overlay(canvas);
}

function draw(){

}

What I found is that the line myMap.overlay(canvas); is the problem. This is the console error :

mappa.js:224 Uncaught TypeError: Cannot set property 'onload' of undefined
    at o.value (mappa.js:224)
    at setup (test.js:11)
    at p5.<anonymous> (p5.js:9111)
    at p5.<anonymous> (p5.js:9041)
    at new p5 (p5.js:9323)
    at _globalInit (p5.js:5602)

Thanks for helping me.

cvalenzuela commented 6 years ago

I assume you are loading mappa with the script provided in the tutorial. There's an error with that link, need to updated it. For now just replace:

<head>
  <title>Basic Mappa Tutorial</title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.16/p5.min.js" type="text/javascript"></script>
  <script src="https://unpkg.com/mappa-mundi/dist/mappa.min.js" type="text/javascript"></script>
</head>

with

<head>
  <title>Basic Mappa Tutorial</title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.16/p5.min.js" type="text/javascript"></script>
  <script src="https://unpkg.com/mappa-mundi@0.0.5/dist/mappa.js" type="text/javascript"></script>
</head>
johhnry commented 6 years ago

Thank you very mutch for your answer, it works now.

Have a nice day!