Skip to content
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

Cannot draw on top of the tilemap. #32

Open
tiganov opened this issue Jun 6, 2019 · 0 comments
Open

Cannot draw on top of the tilemap. #32

tiganov opened this issue Jun 6, 2019 · 0 comments

Comments

@tiganov
Copy link

tiganov commented Jun 6, 2019

I am using the following:

  • ES6 (babel)
  • jQuery for loading the p5.js script
  • npm for mappa

It displays the tilemap just fine, but I cannot draw anything on top of it.

Here is the JavaScript code where I attempt to draw an ellipse at the mouse cursor on top of the map.

import $ from "jquery";
import Mappa from 'mappa-mundi';

$.getScript("https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/p5.js", function(data, textStatus, jqxhr) {

const key = 'REDACTED'

const mappa = new Mappa('Mapbox', key);

// Options for map
const options = {
  lat: 0,
  lng: 0,
  zoom: 4,
  studio: true,
  style: 'mapbox://styles/mapbox/traffic-night-v2',
};

let s = (sk) => {
  let myMap;
  let canvas;
  window.sk = sk;
  var width = $("#canvas").width();
  var height = $("#canvas").height();

  // SETUP
  sk.setup = () => {
    canvas = sk.createCanvas(width, height).parent('canvas');
    myMap = mappa.tileMap(options);
    myMap.overlay(canvas);
    sk.fill(109, 255, 0);
    sk.stroke(100);
    sk.background(100);
  }

  // DRAW
  sk.draw = () => {
    sk.clear();
    sk.ellipse(sk.mouseX, sk.mouseY, 40, 40);
  }
}
let P5 = new p5(s, "canvas");
});

And here is the HTML.

<html>
<head>
  <title>Express</title>
  <link rel="stylesheet" href="/css/style.css">
    <link rel="stylesheet" href="https://api.mapbox.com/mapbox.js/v3.1.1/mapbox.css">
    <script src="./dist/bundle.js"></script>
</head>
<body>
  <!--<canvas id="myCanvas" resize></canvas>-->
  <div class="master-grid">
    <div class="center-panel">
      <!---------------------------------------------------------->
      <div id="canvas" style="width: 100%; height: 100%;"></div>
      <!---------------------------------------------------------->
    </div>
  </div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant