Skip to content

Commit

Permalink
Add an option to disable automatic zoom in routing plugin (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
cazitouni authored Oct 4, 2024
1 parent 6bb9832 commit 7a5f40a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions plugins/Routing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class Routing extends React.Component {
showPinLabels: PropTypes.bool,
task: PropTypes.object,
theme: PropTypes.object,
/** Automatically zoom to the extent of the route */
zoomAuto: PropTypes.bool,
zoomToExtent: PropTypes.func
};
static defaultProps = {
Expand All @@ -83,7 +85,8 @@ class Routing extends React.Component {
initiallyDocked: true,
side: 'left'
},
showPinLabels: true
showPinLabels: true,
zoomAuto: true
};
state = {
visible: false,
Expand Down Expand Up @@ -766,7 +769,9 @@ class Routing extends React.Component {
});
this.updateRouteConfig({points: reorderedPoints, result: {success, data: result}, busy: false}, false);

this.props.zoomToExtent(result.summary.bounds, "EPSG:4326", -1);
if (this.props.zoomAuto) {
this.props.zoomToExtent(result.summary.bounds, "EPSG:4326", -1);
}
} else {
this.updateRouteConfig({result: {success, data: result}, busy: false}, false);
}
Expand Down Expand Up @@ -807,7 +812,9 @@ class Routing extends React.Component {
}
}));
this.props.addLayerFeatures(layer, features, true);
this.props.zoomToExtent(result.bounds, "EPSG:4326", -0.5);
if (this.props.zoomAuto) {
this.props.zoomToExtent(result.bounds, "EPSG:4326", -0.5);
}
}
this.updateIsoConfig({result: {success, data: result}, busy: false}, false);
});
Expand Down

0 comments on commit 7a5f40a

Please sign in to comment.