Dirty display of vector tiles feature properties in Infos.tsx
This commit is contained in:
parent
fa60f5229c
commit
cb8e564270
|
@ -102,7 +102,7 @@ const textFillSel = new Fill({
|
||||||
});
|
});
|
||||||
|
|
||||||
const trksegStroke = new Stroke({
|
const trksegStroke = new Stroke({
|
||||||
color: 'blue',
|
color: [11, 16, 71, 0.8],
|
||||||
width: 3,
|
width: 3,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ const trksegStrokeSel = new Stroke({
|
||||||
});
|
});
|
||||||
|
|
||||||
const rteStroke = new Stroke({
|
const rteStroke = new Stroke({
|
||||||
color: 'green',
|
color: [18, 71, 11, 0.8],
|
||||||
width: 3,
|
width: 3,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -288,16 +288,16 @@ const styles = {
|
||||||
}),
|
}),
|
||||||
nwn: new Stroke({
|
nwn: new Stroke({
|
||||||
color: [174, 33, 219, 0.8],
|
color: [174, 33, 219, 0.8],
|
||||||
width: 4,
|
width: 5,
|
||||||
}),
|
}),
|
||||||
rwn: new Stroke({
|
rwn: new Stroke({
|
||||||
color: [174, 33, 219, 0.8],
|
color: [174, 33, 219, 0.8],
|
||||||
width: 4,
|
width: 5,
|
||||||
lineDash: [10, 10],
|
lineDash: [10, 10],
|
||||||
}),
|
}),
|
||||||
lwn: new Stroke({
|
lwn: new Stroke({
|
||||||
color: [174, 33, 219, 0.8],
|
color: [174, 33, 219, 0.8],
|
||||||
width: 2,
|
width: 3,
|
||||||
lineDash: [10, 10],
|
lineDash: [10, 10],
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -332,12 +332,13 @@ const styles = {
|
||||||
isSelected: feature.get('isSelected') ?? false,
|
isSelected: feature.get('isSelected') ?? false,
|
||||||
name: feature.get('name'),
|
name: feature.get('name'),
|
||||||
klass: feature.get('class'),
|
klass: feature.get('class'),
|
||||||
isHidden: zoom() < 14,
|
isTextHidden: zoom() < 19,
|
||||||
|
isHidden: zoom() < 16,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getStyle: memoize((params: any) => {
|
getStyle: memoize((params: any) => {
|
||||||
console.log({ caller: 'getStyle', params });
|
console.log({ caller: 'getStyle', params });
|
||||||
const { isSelected, name, klass, isHidden } = params;
|
const { isSelected, name, klass, isHidden, isTextHidden } = params;
|
||||||
if (isHidden) {
|
if (isHidden) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -352,11 +353,12 @@ const styles = {
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
// anchor: [0, 0],
|
// anchor: [0, 0],
|
||||||
}),
|
}),
|
||||||
text: name
|
text:
|
||||||
|
name && !isTextHidden
|
||||||
? new Text({
|
? new Text({
|
||||||
text: name,
|
text: name,
|
||||||
font: 'bold 14px "Open Sans", "Arial Unicode MS", "sans-serif"',
|
font: 'bold 14px "Open Sans", "Arial Unicode MS", "sans-serif"',
|
||||||
offsetY: +20,
|
offsetY: +40,
|
||||||
padding: [0, 0, 0, 0],
|
padding: [0, 0, 0, 0],
|
||||||
fill: new Fill({
|
fill: new Fill({
|
||||||
color: 'black',
|
color: 'black',
|
||||||
|
|
|
@ -21,6 +21,7 @@ const Item = styled(Paper)(({ theme }) => ({
|
||||||
const [open, setOpen] = createSignal(false);
|
const [open, setOpen] = createSignal(false);
|
||||||
|
|
||||||
let selectedFeatures: Feature[] = [];
|
let selectedFeatures: Feature[] = [];
|
||||||
|
let vectorLayerFeatures: Feature[] = [];
|
||||||
let hierarchy: any = {};
|
let hierarchy: any = {};
|
||||||
|
|
||||||
const level2Key = (feature: Feature) =>
|
const level2Key = (feature: Feature) =>
|
||||||
|
@ -39,6 +40,10 @@ export const clickHandler = (event: any) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
selectedFeatures = features.filter((feature: any) => feature.get('context'));
|
selectedFeatures = features.filter((feature: any) => feature.get('context'));
|
||||||
|
vectorLayerFeatures = features.filter(
|
||||||
|
(feature: any) => !feature.get('context')
|
||||||
|
);
|
||||||
|
|
||||||
selectedFeatures.sort((f1: Feature, f2: Feature) => {
|
selectedFeatures.sort((f1: Feature, f2: Feature) => {
|
||||||
const ctx1 = f1.get('context');
|
const ctx1 = f1.get('context');
|
||||||
const ctx2 = f2.get('context');
|
const ctx2 = f2.get('context');
|
||||||
|
@ -93,6 +98,7 @@ export const clickHandler = (event: any) => {
|
||||||
event,
|
event,
|
||||||
features,
|
features,
|
||||||
hierarchy,
|
hierarchy,
|
||||||
|
vectorLayerFeatures,
|
||||||
});
|
});
|
||||||
selectedFeatures.map((feature: Feature<Geometry>) => {
|
selectedFeatures.map((feature: Feature<Geometry>) => {
|
||||||
const id = feature.get('id');
|
const id = feature.get('id');
|
||||||
|
@ -108,7 +114,7 @@ export const clickHandler = (event: any) => {
|
||||||
// length,
|
// length,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if (selectedFeatures.length > 0) {
|
if (selectedFeatures.length > 0 || vectorLayerFeatures.length > 0) {
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -118,7 +124,7 @@ const FeaturesTree: Component<{ featuresHierarchy: any }> = ({
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Tree
|
<Tree
|
||||||
title={featuresHierarchy.type || 'root'}
|
title={featuresHierarchy.type || 'voyages'}
|
||||||
content={undefined}
|
content={undefined}
|
||||||
subTree={Object.keys(featuresHierarchy)
|
subTree={Object.keys(featuresHierarchy)
|
||||||
.filter((key: string) => key.startsWith('gpx/'))
|
.filter((key: string) => key.startsWith('gpx/'))
|
||||||
|
@ -143,7 +149,50 @@ const Infos: Component<{}> = (props) => {
|
||||||
alignItems='center'
|
alignItems='center'
|
||||||
sx={{ width: 'calc(100% - 5px)' }}
|
sx={{ width: 'calc(100% - 5px)' }}
|
||||||
>
|
>
|
||||||
|
<Tree
|
||||||
|
title='everything'
|
||||||
|
content={undefined}
|
||||||
|
subTree={
|
||||||
|
<>
|
||||||
|
<Tree
|
||||||
|
title='osm'
|
||||||
|
content={undefined}
|
||||||
|
subTree={
|
||||||
|
<>
|
||||||
|
<For each={vectorLayerFeatures}>
|
||||||
|
{(feature) => (
|
||||||
|
<Tree
|
||||||
|
title={`${feature.get('class')} ${
|
||||||
|
feature.get('name') || ''
|
||||||
|
}`}
|
||||||
|
content={
|
||||||
|
<>
|
||||||
|
<>
|
||||||
|
{console.log({
|
||||||
|
caller: 'Infos / vector layer feature',
|
||||||
|
properties: feature.getProperties(),
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
<For each={Object.keys(feature.getProperties())}>
|
||||||
|
{(key: string) => (
|
||||||
|
<div>{`${key}: ${
|
||||||
|
feature.getProperties()[key]
|
||||||
|
}`}</div>
|
||||||
|
)}
|
||||||
|
</For>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
subTree={undefined}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</For>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
/>
|
||||||
<FeaturesTree featuresHierarchy={hierarchy} />
|
<FeaturesTree featuresHierarchy={hierarchy} />
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
|
|
|
@ -237,7 +237,7 @@ const Map: Component = () => {
|
||||||
|
|
||||||
const vectorTileSource1 = new VectorTileSource({
|
const vectorTileSource1 = new VectorTileSource({
|
||||||
format: new MVT(),
|
format: new MVT(),
|
||||||
url: 'http://localhost:8081/services/aragon/tiles/{z}/{x}/{y}.pbf',
|
url: 'https://geo.dyomedea.com/services/spain/tiles/{z}/{x}/{y}.pbf',
|
||||||
maxZoom: 14,
|
maxZoom: 14,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue