Skip to content

Commit

Permalink
[Point d'intérêt]: remise du zoom lors de la sauvegarde d'un point d'…
Browse files Browse the repository at this point in the history
…intérêt (#1492)

Demande d'Adeline

Resolve #1214 

----

- [ ] Tests E2E (Cypress)
  • Loading branch information
maximeperraultdev authored Jun 20, 2024
2 parents b85af38 + a2bda1d commit d118379
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import {
Textarea,
getCoordinates
} from '@mtes-mct/monitor-ui'
import { WSG84_PROJECTION } from 'domain/entities/map/constants'
import { setDisplayedItems } from 'domain/shared_slices/Global'
import { setFitToExtent } from 'domain/shared_slices/Map'
import { boundingExtent } from 'ol/extent'
import { transformExtent } from 'ol/proj'
import { useCallback, useEffect, useMemo, useState } from 'react'
import styled from 'styled-components'

Expand All @@ -22,6 +26,8 @@ import { updateCoordinatesAction } from '../useCases/updateCoordinates'
import { updateNameAction } from '../useCases/updateName'
import { updateObservationsAction } from '../useCases/updateObservations'

import type { Coordinate } from 'ol/coordinate'

type EditInterestPointProps = {
cancel: () => void
close: () => void
Expand Down Expand Up @@ -91,9 +97,17 @@ export function EditInterestPoint({ cancel, close }: EditInterestPointProps) {
},
[dispatch]
)

function zoomIn() {
const formattedCoordinates = [coordinates[1], coordinates[0]] as Coordinate
const extent = transformExtent(boundingExtent([formattedCoordinates]), WSG84_PROJECTION, OPENLAYERS_PROJECTION)
dispatch(setFitToExtent(extent))
}

const save = () => {
dispatch(saveInterestPointFeature())
dispatch(saveInterestPoint())
zoomIn()
close()
}

Expand Down

0 comments on commit d118379

Please sign in to comment.