Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions frontend/src/components/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '@hotosm/id/dist/iD.css';
import { OSM_CLIENT_ID, OSM_REDIRECT_URI, OSM_SERVER_URL } from '../config';
import messages from './messages';

export default function Editor({ setDisable, comment, presets, imagery, gpxUrl }) {
export default function Editor({ setDisable, comment, presets, imagery, gpxUrl, extraIdParams }) {
const dispatch = useDispatch();
const intl = useIntl();
const session = useSelector((state) => state.auth.session);
Expand All @@ -33,7 +33,33 @@ export default function Editor({ setDisable, comment, presets, imagery, gpxUrl }
}
}
}
}, [customImageryIsSet, imagery, iDContext, customSource]);

// wait till iDContext loads background
if (!iDContext?.background()) return;

// this fixes the custom imagery persisting from previous load
// when no imagery is selected in project setting
if (!imagery) {
// set Bing as default
const imagerySource = iDContext.background().findSource('Bing');
if (!imagerySource) return;
iDContext.background().baseLayerSource(imagerySource);
}

// this sets imagery offset from extraIdParams if present
if (extraIdParams) {
const params = new URLSearchParams(extraIdParams);
const offsetStr = params.get('offset'); // "10,-10"
if (!offsetStr) return;
const offsetInMeters = offsetStr.split(',').map(Number); // [10, -10]
const offset = window.iD.geoMetersToOffset(offsetInMeters);
iDContext.background().offset(offset);
} else {
// reset offset if params not present
// this is needed to fix the offset persisting from previous project issue
iDContext.background().offset([0, 0]);
}
}, [customImageryIsSet, imagery, iDContext, customSource, extraIdParams]);

useEffect(() => {
if (windowInit) {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/taskSelection/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export function TaskMapAction({ project, tasks, activeTasks, getTasks, action, e
setDisable={setDisable}
comment={project.changesetComment}
presets={project.idPresets}
extraIdParams={project.extraIdParams}
imagery={formatImageryUrlCallback(project.imagery)}
gpxUrl={getTaskGpxUrlCallback(project.projectId, tasksIds)}
/>
Expand Down