Put IGN map behind a feature flag
This commit is contained in:
parent
f1cbc9846e
commit
4c87e547b3
6 changed files with 24 additions and 16 deletions
|
@ -23,7 +23,7 @@ import {
|
|||
|
||||
const Map = ReactMapboxGl({});
|
||||
|
||||
function MapEditor({ featureCollection, url, preview, hasCadastres }) {
|
||||
function MapEditor({ featureCollection, url, preview, hasCadastres, ign }) {
|
||||
const drawControl = useRef(null);
|
||||
const [currentMap, setCurrentMap] = useState(null);
|
||||
|
||||
|
@ -313,7 +313,7 @@ function MapEditor({ featureCollection, url, preview, hasCadastres }) {
|
|||
trash: true
|
||||
}}
|
||||
/>
|
||||
<SwitchMapStyle style={style} setStyle={setStyle} />
|
||||
<SwitchMapStyle style={style} setStyle={setStyle} ign={ign} />
|
||||
<ZoomControl />
|
||||
</Map>
|
||||
</>
|
||||
|
@ -328,7 +328,8 @@ MapEditor.propTypes = {
|
|||
}),
|
||||
url: PropTypes.string,
|
||||
preview: PropTypes.bool,
|
||||
hasCadastres: PropTypes.bool
|
||||
hasCadastres: PropTypes.bool,
|
||||
ign: PropTypes.bool
|
||||
};
|
||||
|
||||
export default MapEditor;
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
|
||||
const Map = ReactMapboxGl({});
|
||||
|
||||
const MapReader = ({ featureCollection }) => {
|
||||
const MapReader = ({ featureCollection, ign }) => {
|
||||
const [currentMap, setCurrentMap] = useState(null);
|
||||
const [style, setStyle] = useState('ortho');
|
||||
const cadastresFeatureCollection = useMemo(
|
||||
|
@ -184,7 +184,7 @@ const MapReader = ({ featureCollection }) => {
|
|||
/>
|
||||
) : null}
|
||||
|
||||
<SwitchMapStyle style={style} setStyle={setStyle} />
|
||||
<SwitchMapStyle style={style} setStyle={setStyle} ign={ign} />
|
||||
<ZoomControl />
|
||||
</Map>
|
||||
);
|
||||
|
@ -195,7 +195,8 @@ MapReader.propTypes = {
|
|||
type: PropTypes.string,
|
||||
bbox: PropTypes.array,
|
||||
features: PropTypes.array
|
||||
})
|
||||
}),
|
||||
ign: PropTypes.bool
|
||||
};
|
||||
|
||||
export default MapReader;
|
||||
|
|
|
@ -13,7 +13,11 @@ const STYLES = {
|
|||
title: 'Vectoriel',
|
||||
preview: vector,
|
||||
color: '#000'
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
const IGN_STYLES = {
|
||||
...STYLES,
|
||||
ign: {
|
||||
title: 'Carte IGN',
|
||||
preview: vector,
|
||||
|
@ -21,8 +25,8 @@ const STYLES = {
|
|||
}
|
||||
};
|
||||
|
||||
function getNextStyle(style) {
|
||||
const styles = Object.keys(STYLES);
|
||||
function getNextStyle(style, ign) {
|
||||
const styles = Object.keys(ign ? IGN_STYLES : STYLES);
|
||||
let index = styles.indexOf(style) + 1;
|
||||
if (index === styles.length) {
|
||||
return styles[0];
|
||||
|
@ -30,9 +34,9 @@ function getNextStyle(style) {
|
|||
return styles[index];
|
||||
}
|
||||
|
||||
export const SwitchMapStyle = ({ style, setStyle }) => {
|
||||
const nextStyle = getNextStyle(style);
|
||||
const { title, preview, color } = STYLES[nextStyle];
|
||||
export const SwitchMapStyle = ({ style, setStyle, ign }) => {
|
||||
const nextStyle = getNextStyle(style, ign);
|
||||
const { title, preview, color } = (ign ? IGN_STYLES : STYLES)[nextStyle];
|
||||
|
||||
const imgStyle = {
|
||||
width: '100%',
|
||||
|
@ -69,5 +73,6 @@ export const SwitchMapStyle = ({ style, setStyle }) => {
|
|||
|
||||
SwitchMapStyle.propTypes = {
|
||||
style: PropTypes.string,
|
||||
setStyle: PropTypes.func
|
||||
setStyle: PropTypes.func,
|
||||
ign: PropTypes.bool
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- if champ.geometry?
|
||||
= react_component("MapReader", { featureCollection: champ.to_feature_collection } )
|
||||
= react_component("MapReader", { featureCollection: champ.to_feature_collection, ign: feature_enabled_for?(:carte_ign, champ.procedure) } )
|
||||
.geo-areas
|
||||
= render partial: 'shared/champs/carte/geo_areas', locals: { champ: champ, editing: false }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
- preview = !champ.persisted?
|
||||
= react_component("MapEditor", { featureCollection: champ.to_feature_collection, url: champs_carte_features_path(preview ? 'preview' : champ), preview: preview, hasCadastres: !!champ.cadastres? }, class: "carte-#{champ.id}")
|
||||
= react_component("MapEditor", { featureCollection: champ.to_feature_collection, url: champs_carte_features_path(preview ? 'preview' : champ), preview: preview, hasCadastres: !!champ.cadastres?, ign: feature_enabled_for?(:carte_ign, champ.procedure) }, class: "carte-#{champ.id}")
|
||||
|
||||
.geo-areas
|
||||
= render partial: 'shared/champs/carte/geo_areas', locals: { champ: champ, editing: true }
|
||||
|
|
|
@ -35,7 +35,8 @@ features = [
|
|||
:mini_profiler,
|
||||
:operation_log_serialize_subject,
|
||||
:pre_maintenance_mode,
|
||||
:xray
|
||||
:xray,
|
||||
:carte_ign
|
||||
]
|
||||
|
||||
def database_exists?
|
||||
|
|
Loading…
Reference in a new issue