Differentiating between web and non web platforms.

This commit is contained in:
Eric van der Vlist 2023-02-06 18:52:14 +01:00
parent a458b82dc1
commit 8355ee4c1e
3 changed files with 32 additions and 9 deletions

View File

@ -5,6 +5,13 @@
margin-left: calc(100% - 230px) !important; margin-left: calc(100% - 230px) !important;
z-index: 1; z-index: 1;
} }
.control_web {
opacity: 1;
position: fixed !important;
top: 0px;
margin-left: calc(100% - 190px) !important;
z-index: 1;
}
.ol_popup { .ol_popup {
position: absolute; position: absolute;
background-color: white; background-color: white;

View File

@ -112,7 +112,13 @@ const Finder: Component<Props> = (props) => {
return ( return (
<> <>
<div class={style.control}> <div
class={
window.Capacitor.platform === 'web'
? style.control_web
: style.control
}
>
<IconButton <IconButton
onClick={() => { onClick={() => {
setOpen(true); setOpen(true);

View File

@ -10,6 +10,7 @@ import Attribution from 'ol/control/Attribution';
import Rotate from 'ol/control/Rotate'; import Rotate from 'ol/control/Rotate';
import ScaleLine from 'ol/control/ScaleLine'; import ScaleLine from 'ol/control/ScaleLine';
import Control from 'ol/control/Control'; import Control from 'ol/control/Control';
import Zoom from 'ol/control/Zoom';
import { fromLonLat, toLonLat } from 'ol/proj'; import { fromLonLat, toLonLat } from 'ol/proj';
import DragRotate from 'ol/interaction/DragRotate'; import DragRotate from 'ol/interaction/DragRotate';
@ -43,6 +44,7 @@ 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, { findLocation } from '../finder'; import Finder, { findLocation } from '../finder';
import { ZoomIn } from '@suid/icons-material';
const [getState, setState] = createSignal({ const [getState, setState] = createSignal({
lon: 0, lon: 0,
@ -252,6 +254,16 @@ const Map: Component = () => {
// vectorTile: clusterableVectorTileSource.getProjection(), // vectorTile: clusterableVectorTileSource.getProjection(),
// }); // });
let controls = [
new Attribution({ collapsible: true }),
new Rotate(),
new ScaleLine({ bar: true }),
];
if (window.Capacitor.platform === 'web') {
controls.push(new Zoom());
}
const olMap = new OlMap({ const olMap = new OlMap({
view: new View({ view: new View({
center: fromLonLat([+getState().lon, +getState().lat]), center: fromLonLat([+getState().lon, +getState().lat]),
@ -260,11 +272,7 @@ const Map: Component = () => {
}), }),
layers: [tileLayer, vectorLayer], layers: [tileLayer, vectorLayer],
target: target, target: target,
controls: new Collection<Control>([ controls: new Collection<Control>(controls),
new Attribution({ collapsible: true }),
new Rotate(),
new ScaleLine({ bar: true }),
]),
moveTolerance: 10, moveTolerance: 10,
interactions: new Collection<Interaction>([ interactions: new Collection<Interaction>([
new DragRotate(), new DragRotate(),
@ -291,9 +299,11 @@ const Map: Component = () => {
<Overlays map={getMap} /> <Overlays map={getMap} />
<Finder /> <Finder />
<GetLocation /> <GetLocation />
<Forward /> <Show when={window.Capacitor.platform !== 'web'}>
<Back /> <Forward />
<GpxRecord /> <Back />
<GpxRecord />
</Show>
<GpxImport /> <GpxImport />
<MapTileProvider /> <MapTileProvider />
<GpxDialog /> <GpxDialog />