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

deck.gl not working with vue.js #2935

Closed
AlbertMarashi opened this issue Apr 10, 2019 · 4 comments
Closed

deck.gl not working with vue.js #2935

AlbertMarashi opened this issue Apr 10, 2019 · 4 comments
Labels

Comments

@AlbertMarashi
Copy link

Hello,

I'm trying to make deck.gl work inside a Vue application, however, it's not working for me. The canvas is being recognised and attached and the canvas becomes interactive (can grab) However, my red dot doesn't appear in the canvas. I'm not sure why this is happening

<template>
    <div style="height: 100%">
          <canvas id="my-canvas"></canvas>
    </div>
</template>
<script>
import { Deck } from "@deck.gl/core"
import { ScatterplotLayer } from "@deck.gl/layers"

export default {
    data(){
        return {
            deck: null
        }
    },
    mounted(){
        const INITIAL_VIEW_STATE = {
            latitude: 37.78,
            longitude: -122.45,
            zoom: 3
        }

        this.deck = new Deck({
            canvas: 'my-canvas',
            initialViewState: INITIAL_VIEW_STATE,
            controller: true,
            layers: [
                new ScatterplotLayer({
                    data: [{
                        position: [-122.45, 37.8],
                        color: [255, 0, 0],
                        radius: 100
                    }]
                })
            ]
        })
    },

}
</script>
@AlbertMarashi
Copy link
Author

Here's a codesandbox https://codesandbox.io/s/1mx1v97q3

@AlbertMarashi
Copy link
Author

I'd be glad to help with the development of deck.gl and expand its reach into other frameworks like Vue, but I can't get a simple standalone working.

@Pessimistress
Copy link
Collaborator

It is working, it's just that your layer does not render anything visible.

First, you need to specify the getRadius prop of the ScatterplotLayer. The default is 1. Second, the radius is in meters, so it's not visible at zoom level 3.

You can try adding the following to the layer:

getRadius: d => d.radius,
getColor: d => d.color,
radiusMinPixels: 1

AlbertMarashi pushed a commit to AlbertMarashi/deck.gl that referenced this issue Apr 10, 2019
Makes the red dot visible (at zoom 3 or 1 it was not visible) visgl#2935
AlbertMarashi pushed a commit to AlbertMarashi/deck.gl that referenced this issue Apr 10, 2019
Makes the red dot visible (at zoom 3 or 1 it was not visible) visgl#2935
@AlbertMarashi
Copy link
Author

@Pessimistress lol, thankyou! I've suggested some doc updates to make the standalone "get-started" guide simpler to get started. I think it'll help with adoption of deck.gl

@tgorkin tgorkin closed this as completed Apr 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants