Skip to content

Commit

Permalink
Fix scale control
Browse files Browse the repository at this point in the history
  • Loading branch information
alex3165 committed Feb 5, 2017
1 parent 6aa8200 commit 1d168c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"clean": "rm -rf dist",
"test": "jest",
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"build": "npm run lint && npm run test && tsc",
"build:watch": "tsc --watch",
"prepublish": "npm run clean && npm run build",
"version": "npm run build",
Expand Down
14 changes: 6 additions & 8 deletions src/scale-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ const scales = [
10 * 1000
];

const defaultPosition = { top: 10, right: 10, bottom: 'auto', left: 'auto' };

const positions = {
topRight: defaultPosition,
topLeft: defaultPosition,
bottomRight: defaultPosition,
bottomLeft: defaultPosition
topRight: { top: 10, right: 10, bottom: 'auto', left: 'auto' },
topLeft: { top: 10, left: 10, bottom: 'auto', right: 'auto' },
bottomRight: { bottom: 10, right: 10, top: 'auto', left: 'auto' },
bottomLeft: { bottom: 10, left: 10, top: 'auto', right: 'auto' }
};

const containerStyle = {
Expand Down Expand Up @@ -109,14 +107,14 @@ export default class ScaleControl extends React.Component<Props, State> {

const totalWidth = this._getDistanceTwoPoints(
[_sw.lng, _ne.lat],
[_sw.lng, _ne.lat],
[_ne.lng, _ne.lat],
measurement
);

const relativeWidth = totalWidth / clientWidth * MIN_WIDTH_SCALE;

const chosenScale = scales.reduce((acc, curr) => {
if (curr > relativeWidth) {
if (!acc && curr > relativeWidth) {
return curr;
}

Expand Down

0 comments on commit 1d168c3

Please sign in to comment.