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
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@ public ObjectNode getSettings(RequestParams requestParams) {
);
}

@Override
public ObjectNode getSettingsJs(RequestParams requestParams) {
return mapService.getMapSettingsJs(
getAuthenticatedRealmName(),
requestParams.getExternalSchemeHostAndPort()
);
}

@Override
public Response getTile(int zoom, int column, int row) {
byte[] tile = mapService.getMapTile(zoom, column, row);
Expand Down
31 changes: 1 addition & 30 deletions manager/src/main/java/org/openremote/manager/map/MapService.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public void stop(Container container) throws Exception {
}

/**
* Dynamically build Mapbox GL settings based on mapsettings.json
* Dynamically build MapLibre GL settings based on mapsettings.json
*/
public ObjectNode getMapSettings(String realm, URI host) {
String realmUriKey = realm + host.toString();
Expand Down Expand Up @@ -469,35 +469,6 @@ public ObjectNode getMapSettings(String realm, URI host) {
return settings;
}

/**
* Dynamically build Mapbox JS settings based on mapsettings.json
*/
public ObjectNode getMapSettingsJs(String realm, URI host) {
String realmUriKey = realm + host.toString();
if (mapSettingsJs.containsKey(realmUriKey)) {
return mapSettingsJs.get(realmUriKey);
}

final ObjectNode settings = mapSettingsJs.computeIfAbsent(realmUriKey, r -> ValueUtil.JSON.createObjectNode());

if (!metadata.isValid() || mapConfig.isEmpty()) {
return settings;
}

ArrayNode tilesArray = ValueUtil.JSON.createArrayNode();
String tileUrl = UriBuilder.fromUri(host).replacePath(RASTER_MAP_TILE_PATH).build().toString() + "/{z}/{x}/{y}.png";
tilesArray.insert(0, tileUrl);

settings.replace("options", mapConfig.has("options") && mapConfig.get("options").isObject() ? (ObjectNode)mapConfig.get("options") : null);

settings.put("attribution", metadata.attribution);
settings.put("format", "png");
settings.put("type", "baselayer");
settings.replace("tiles", tilesArray);

return settings;
}

public byte[] getMapTile(int zoom, int column, int row) {
// Flip y, oh why
row = Double.valueOf(Math.pow(2, zoom) - 1 - row).intValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public class ManagerConfig {
protected Auth auth;
protected UsernamePassword credentials;
protected EventProviderType eventProviderType;
protected MapType mapType;
protected Object configureTranslationsOptions;
protected Object basicLoginProvider;
protected String defaultLanguage;
Expand Down
24 changes: 0 additions & 24 deletions model/src/main/java/org/openremote/model/manager/MapType.java

This file was deleted.

16 changes: 3 additions & 13 deletions model/src/main/java/org/openremote/model/map/MapResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,16 @@ public interface MapResource {
ObjectNode saveSettings(@BeanParam RequestParams requestParams, MapConfig mapConfig);

/**
* Returns style used to initialise Mapbox GL
* Returns style used to initialise MapLibre GL
* @return
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Operation(operationId = "getSettings", summary = "Retrieve the style used for Mapbox GL")
@Operation(operationId = "getSettings", summary = "Retrieve the style used for MapLibre GL")
ObjectNode getSettings(@BeanParam RequestParams requestParams);

/**
* Returns tileJSON object used to initialise Mapbox JS
* @return
*/
@GET
@Path("js")
@Produces(MediaType.APPLICATION_JSON)
@Operation(operationId = "getSettingsJs", summary = "Retrieve the tileJSON object used for Mapbox GL")
ObjectNode getSettingsJs(@BeanParam RequestParams requestParams);

/**
* Gets vector tile data for Mapbox GL
* Gets vector tile data for MapLibre GL
*/
@GET
@Produces("application/vnd.mapbox-vector-tile")
Expand Down
4 changes: 2 additions & 2 deletions ui/app/storybook/rsbuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ export default defineConfig({
},
tools: {
bundlerChain: (chain, { CHAIN_ID }) => {
chain.module.rule(CHAIN_ID.RULE.CSS).exclude.add(/(maplibre|mapbox|@material|gridstack|@mdi).*\.css$/); // Exclude the external CSS imports from default bundling.
chain.module.rule(CHAIN_ID.RULE.CSS).exclude.add(/(maplibre|@material|gridstack|@mdi).*\.css$/); // Exclude the external CSS imports from default bundling.
},
rspack: (config, { addRules }) => {
addRules([{test: /(maplibre|mapbox|@material|gridstack|@mdi).*\.css$/, type: "asset/source"}]); // Add rule to treat external CSS imports as raw strings.
addRules([{test: /(maplibre|@material|gridstack|@mdi).*\.css$/, type: "asset/source"}]); // Add rule to treat external CSS imports as raw strings.
return config;
}
}
Expand Down
5 changes: 0 additions & 5 deletions ui/component/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
ConsoleAppConfig,
EventProviderType,
ManagerConfig,
MapType,
Role,
User,
UsernamePassword
Expand Down Expand Up @@ -271,10 +270,6 @@ export class Manager implements EventProviderFactory {
return this.events;
}

get mapType() {
return this._config.mapType || MapType.VECTOR;
}

protected static MAX_RECONNECT_DELAY = 45000;
private _error?: ORError;
private _config!: ManagerConfig;
Expand Down
14 changes: 4 additions & 10 deletions ui/component/or-map/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Linux Build][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]

Web Component for displaying a Mapbox map; either raster or vector (default). This component requires an OpenRemote
Web Component for displaying a MapLibre map; either raster or vector (default). This component requires an OpenRemote
Manager to retrieve map settings and tiles.
Comment thread
Ekhorn marked this conversation as resolved.
Resolved

## Install
Expand All @@ -19,30 +19,24 @@ For a full list of properties, methods and options refer to the TypeDoc generate
<or-map center="5.454250, 51.445990" zoom="5" style="height: 500px; width: 100%;" />
```

For a raster map (raster tile serving in the OpenRemote Manager must be properly configured):

```$html
<or-map type="RASTER" center="5.454250, 51.445990" zoom="5" style="height: 500px; width: 100%;" />
```

The center and zoom are optional overrides for the defaults that will be defined in the `mapsettings` loaded from the
OpenRemote Manager; each realm can have different `mapsettings` with a fallback to the default.

Markers can be added via markup as children:

```$html
<or-map id="vectorMap" center="5.454250, 51.445990" zoom="5" style="height: 500px; width: 100%;">
<or-map id="map" center="5.454250, 51.445990" zoom="5" style="height: 500px; width: 100%;">
<or-map-marker id="demo-marker" lng="5.454250" class="marker" icon="or:logo-plain"></or-map-marker>
</or-map>
```

Or programmatically:

```$typescript
const vectorMap = docuemnt.getElementById("vectorMap");
const map = document.getElementById("map");
const assetMarker = document.createElement("or-map-marker-asset");
assetMarker.setAttribute("asset", apartment1.id!);
vectorMap.appendChild(assetMarker);
map.appendChild(assetMarker);
```

There are two types of built in markers:
Expand Down
4 changes: 1 addition & 3 deletions ui/component/or-map/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@
"lit": "^3.3.1",
"lit-html": "^3.3.1",
"lodash.debounce": "^4.0.8",
"mapbox.js": "^3.3.1",
"maplibre-gl": "^5.12.0"
},
"devDependencies": {
"@types/geojson": "^7946.0.7",
"@types/lodash.debounce": "^4",
"@types/mapbox": "^1.6.42"
"@types/lodash.debounce": "^4"
},
"publishConfig": {
"access": "public"
Expand Down
1 change: 0 additions & 1 deletion ui/component/or-map/rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ bundles = {
"index": {
vendor: {
"maplibre-gl": "maplibre",
"mapbox.js": "L.mapbox",
"moment": "moment"
},
excludeOr: true
Expand Down
7 changes: 2 additions & 5 deletions ui/component/or-map/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {OrMwcDialog, showDialog} from "@openremote/or-mwc-components/or-mwc-dial
import {getMarkerIconAndColorFromAssetType} from "./util";
import {i18next} from "@openremote/or-translate";
import debounce from "lodash.debounce";
import { Asset, Attribute, GeoJsonConfig, GeoJSONPoint, MapType, WellknownAttributes } from "@openremote/model";
import { Asset, Attribute, GeoJsonConfig, GeoJSONPoint, WellknownAttributes } from "@openremote/model";
import { CoordinatesControl, CoordinatesRegexPattern, getCoordinatesInputKeyHandler } from "./controls/coordinates";
import { CenterControl } from "./controls/center";

Expand Down Expand Up @@ -307,9 +307,6 @@ export class OrMap extends LitElement {

public static styles = style;

@property({type: String})
public type: MapType = manager.mapType;

@property({type: Object})
public cluster?: ClusterConfig;

Expand Down Expand Up @@ -452,7 +449,7 @@ export class OrMap extends LitElement {
}

if (this._mapContainer && this._slotElement) {
this._map = new MapWidget(this.type, this.shadowRoot!, this._mapContainer, this.showGeoCodingControl, this.showBoundaryBoxControl, this.useZoomControl, this.showGeoJson, this.cluster)
this._map = new MapWidget(this.shadowRoot!, this._mapContainer, this.showGeoCodingControl, this.showBoundaryBoxControl, this.useZoomControl, this.showGeoJson, this.cluster)
.setCenter(this.center)
.setZoom(this.zoom)
.setControls(this.controls)
Expand Down
Loading
Loading