Doing the samething for WPts
This commit is contained in:
parent
ab1d644e8e
commit
deb1f267ab
|
@ -1,13 +1,10 @@
|
||||||
import { Component, createEffect, createResource } from 'solid-js';
|
import { Component, createEffect, createResource } from 'solid-js';
|
||||||
|
|
||||||
import OlMap from 'ol/Map';
|
|
||||||
|
|
||||||
import dispatch from '../../workers/dispatcher-main';
|
import dispatch from '../../workers/dispatcher-main';
|
||||||
import getUri from '../../lib/ids';
|
|
||||||
import VectorSource from 'ol/source/Vector';
|
import VectorSource from 'ol/source/Vector';
|
||||||
import GeoJSON from 'ol/format/GeoJSON';
|
import GeoJSON from 'ol/format/GeoJSON';
|
||||||
import { setBranch, tree } from '../map';
|
import { setBranch, tree } from '../map';
|
||||||
import { unwrap } from 'solid-js/store';
|
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { Component, createEffect, createResource } from 'solid-js';
|
import { Component, createEffect, createResource } from 'solid-js';
|
||||||
|
|
||||||
import OlMap from 'ol/Map';
|
|
||||||
|
|
||||||
import dispatch from '../../workers/dispatcher-main';
|
import dispatch from '../../workers/dispatcher-main';
|
||||||
import getUri from '../../lib/ids';
|
|
||||||
import VectorSource from 'ol/source/Vector';
|
import VectorSource from 'ol/source/Vector';
|
||||||
import GeoJSON from 'ol/format/GeoJSON';
|
import GeoJSON from 'ol/format/GeoJSON';
|
||||||
|
import { setBranch, tree } from '../map';
|
||||||
|
import { Feature } from 'ol';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
wptId: string;
|
wptId: string;
|
||||||
|
@ -27,7 +26,7 @@ export const Wpt: Component<Props> = ({ vectorSource, wptId: wptId }) => {
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
console.log({ caller: 'Wpt', vectorSource, wptId, wpt: wpt() });
|
console.log({ caller: 'Wpt', vectorSource, wptId, wpt: wpt() });
|
||||||
|
|
||||||
if (wpt()) {
|
if (wpt() && !tree[wptId]) {
|
||||||
let geo: any = {
|
let geo: any = {
|
||||||
type: 'FeatureCollection',
|
type: 'FeatureCollection',
|
||||||
features: [
|
features: [
|
||||||
|
@ -45,9 +44,17 @@ export const Wpt: Component<Props> = ({ vectorSource, wptId: wptId }) => {
|
||||||
const features = new GeoJSON().readFeatures(geo);
|
const features = new GeoJSON().readFeatures(geo);
|
||||||
console.log({ caller: 'Wpt', features });
|
console.log({ caller: 'Wpt', features });
|
||||||
vectorSource.addFeatures(features);
|
vectorSource.addFeatures(features);
|
||||||
|
setBranch(wptId, { features, updateHandler });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const updateHandler = (feature: Feature) => {
|
||||||
|
console.log({
|
||||||
|
caller: 'Wpt / updateHandler / clicked',
|
||||||
|
feature,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return <></>;
|
return <></>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue