Skip to content

Commit 1f4003e

Browse files
committed
Handle extent in url params
1 parent ca11170 commit 1f4003e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

plugins/Bookmark.jsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import classnames from 'classnames';
1313
import isEmpty from 'lodash.isempty';
1414
import PropTypes from 'prop-types';
1515

16-
import { zoomToPoint } from '../actions/map';
16+
import { zoomToExtent, zoomToPoint } from '../actions/map';
1717
import Icon from '../components/Icon';
1818
import SideBar from '../components/SideBar';
1919
import Spinner from '../components/Spinner';
@@ -39,6 +39,7 @@ class Bookmark extends React.Component {
3939
side: PropTypes.string,
4040
state: PropTypes.object,
4141
task: PropTypes.string,
42+
zoomToExtent: PropTypes.func,
4243
zoomToPoint: PropTypes.func
4344
};
4445
static defaultProps = {
@@ -131,10 +132,15 @@ class Bookmark extends React.Component {
131132
};
132133
zoomToBookmarkExtent = (bookmarkkey) => {
133134
resolveBookmark(bookmarkkey, (params) => {
134-
const scale = parseFloat(params.s);
135-
const zoom = MapUtils.computeZoom(this.props.mapScales, scale);
136-
const center = params.c.split(/[;,]/g).map(x => parseFloat(x));
137-
this.props.zoomToPoint(center, zoom, this.props.mapCrs);
135+
if ('c' in params && 's' in params) {
136+
const scale = parseFloat(params.s);
137+
const zoom = MapUtils.computeZoom(this.props.mapScales, scale);
138+
const center = params.c.split(/[;,]/g).map(x => parseFloat(x));
139+
this.props.zoomToPoint(center, zoom, this.props.mapCrs);
140+
} else if ('e' in params) {
141+
const bounds = (params.e).split(',').map(n => parseFloat(n));
142+
this.props.zoomToExtent(bounds, this.props.mapCrs);
143+
}
138144
});
139145
};
140146
toggleCurrentBookmark = (bookmark) => {
@@ -189,5 +195,6 @@ const selector = state => ({
189195
});
190196

191197
export default connect(selector, {
198+
zoomToExtent: zoomToExtent,
192199
zoomToPoint: zoomToPoint
193200
})(Bookmark);

0 commit comments

Comments
 (0)