Skip to content
Merged
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
22 changes: 18 additions & 4 deletions packages/base/src/mainview/mainView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ import {
} from 'ol/source';
import Static from 'ol/source/ImageStatic';
import { TileSourceEvent } from 'ol/source/Tile';
import { Circle, Fill, Stroke, Style } from 'ol/style';
import { Circle, Fill, Icon, Stroke, Style } from 'ol/style';
import { Rule } from 'ol/style/flat';
//@ts-expect-error no types for ol-pmtiles
import { PMTilesRasterSource, PMTilesVectorSource } from 'ol-pmtiles';
Expand All @@ -102,6 +102,7 @@ import CollaboratorPointers, { ClientPointer } from './CollaboratorPointers';
import { FollowIndicator } from './FollowIndicator';
import TemporalSlider from './TemporalSlider';
import { MainViewModel } from './mainviewmodel';
import { markerIcon } from '../icons';
import { LeftPanel, RightPanel } from '../panelview';

type OlLayerTypes =
Expand Down Expand Up @@ -837,6 +838,19 @@ export class MainView extends React.Component<IProps, IStates> {
geometry: point,
});

// Replace color placeholder in SVG with the parameter color
const markerColor = parameters.color || '#3463a0';
const svgString = markerIcon.svgstr.replace('{{COLOR}}', markerColor);

const iconStyle = new Style({
image: new Icon({
src: `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svgString)}`,
scale: 0.25,
}),
});

marker.setStyle(iconStyle);

newSource = new VectorSource({
features: [marker],
});
Expand Down Expand Up @@ -2098,7 +2112,7 @@ export class MainView extends React.Component<IProps, IStates> {
this._model.syncPointer(pointer);
});

private _addMarker(e: MapBrowserEvent<any>) {
private async _addMarker(e: MapBrowserEvent<any>) {
if (this._model.currentMode !== 'marking') {
return;
}
Expand Down Expand Up @@ -2130,11 +2144,11 @@ export class MainView extends React.Component<IProps, IStates> {
parameters: layerParams,
};

this.addSource(sourceId, sourceModel);
this._model.sharedModel.addSource(sourceId, sourceModel);
await this.addSource(sourceId, sourceModel);

this.addLayer(layerId, layerModel, this.getLayerIDs().length);
this._model.addLayer(layerId, layerModel);
await this.addLayer(layerId, layerModel, this.getLayerIDs().length);
}

private _identifyFeature(e: MapBrowserEvent<any>) {
Expand Down
3 changes: 2 additions & 1 deletion packages/base/style/icons/marker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/schema/src/schema/project/sources/markerSource.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"required": ["feature"],
"additionalProperties": false,
"properties": {
"color": {
"type": "string",
"description": "Color of the marker icon (hex, rgb, rgba, or named color)"
},
"feature": {
"type": "object",
"description": "Info for the marker",
Expand Down
Loading