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