Skip to content

Commit

Permalink
locate substation with zoom (#119)
Browse files Browse the repository at this point in the history
* [Map] Zoom camera on substation when locating it

- keep the the greater zoom level between user zoom and default zoom

---------

Signed-off-by: jamal-khey <myjamal89@gmail.com>
Co-authored-by: souissimai <133104748+souissimai@users.noreply.github.com>
  • Loading branch information
jamal-khey and souissimai authored Nov 8, 2024
1 parent 5573b0d commit ab27786
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/network-map-viewer/network/network-map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const INITIAL_CENTERED = {
centeredSubstationId: null,
centered: false,
};
const DEFAULT_LOCATE_SUBSTATION_ZOOM_LEVEL = 12;

// get polygon coordinates (features) or an empty object
function getPolygonFeatures() {
Expand Down Expand Up @@ -187,6 +188,9 @@ const NetworkMap = forwardRef((props, ref) => {
mapRef.current?.flyTo({
center: [geodata.lon, geodata.lat],
duration: 2000,
// only zoom if the current zoom is smaller than the new one
zoom: Math.max(mapRef.current?.getZoom(), props.locateSubStationZoomLevel),
essential: true,
});
setCentered({
lastCenteredSubstation: centered.centeredSubstationId,
Expand Down Expand Up @@ -643,6 +647,7 @@ NetworkMap.defaultProps = {
useName: true,
visible: true,
shouldDisableToolTip: false,
locateSubStationZoomLevel: DEFAULT_LOCATE_SUBSTATION_ZOOM_LEVEL,

onSubstationClick: () => {},
onSubstationClickChooseVoltageLevel: () => {},
Expand Down Expand Up @@ -696,7 +701,7 @@ NetworkMap.propTypes = {
useName: PropTypes.bool,
visible: PropTypes.bool,
shouldDisableToolTip: PropTypes.bool,

locateSubStationZoomLevel: PropTypes.number,
onHvdcLineMenuClick: PropTypes.func,
onLineMenuClick: PropTypes.func,
onTieLineMenuClick: PropTypes.func,
Expand Down

0 comments on commit ab27786

Please sign in to comment.