Calling <Infos/> when receiving location intent.
This commit is contained in:
parent
93d13b749a
commit
a42c6d99a1
|
@ -24,6 +24,7 @@ import style from '../gpx/styles';
|
|||
import OsmFindAll from './OsmFindAll';
|
||||
import { eventNames } from 'pouchdb-browser';
|
||||
import { toLonLat } from 'ol/proj';
|
||||
import { getMap } from '../map';
|
||||
|
||||
const Item = styled(Paper)(({ theme }) => ({
|
||||
...theme.typography.body2,
|
||||
|
@ -47,9 +48,10 @@ const level2Key = (feature: Feature) =>
|
|||
export const clickHandler = (event: any) => {
|
||||
hierarchy = {};
|
||||
|
||||
const map = event.map || getMap();
|
||||
const pixel = [event.originalEvent.x, event.originalEvent.y];
|
||||
const features = event.map.getFeaturesAtPixel(pixel, { hitTolerance: 30 });
|
||||
setLocation(toLonLat(event.map.getCoordinateFromPixel(pixel)));
|
||||
const features = map.getFeaturesAtPixel(pixel, { hitTolerance: 30 });
|
||||
setLocation(toLonLat(map.getCoordinateFromPixel(pixel)));
|
||||
console.log({ caller: 'Infos.tsx / clickHandler', features, event });
|
||||
selectedFeatures.map((feature) => {
|
||||
if (feature.set) {
|
||||
|
|
|
@ -50,6 +50,7 @@ import MVT from 'ol/format/MVT.js';
|
|||
import style from '../gpx/styles';
|
||||
import ClusterableVectorTileSourceProxy from '../../lib/ClusterableVectorTileSourceProxy';
|
||||
import { Overlays } from '../overlays/Overlays';
|
||||
import { WindowSharp } from '@suid/icons-material';
|
||||
|
||||
const [getState, setState] = createSignal({
|
||||
lon: 0,
|
||||
|
@ -93,13 +94,17 @@ const Map: Component = () => {
|
|||
const url = new URL(intent.data);
|
||||
const q = url.search;
|
||||
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 });
|
||||
navigate(
|
||||
`/map/${getState().provider}/${lon}/${lat}/${zoom}/${
|
||||
getState().rotation
|
||||
}`
|
||||
);
|
||||
clickHandler({
|
||||
map: false,
|
||||
originalEvent: { x: window.innerWidth / 2, y: window.innerHeight / 2 },
|
||||
});
|
||||
});
|
||||
} else {
|
||||
console.log({
|
||||
|
|
Loading…
Reference in New Issue