Calling <Infos/> when receiving location intent.

This commit is contained in:
Eric van der Vlist 2023-01-28 21:51:28 +01:00
parent 93d13b749a
commit a42c6d99a1
2 changed files with 10 additions and 3 deletions

View File

@ -24,6 +24,7 @@ import style from '../gpx/styles';
import OsmFindAll from './OsmFindAll'; import OsmFindAll from './OsmFindAll';
import { eventNames } from 'pouchdb-browser'; import { eventNames } from 'pouchdb-browser';
import { toLonLat } from 'ol/proj'; import { toLonLat } from 'ol/proj';
import { getMap } from '../map';
const Item = styled(Paper)(({ theme }) => ({ const Item = styled(Paper)(({ theme }) => ({
...theme.typography.body2, ...theme.typography.body2,
@ -47,9 +48,10 @@ const level2Key = (feature: Feature) =>
export const clickHandler = (event: any) => { export const clickHandler = (event: any) => {
hierarchy = {}; hierarchy = {};
const map = event.map || getMap();
const pixel = [event.originalEvent.x, event.originalEvent.y]; const pixel = [event.originalEvent.x, event.originalEvent.y];
const features = event.map.getFeaturesAtPixel(pixel, { hitTolerance: 30 }); const features = map.getFeaturesAtPixel(pixel, { hitTolerance: 30 });
setLocation(toLonLat(event.map.getCoordinateFromPixel(pixel))); setLocation(toLonLat(map.getCoordinateFromPixel(pixel)));
console.log({ caller: 'Infos.tsx / clickHandler', features, event }); console.log({ caller: 'Infos.tsx / clickHandler', features, event });
selectedFeatures.map((feature) => { selectedFeatures.map((feature) => {
if (feature.set) { if (feature.set) {

View File

@ -50,6 +50,7 @@ import MVT from 'ol/format/MVT.js';
import style from '../gpx/styles'; import style from '../gpx/styles';
import ClusterableVectorTileSourceProxy from '../../lib/ClusterableVectorTileSourceProxy'; import ClusterableVectorTileSourceProxy from '../../lib/ClusterableVectorTileSourceProxy';
import { Overlays } from '../overlays/Overlays'; import { Overlays } from '../overlays/Overlays';
import { WindowSharp } from '@suid/icons-material';
const [getState, setState] = createSignal({ const [getState, setState] = createSignal({
lon: 0, lon: 0,
@ -93,13 +94,17 @@ 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.min(18, getState().zoom); const zoom = Math.max(18, getState().zoom);
console.log({ caller: 'Intent receiver', intent, url, lat, lon, zoom }); console.log({ caller: 'Intent receiver', intent, url, lat, lon, zoom });
navigate( navigate(
`/map/${getState().provider}/${lon}/${lat}/${zoom}/${ `/map/${getState().provider}/${lon}/${lat}/${zoom}/${
getState().rotation getState().rotation
}` }`
); );
clickHandler({
map: false,
originalEvent: { x: window.innerWidth / 2, y: window.innerHeight / 2 },
});
}); });
} else { } else {
console.log({ console.log({