New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot set property 'onload' of undefined #11
Comments
Is there any particular reason you are using p5 in instance mode? |
We are developing a webapp to create notebooks with some bock types (text, code, maps,...). One of these types is P5. The final user can write and execute p5 code on "live". |
I tried your code, removing the the |
Yes, I have to do that to move the map inside the div (see https://forum.processing.org/two/discussion/26239/p5-js-mappa-js-unable-to-place-map-in-parent-div) With p5 parent is not working, I tried with mappa and canvas element. Thanks |
Do you have p5.dom.js in your sketch? All the examples on the website are appending the canvas to another div with |
Yes, I have p5.dom . But, removing $("#mappa").detach().appendTo("#DivName"); and using .parent() the map is drawing outside the Div. |
It seems the example from the Processing forum was using version 0.0.4 directly from npm. Here's the same CodePen from the forum but with version 0.0.5 https://codepen.io/anon/pen/Zxeemq thanks for pointing this out! I just updated the version on npm! |
Perfect! Thanks a lot! |
Hi guys,
I'm getting this error when I re-run this skeatch:
let myMap;
let canvas;
let locationData;
const mappa = new Mappa('Leaflet');
const options = {
lat: 40,
lng: 0,
zoom: 4,
style: "http://{s}.tile.osm.org/{z}/{x}/{y}.png"
}
p5.setup = function() {
locationData = p5.getCurrentPosition();
canvas = p5.createCanvas(640,640);
myMap = mappa.tileMap(options);
myMap.overlay(canvas);
// Add a color to our ellipse
p5.fill(200, 100, 100);
console.log(locationData.latitude +" "+ locationData.longitude);
}
p5.draw = function() {
p5.clear();
console.log(locationData.latitude +" "+ locationData.longitude);
// Every Frame, get the canvas position
// for the latitude and longitude of Nigeria
const nigeria = myMap.latLngToPixel(locationData.latitude, locationData.longitude);
// Using that position, draw an ellipse
p5.ellipse(nigeria.x, nigeria.y, 20, 20);
$("#mappa").detach().appendTo("#kajero-p5-3");
}
The error is invocked by myMap.overlay(canvas); . I executed correctly the sketch in the first time, but I'm getting this error the second time.
Best
The text was updated successfully, but these errors were encountered: