Skip to content

Commit

Permalink
[FE-15599] Add ruler control to mapbox map (#689)
Browse files Browse the repository at this point in the history
* Add mapbox ruler, add control to mapbox map, style a bit

* Don't use their css
  • Loading branch information
johallar authored Jan 24, 2025
1 parent f7e0de7 commit 703ef1a
Show file tree
Hide file tree
Showing 6 changed files with 358 additions and 231 deletions.
7 changes: 7 additions & 0 deletions dist/charting.css
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,13 @@ body {
overflow: hidden;
box-shadow: none !important;
border: 1px solid #e2e2e2; }
.mapboxgl-ctrl-group.mapbox-ctrl-ruler {
bottom: 86px; }
.mapboxgl-ctrl-group.mapbox-ctrl-ruler button {
width: 28px;
height: 28px; }
.mapboxgl-ctrl-group.mapbox-ctrl-ruler button svg {
margin-top: 3px; }

.mapboxgl-ctrl-compass {
display: none !important; }
Expand Down
477 changes: 246 additions & 231 deletions dist/charting.js

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"dependencies": {
"@heavyai/data-layer": "npm:[email protected]",
"@heavyai/draw": "https://github.com/heavyai/mapd-draw.git#fc0b065",
"@mapbox-controls/ruler": "^3.0.0",
"@mapbox/unitbezier": "0.0.0",
"@mapd/connector": "github:omnisci/mapd-connector#d75148077a2a4b23d66d89c63d05c20e5735af2e",
"@mapd/crossfilter": "github:omnisci/mapd-crossfilter#6f291ac",
Expand Down
12 changes: 12 additions & 0 deletions scss/chart.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,18 @@ body {
overflow:hidden;
box-shadow: none !important;
border: 1px solid $gray2;

&.mapbox-ctrl-ruler {
// Just above the zoom controls, below the zoom to filters overlay
bottom: 86px;
button {
width: 28px;
height: 28px;
svg {
margin-top: 3px;
}
}
}
}

.mapboxgl-ctrl-compass {
Expand Down
11 changes: 11 additions & 0 deletions src/mixins/map-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as _ from "lodash"
import { redrawAllAsync, resetRedrawStack } from "../core/core-async"
import { utils } from "../utils/utils"
import { rasterDrawMixin } from "./raster-draw-mixin"
import RulerControl from "@mapbox-controls/ruler"

function valuesOb(obj) {
return Object.keys(obj).map(key => obj[key])
Expand Down Expand Up @@ -736,6 +737,16 @@ export default function mapMixin(

_map.dragRotate.disable()
_map.touchZoomRotate.disableRotation()

_map.addControl(
new RulerControl({
linePaint: {
"line-color": "#999",
"line-width": 2
}
}),
"bottom-right"
)
_map.addControl(new _mapboxgl.NavigationControl(), "bottom-right")
_map.addControl(new _mapboxgl.AttributionControl(), _attribLocation)
_map.addControl(
Expand Down

0 comments on commit 703ef1a

Please sign in to comment.