Skip to content

myMap.overlay(canvas) yields error: Cannot set property 'onload' of undefined #36

Description

@paraclete-pizza

Hello,

In attempting to go through the basic tutorial, I end up getting the following error:

mappa.js:224 Uncaught TypeError: Cannot set property 'onload' of undefined
    at o.value (mappa.js:224)
    at setup (map.html:31)
    at e.<anonymous> (p5.min.js:32)
    at e.<anonymous> (p5.min.js:32)
    at new e (p5.min.js:32)
    at e (p5.min.js:32)

I updated the out-of-date code for loading the mappa js file, and, indeed, the console reads "Mappa loaded!" so I'm not sure what is causing the issue. It seems to be prompted y the command "myMap.overlay(canvas);" which is at line 31 of my map.html code.

Pasted below is the full text of the HTML file:

<!DOCTYPE html>
<html lang="en">

<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>--->
  <script src="https://cdn.jsdelivr.net/npm/mappa-mundi/dist/mappa.min.js" type="text/javascript"></script>

</head>

<body>
  <script>
  // Create a variable to hold our map
let myMap;
// Create a variable to hold our canvas
let canvas;
// Create a new Mappa instance using Leaflet.
const mappa = new Mappa('Leaflet');

// p5.js setup
function setup(){
  // Create a canvas 640x640
  canvas = createCanvas(640,640); 
  // Add a grey background
  background(100);
  
 // Create a tile map with lat 0, lng 0, zoom 4
  myMap = mappa.tileMap(0,0,4); 
  // Overlay the canvas over the tile map
  myMap.overlay(canvas);
}



// p5.js draw
function draw(){

}
  </script>
</body>

</html>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions