Skip to content

Commit

Permalink
Merge 32152f9 into 25b7fa3
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Jun 4, 2019
2 parents 25b7fa3 + 32152f9 commit ec0ea3c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
11 changes: 8 additions & 3 deletions examples/website/map-tile/app.js
Expand Up @@ -2,6 +2,7 @@ import React, {PureComponent} from 'react';
import {render} from 'react-dom';

import DeckGL, {TileLayer, BitmapLayer} from 'deck.gl';
import {loadImage} from '@loaders.gl/images';

const INITIAL_VIEW_STATE = {
latitude: 47.65,
Expand Down Expand Up @@ -53,12 +54,16 @@ export class App extends PureComponent {
minZoom: 0,
maxZoom: 19,

getTileData: ({x, y, z}) => loadImage(`${tileServer}/${z}/${x}/${y}.png`),

renderSubLayers: props => {
const {x, y, z, bbox} = props.tile;
const {west, south, east, north} = bbox;
const {
bbox: {west, south, east, north}
} = props.tile;

return new BitmapLayer(props, {
image: `${tileServer}/${z}/${x}/${y}.png`,
data: null,
image: props.data,
bounds: [west, south, east, north]
});
}
Expand Down
24 changes: 11 additions & 13 deletions modules/layers/src/bitmap-layer/bitmap-layer.js
Expand Up @@ -93,7 +93,7 @@ export default class BitmapLayer extends Layer {
}

if (props.image !== oldProps.image) {
this.loadTexture();
this.loadTexture(props.image);
}

const attributeManager = this.getAttributeManager();
Expand Down Expand Up @@ -200,24 +200,22 @@ export default class BitmapLayer extends Layer {
}
}

loadTexture() {
loadTexture(image) {
if (typeof image === 'string') {
image = loadImage(image);
}
if (image instanceof Promise) {
image.then(data => this.loadTexture(data));
return;
}

const {gl} = this.context;
const {image} = this.props;

if (this.state.bitmapTexture) {
this.state.bitmapTexture.delete();
}

if (typeof image === 'string') {
loadImage(image).then(data => {
this.setState({
bitmapTexture: new Texture2D(gl, {
data,
parameters: DEFAULT_TEXTURE_PARAMETERS
})
});
});
} else if (image instanceof Texture2D) {
if (image instanceof Texture2D) {
this.setState({bitmapTexture: image});
} else if (
// browser object
Expand Down

0 comments on commit ec0ea3c

Please sign in to comment.