Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

UI fix for marker radius changing in size while zooming (#2464)

Martin Peeters8c3b0a6643c5
diff --git a/ui/app/storybook/docs/components/or-map.mdx b/ui/app/storybook/docs/components/or-map.mdx
new file mode 100644
index 000000000..ad86c5ab1
--- /dev/null
+++ b/ui/app/storybook/docs/components/or-map.mdx
@@ -0,0 +1,7 @@
+import { Meta } from '@storybook/addon-docs/blocks';
+import * as ComponentStory from "../../../../component/or-map/stories/map.stories"; // stories need relative imports
+import {ComponentDocs} from "../../util/componentdocs.mdx";
+
+<Meta title="Components/Map" />
+
+<ComponentDocs story={ComponentStory} options={{displayName: "Map"}} elementsjson={ComponentStory.customElements} />
diff --git a/ui/component/or-map/package.json b/ui/component/or-map/package.json
index b64184bc5..9ecaecf7e 100644
--- a/ui/component/or-map/package.json
+++ b/ui/component/or-map/package.json
@@ -20,6 +20,7 @@
"prepack": "npx rspack"
},
"author": "OpenRemote",
+ "repository": "https://github.com/openremote/openremote",
"license": "AGPL-3.0-or-later",
"dependencies": {
"@maplibre/maplibre-gl-geocoder": "^1.5.0",
diff --git a/ui/component/or-map/src/mapwidget.ts b/ui/component/or-map/src/mapwidget.ts
index af7828af4..8e09fd078 100644
--- a/ui/component/or-map/src/mapwidget.ts
+++ b/ui/component/or-map/src/mapwidget.ts
@@ -959,9 +959,7 @@ export class MapWidget {
"type": "Point",
"coordinates": [marker.lng, marker.lat]
},
- properties: {
- "title": "You Found Me",
- }
+ properties: {}
}]
}
});
@@ -972,14 +970,15 @@ export class MapWidget {
"source": "circleData",
"paint": {
"circle-radius": [
- "interpolate",
- ["linear"],
- ["zoom"],
+ "interpolate",
+ ["exponential", 2],
+ ["zoom"],
0, 0,
20, metersToPixelsAtMaxZoom(marker.radius, marker.lat)
],
"circle-color": "red",
- "circle-opacity": 0.3
+ "circle-opacity": 0.3,
+ "circle-pitch-alignment": "map" // Keeps the circle flat against the map surface
}
});
}
diff --git a/ui/component/or-map/stories/map.stories.ts b/ui/component/or-map/stories/map.stories.ts
new file mode 100644
index 000000000..d91e52034
--- /dev/null
+++ b/ui/component/or-map/stories/map.stories.ts
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2025, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+import {type Meta, setCustomElementsManifest, type StoryObj} from "@storybook/web-components";
+import {getStorybookHelpers} from "@wc-toolkit/storybook-helpers";;
+import manager from "@openremote/core";
+import {html} from "lit";
+import customElements from "../custom-elements.json" with {type: "json"};
+import packageJson from "../package.json" with {type: "json"};
+import "../src/index";
+import "../src/markers/or-map-marker";
+
+const tagName = "or-map";
+type Story = StoryObj;
+setCustomElementsManifest(customElements);
+
+const { events, args, argTypes, template } = getStorybookHelpers(tagName);
+
+const meta: Meta = {
+ title: "Playground/or-map",
+ component: tagName,
+ args: args,
+ argTypes: argTypes,
+ render: storyArgs => template(storyArgs),
+ excludeStories: /^[a-z].*/,
+ parameters: {
+ actions: {
+ handles: events
+ },
+ docs: {
+ subtitle: `<${tagName}>`,
+ description: "Map is a component for displaying geographical maps, with support for custom layers."
+ }
+ }
+};
+
+const parameters = {
+ docs: {
+ story: {
+ height: "360px"
+ }
+ }
+};
+
+const loaders = [
+ async storyArgs => ({
+ orManager: await loadOrManager()
+ })
+];
+
+export const Primary: Story = {
+ loaders,
+ parameters,
+ render: (args) => template(args, html`
+ <or-map-marker colour="#FF0000" icon="information" lat="51.915767" lng="4.483118" title="Marker"></or-map-marker>
+ `)
+};
+
+export const WithRadius: Story = {
+ loaders,
+ name: "Radius example",
+ parameters: {
+ ...parameters,
+ title: "Applying a marker radius",
+ summary: "Using the `radius` HTML attribute, you can surround your marker with a circle. For example a radius of 100 meters:",
+ },
+ render: (args) => template(args, html`
+ <or-map-marker colour="#FF0000" icon="information" lat="51.915767" lng="4.483118" radius="100" title="Radius"></or-map-marker>
+ `)
+};
+
+export const examples = [WithRadius];
+
+export {customElements, packageJson};
+
+/* ------------------------------------------------------- */
+/* UTILITY FUNCTIONS */
+/* ------------------------------------------------------- */
+
+async function loadOrManager() {
+ if(await manager.init({ managerUrl: "http://localhost:8080", realm: "smartcity" })) {
+ if(!manager.authenticated) {
+ manager.login();
+ }
+ return manager;
+ }
+ throw new Error("Manager could not be initialized");
+}
+
+export default meta;
diff --git a/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts b/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts
index 369363d1e..3d28a2359 100644
--- a/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts
+++ b/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts
@@ -745,7 +745,7 @@ export class OrRuleAssetQuery extends translate(i18next)(LitElement) {
negated: value === AssetQueryOperator.OUTSIDE_RADIUS,
lat: 0,
lng: 0,
- radius: 50
+ radius: 100
};
break;
case AssetQueryOperator.WITHIN_RECTANGLE: