Call <Finder> on intent

This commit is contained in:
Eric van der Vlist 2023-02-02 17:26:56 +01:00
parent dec79c9c2d
commit 0af58ccb4f
2 changed files with 5 additions and 10 deletions

View File

@ -16,6 +16,7 @@ import WptEditDialog from '../wpt/WptEditDialog';
const [popup, setPopup] = createSignal<Overlay>(); const [popup, setPopup] = createSignal<Overlay>();
const [open, setOpen] = createSignal(false); const [open, setOpen] = createSignal(false);
const [coordinate, setCoordinate] = createSignal<Coordinate>();
let popupElement: HTMLElement; let popupElement: HTMLElement;
export const findLocation = ( export const findLocation = (
@ -37,6 +38,7 @@ export const findLocation = (
popup: popup(), popup: popup(),
popupElement, popupElement,
}); });
setCoordinate(coordinate);
popup().setMap(getMap()); popup().setMap(getMap());
popup().setPosition(fromLonLat(coordinate)); popup().setPosition(fromLonLat(coordinate));
getMap()?.addOverlay(popup()); getMap()?.addOverlay(popup());
@ -54,7 +56,6 @@ const Finder: Component<Props> = (props) => {
const [searchString, setSearchString] = createSignal(''); const [searchString, setSearchString] = createSignal('');
const [popupContent, setPopupContent] = createSignal(<></>); const [popupContent, setPopupContent] = createSignal(<></>);
const [t, { add, locale, dict }] = useI18n(); const [t, { add, locale, dict }] = useI18n();
const [coordinate, setCoordinate] = createSignal<Coordinate>();
const searchStringChangeHandler = (event: any) => { const searchStringChangeHandler = (event: any) => {
setSearchString(event.target.value); setSearchString(event.target.value);
}; };

View File

@ -42,7 +42,7 @@ import { debounce } from 'lodash';
import { AndroidFullScreen } from '@awesome-cordova-plugins/android-full-screen'; import { AndroidFullScreen } from '@awesome-cordova-plugins/android-full-screen';
import Account from '../account'; import Account from '../account';
import { Overlays } from '../overlays/Overlays'; import { Overlays } from '../overlays/Overlays';
import Finder from '../finder'; import Finder, { findLocation } from '../finder';
const [getState, setState] = createSignal({ const [getState, setState] = createSignal({
lon: 0, lon: 0,
@ -92,13 +92,8 @@ const Map: Component = () => {
const url = new URL(intent.data); const url = new URL(intent.data);
const q = url.search; const q = url.search;
const [, lat, lon] = q.match(/q=([0-9.-]+),([0-9.-]+)/); const [, lat, lon] = q.match(/q=([0-9.-]+),([0-9.-]+)/);
const zoom = Math.max(16, getState().zoom); console.log({ caller: 'Intent receiver', intent, url, lat, lon });
console.log({ caller: 'Intent receiver', intent, url, lat, lon, zoom }); findLocation(navigate, [lon, lat]);
navigate(
`/map/${getState().provider}/${lon}/${lat}/${zoom}/${
getState().rotation
}#mark=fromIntent`
);
}); });
} else { } else {
console.log({ console.log({
@ -297,7 +292,6 @@ const Map: Component = () => {
<Account /> <Account />
<AllGpxes map={getMap} /> <AllGpxes map={getMap} />
<Infos /> <Infos />
</div> </div>
); );
}; };