Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add switch for showing border and fixed not refreshing autocenter when new query results come in #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dashboards/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"shape": "circle",
"showLegend": true,
"showPin": true,
"showBorder": false,
"size": {
"field": "availablespotnumber",
"fixed": 1,
Expand Down
1 change: 1 addition & 0 deletions dashboards/timescaledb-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@
"shape": "circle",
"showLegend": true,
"showPin": true,
"showBorder": false,
"size": {
"fixed": 1,
"max": 15,
Expand Down
18 changes: 18 additions & 0 deletions src/GeomapPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { getGlobalStyles } from './globalStyles';
import { GeomapHoverFeature, GeomapHoverPayload } from './event';
import { DataHoverView } from './components/DataHoverView';
import { ExtendMapLayerOptions } from './extension';
import LayerGroup from 'ol/layer/Group';

interface MapLayerState {
config: ExtendMapLayerOptions;
Expand Down Expand Up @@ -165,6 +166,23 @@ export class GeomapPanel extends Component<Props, State> {
}
}
}
if (layer instanceof LayerGroup) {
const groupLayers = layer.getLayersArray();
for (let l of groupLayers) {
if (l instanceof VectorLayer) {
let source = l.getSource();
if (source !== undefined && source instanceof Vector) {
let features = source.getFeatures();
for (let feature of features) {
let geo = feature.getGeometry();
if (geo) {
extend(extent, geo.getExtent());
}
}
}
}
}
}
}
if (!isEqual(extent, createEmpty())) {
this.map.getView().fit(extent);
Expand Down
29 changes: 23 additions & 6 deletions src/layers/data/markersLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface MarkersConfig {
shape?: string;
showLegend?: boolean;
showPin?: boolean;
showBorder?: boolean;
iconSize?: number;
enableGradient?: boolean;
enableShadow?: boolean;
Expand Down Expand Up @@ -79,6 +80,7 @@ const defaultOptions: MarkersConfig = {
shape: 'circle',
showLegend: true,
showPin: false,
showBorder: false,
enableGradient: false,
enableShadow: false,
pinShape: 'marker',
Expand Down Expand Up @@ -355,6 +357,7 @@ export const markersLayer: ExtendMapLayerRegistryItem<MarkersConfig> = {

const showPin = options.config?.showPin ?? defaultOptions.showPin;
const cluster = options.config?.cluster ?? defaultOptions.cluster;
const showBorder = options.config?.showBorder ?? defaultOptions.showBorder;

for (const frame of data.series) {
if ((options.query && options.query.options === frame.refId) || (frame.meta)) {
Expand Down Expand Up @@ -383,16 +386,24 @@ export const markersLayer: ExtendMapLayerRegistryItem<MarkersConfig> = {
if (geoType === 'Point') {
geometry.setStyle(shape!.make(color, fillColor, radius));
} else {
const strokeSize = getScaledDimension(frame, config.geoJsonStrokeSize);
let style = new Style({
stroke: new Stroke({
color: color,
width: strokeSize.get(i),
}),
fill: new Fill({
color: fillColor,
}),
})
});
if (showBorder)
{
const strokeSize = getScaledDimension(frame, config.geoJsonStrokeSize);
style = new Style({
stroke: new Stroke({
color: color,
width: strokeSize.get(i),
}),
fill: new Fill({
color: fillColor,
})
});
}
geometry.setStyle(style);
}
geometryFeatures.push(geometry);
Expand Down Expand Up @@ -515,6 +526,12 @@ export const markersLayer: ExtendMapLayerRegistryItem<MarkersConfig> = {
description: 'Show pin',
defaultValue: defaultOptions.showPin,
})
.addBooleanSwitch({
path: 'config.showBorder',
name: 'Show border',
description: 'Show border',
defaultValue: defaultOptions.showBorder,
})
.addSelect({
path: 'config.pinShape',
name: 'Pin Shape',
Expand Down