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

[FE-8035] Upgrade Mapbox #373

Merged
merged 51 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
beebb9b
upgrade mapbox to latest
CaitW Jul 22, 2019
fa6a5fc
remove global
CaitW Jul 22, 2019
5cff735
update stylesheet
CaitW Jul 22, 2019
87cd2ca
import where needed
CaitW Jul 22, 2019
f92330d
Copy old modified functions
CaitW Jul 22, 2019
14515cd
use copied getImage
CaitW Jul 22, 2019
d061ebc
fix typo
CaitW Jul 22, 2019
27d9430
use ported `timed` function
CaitW Jul 22, 2019
68b48ca
build
CaitW Jul 24, 2019
cfb7a1f
test adding this back in
CaitW Jul 26, 2019
1cd1050
re-add global variable, remove direct imports
CaitW Jul 26, 2019
2c06ce2
build
CaitW Jul 26, 2019
02e61d8
merge master
CaitW Jul 29, 2019
9bbbd50
try using mapbox getImage
CaitW Aug 1, 2019
81b7812
set opacity based on layer type
CaitW Aug 1, 2019
096ac3f
remove newline
CaitW Aug 1, 2019
608cfbe
build
CaitW Aug 1, 2019
0660c3d
modify controls
CaitW Aug 2, 2019
ec8cf6b
Remove this
CaitW Aug 5, 2019
7e5e678
And this
CaitW Aug 5, 2019
f4c8f6f
build
CaitW Aug 5, 2019
5e8ba58
update map style
CaitW Aug 5, 2019
02095ff
move zoom button up
CaitW Aug 5, 2019
821551d
force map logo to stay on
CaitW Aug 5, 2019
b224708
build
CaitW Aug 5, 2019
8dfcf39
Finally figure out styling arrangement for all controls
CaitW Aug 6, 2019
81d5684
Merge master
CaitW Aug 6, 2019
7426c23
build
CaitW Aug 6, 2019
9b6fd16
no longer needed
CaitW Aug 6, 2019
6905645
Replace with mapbox util fn
CaitW Aug 6, 2019
de619c7
build
CaitW Aug 6, 2019
096d7a5
remove unused variable
CaitW Aug 6, 2019
5d89639
add bezier
CaitW Aug 6, 2019
0fa1cfc
package-lock and build
CaitW Aug 7, 2019
8d73909
Merge master
CaitW Aug 7, 2019
607d0c7
formatting
CaitW Aug 7, 2019
16d95fd
Use non-mapbox getImage
CaitW Aug 7, 2019
fe16dd8
axios + build
CaitW Aug 7, 2019
6a0b4a7
Make sure that multiple mapbox logos appear
CaitW Aug 7, 2019
37e455e
build
CaitW Aug 7, 2019
a8bd4fd
typo
CaitW Aug 7, 2019
1d39d38
remove redundant redundancy
CaitW Aug 7, 2019
f4851bb
minor visual adjustment
CaitW Aug 7, 2019
59450b3
build
CaitW Aug 7, 2019
0b11e2c
remove unused imports / files
CaitW Aug 7, 2019
33e0e84
merge master
CaitW Aug 8, 2019
71453d2
package-lock and build
CaitW Aug 8, 2019
4c099dc
undo opacity changes
CaitW Aug 19, 2019
da419a7
call updateDraw on original events for pan and mousewheel
uyanga-gb Aug 28, 2019
24093c4
remove event when map is off
uyanga-gb Aug 28, 2019
63c312b
running prettier
uyanga-gb Aug 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
480 changes: 400 additions & 80 deletions dist/mapdc.css

Large diffs are not rendered by default.

31,900 changes: 12,036 additions & 19,864 deletions dist/mapdc.js

Large diffs are not rendered by default.

1,054 changes: 378 additions & 676 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@
"test:unit": "find ./src -name '*.spec.js' | BABEL_ENV=test NODE_PATH=./src xargs nyc mocha --opts ./test/mocha.unit.opts"
},
"dependencies": {
"@mapbox/unitbezier": "0.0.0",
"@mapd/mapd-draw": "git://github.com/omnisci/mapd-draw.git#fa59fbf68ded25619b5f71b3ee6a73cea9f8d149",
"@turf/bbox": "^6.0.1",
"@turf/bbox-clip": "^6.0.3",
"axios": "^0.19.0",
"d3": "^3.5.17",
"earcut": "^2.1.1",
"fast-deep-equal": "^2.0.1",
"http-server": "^0.11.1",
"legendables": "git://github.com/omnisci/legendables.git#63e2ad9a8375a11e5510a5dadf0b7a4326fae888",
"mapbox-gl": "https://github.com/omnisci/mapbox-gl-js/tarball/35231362c7b6f2b63590fd184a38d8ac15fdf57d",
"mapbox-gl": "^1.1.1",
"mapd-data-layer-2": "0.0.22",
"moment": "^2.19.3",
"ramda": "0.21.0",
Expand Down
35 changes: 19 additions & 16 deletions scss/chart.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,25 @@ body {
}
}

.mapboxgl-ctrl-bottom-right {
// Attribution
.mapboxgl-ctrl.mapboxgl-ctrl-attrib {
margin: 0 !important;
position: absolute;
white-space: nowrap;
right: 100px;
bottom: 7px;
font-size: 11px;
&.mapboxgl-compact {
bottom: 5px;
}
}
// Zoom
.mapboxgl-ctrl.mapboxgl-ctrl-group {
margin: 0 10px 10px 0 !important;
}
}

.mapboxgl-ctrl-top-left {
.mapboxgl-ctrl {
margin: 8px 0 0 8px !important;
Expand Down Expand Up @@ -1963,22 +1982,6 @@ body {
}
}

.mapbox-maplogo {
position:absolute;
display:block;
height: 20px;
width: 65px;
right: 80px !important;
bottom: 20px;
text-indent: -9999px;
z-index:99999;
overflow:hidden;
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIIAAAAoCAMAAAAFWtJHAAAAwFBMVEUAAAAAAAAAAABtbW0AAAAAAAAAAAAAAAAAAAAAAAClpaUAAADp6ekAAAD5+fna2toAAAAMDAzv7+/Nzc0AAAA2Njb8/Pz9/f3T09MAAAAAAAD7+/sAAAArKyuxsbH39/fs7OwbGxuIiIjz8/N8fHyenp7u7u74+PgAAAC8vLxWVlbx8fF1dXXl5eVcXFyUlJTQ0NDFxcVCQkLAwMC4uLj19fXo6OjW1tarq6ve3t77+/vi4uL6+vrKysrNzc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AFuNmQPuKAEAjYNQ0CyeoUEWHYBnpQVQgpvc0Ph+gsKlAnKg1+vEHsw5LKciLKCAJobiWBzYFGbCKpHqkZZrxBFHEASyFI59vJPCskcwNVGOWZAOqsrR+pKbaNeAMT1CixMEtlnsqopNxUMzVJT3tY35aXZm6a6Y9QhwMN6BUJWbE1lhbMO1WehkO7poO0sK7em9MJGxp1XSbC1gtugzzSLQmGsX7VntJGSwsPZ2d2z3bIPKzdoOp3Wzqt8G4XyMVUoFIxLx1S7+piaHtCvR3FeRVsq0GFdp9C5TbGpcNqsPqyHKxcfd14h21KhuLKUFU4f3osrC7F6uV3WXFnadL7wyAPeKDXw2RoJCO5GY4DouYvb/gepVXheLoewzPseQG9N/vzilrMIjoStE3++zvle4eSurw7XEe76ynI4aq+v7lEyt1x5awiFlFLQbHKIpabnM3eJLym4Szzzc/du7SU+zOXv9UNpECH7IoH/gecURPlN9vdQpeD47yhIFNX0U0QgvID9nENm+yxk/xb+AGAjNfRZuk9qAAAAAElFTkSuQmCC);
background-repeat:no-repeat;
background-position: 0 0 ;
background-size: 65px 20px;
}

.mapd-draw-button-control-group {
margin: 8px 0 0 8px;
float: left;
Expand Down
3 changes: 3 additions & 0 deletions src/charts/raster-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,9 @@ function genLayeredVega(chart) {
const vegaSpec = {
width: Math.round(width),
height: Math.round(height),
viewRenderOptions: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the trick BE needs?

premultipliedAlpha: false
},
data,
scales,
projections,
Expand Down
10 changes: 4 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
require("../mapdc.css")
require("../scss/chart.scss")
require("mapbox-gl/dist/styles.css")
require("mapbox-gl/dist/mapbox-gl.css")
require("legendables/src/styles.css")
require("./mixins/d3.box.js")
require("./polyfills/inner-svg")

if (process.env.BABEL_ENV !== "test") {
window.mapboxgl = require("mapbox-gl/dist/mapbox-gl.js")
require("mapbox-gl/dist/mapboxgl-overrides.js")
window.mapboxgl = require("mapbox-gl")
}

require("./mixins/d3.box.js")
require("./polyfills/inner-svg")

export * as d3 from "d3" // eslint-disable-line
export * from "./core/core"
export * from "./core/core-async"
Expand Down
98 changes: 59 additions & 39 deletions src/mixins/coordinate-grid-raster-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import bindEventHandlers from "./ui/coordinate-grid-raster-mixin-ui"
import colorMixin from "./color-mixin"
import d3 from "d3"
import marginMixin from "./margin-mixin"
import axios from "axios"

/**
* Coordinate Grid Raster is an abstract base chart designed to support coordinate grid based
Expand Down Expand Up @@ -681,54 +682,73 @@ export default function coordinateGridRasterMixin (_chart, _mapboxgl, browser) {
}
}

const TRANSPARENT_PNG_URL = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=';

function renderChart (imgUrl, renderBounds, queryId) {
const gl = _gl

if (imgUrl) { // should we check to see if the imgUrl is the same from the previous render?
_mapboxgl.util.getImage(imgUrl, (err, img) => {
if (queryId === _queryId) {
const xdom = _chart.x().domain()
const ydom = _chart.y().domain()
const onImageLoad = (err, img) => {
if (err) {
throw err
}
if (queryId === _queryId) {
const xdom = _chart.x().domain()
const ydom = _chart.y().domain()

if (xdom[0] === renderBounds[0][0] && xdom[1] === renderBounds[1][0] && ydom[0] === renderBounds[2][1] && ydom[1] === renderBounds[0][1]) {
if (xdom[0] === renderBounds[0][0] && xdom[1] === renderBounds[1][0] && ydom[0] === renderBounds[2][1] && ydom[1] === renderBounds[0][1]) {

if (!_tex) {
createGLTexture()
}
if (!_tex) {
createGLTexture()
}

if (!_img || img.width != _img.width || img.height != _img.height) {
// Image was updated and dimensions changed.
gl.bindTexture(gl.TEXTURE_2D, _tex)
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, img)

if (!_img || img.width != _img.width || img.height != _img.height) {
// Image was updated and dimensions changed.
gl.bindTexture(gl.TEXTURE_2D, _tex)
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, img)

if (!_img) {
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
}
} else {
// Image was updated but dimensions unchanged.
gl.bindTexture(gl.TEXTURE_2D, _tex)
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, img)
if (!_img) {
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
}
_img = img

_scale[0] = 1
_scale[1] = 1
_offset[0] = 0
_offset[1] = 0
const xrange = _chart.xRange()
const yrange = _chart.yRange()
_currDataBounds[0][0] = xrange[0]
_currDataBounds[0][1] = xrange[1]
_currDataBounds[1][0] = yrange[0]
_currDataBounds[1][1] = yrange[1]

renderChart()
} else {
// Image was updated but dimensions unchanged.
gl.bindTexture(gl.TEXTURE_2D, _tex)
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, img)
}
_img = img

_scale[0] = 1
_scale[1] = 1
_offset[0] = 0
_offset[1] = 0
const xrange = _chart.xRange()
const yrange = _chart.yRange()
_currDataBounds[0][0] = xrange[0]
_currDataBounds[0][1] = xrange[1]
_currDataBounds[1][0] = yrange[0]
_currDataBounds[1][1] = yrange[1]

renderChart()
}
})
}
}

if (imgUrl) { // should we check to see if the imgUrl is the same from the previous render?
axios.get(imgUrl, {
responseType: 'arraybuffer'
}).then(({ data }) => {
const img = new window.Image();
const URL = window.URL || window.webkitURL;
img.onload = () => {
onImageLoad(null, img);
URL.revokeObjectURL(img.src);
};
img.onerror = () => onImageLoad(new Error('Could not load scatterplot image'));
const blob = new window.Blob([new Uint8Array(data)], { type: 'image/png' });
img.src = data.byteLength ? URL.createObjectURL(blob) : TRANSPARENT_PNG_URL;
})
}

if (queryId !== null && queryId !== undefined) { _queryId = queryId }
Expand Down
Loading