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
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ jobs:
with:
fetch-depth: 0
filter: tree:0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
Expand Down
5 changes: 0 additions & 5 deletions prebuild.cmd

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.40" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="9.0.40" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/OpenLayers.Blazor.Demo/OpenLayers.Blazor.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.2" />
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.40" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.40" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="9.0.40" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
19 changes: 16 additions & 3 deletions src/OpenLayers.Blazor/OpenLayers.Blazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<SourceLinkCreate>true</SourceLinkCreate>
<SourceLinkOriginUrl>https://github.com/lolochristen/OpenLayers.Blazor</SourceLinkOriginUrl>
</PropertyGroup>
<PrepareForBuildDependsOn>BundleMinify;$(PrepareForBuildDependsOn)</PrepareForBuildDependsOn>
</PropertyGroup>

<ItemGroup>
<ItemGroup>
<None Include="..\..\LICENSE" Link="LICENSE">
<Pack>True</Pack>
<PackagePath></PackagePath>
Expand Down Expand Up @@ -108,7 +109,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -117,4 +119,15 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('node_modules') ">
<!-- Ensure Node.js is installed -->
<Exec Command="node --version" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
<Exec WorkingDirectory="" Command="npm install" />
</Target>

</Project>
2 changes: 0 additions & 2 deletions src/OpenLayers.Blazor/Shape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,6 @@ public override Task SetParametersAsync(ParameterView parameters)
if (parameters.TryGetValue(nameof(Coordinates), out Coordinates? c) && c != Coordinates)
_coordinatesParametersChanged = true;

Console.WriteLine($"{_updateableParametersChanged} {_coordinatesParametersChanged} { string.Join(";", parameters.ToDictionary().Select(p => p.Key + "=" + p.Value)) }");

return base.SetParametersAsync(parameters);
}

Expand Down
17 changes: 17 additions & 0 deletions src/OpenLayers.Blazor/bundleconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Configure bundling and minification for the project.
// More info at https://go.microsoft.com/fwlink/?LinkId=808241
[
{
"outputFileName": "wwwroot/openlayers_interop.min.js",
"inputFiles": [
"wwwroot/openlayers_interop.js"
],
// Optionally specify minification options
"minify": {
"enabled": true,
"renameLocals": false
},
// Optinally generate .map file
"sourceMap": false
}
]
13 changes: 13 additions & 0 deletions src/OpenLayers.Blazor/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/OpenLayers.Blazor/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "openlayers.blazor",
"version": "1.0.0",
"private": true,
"devDependencies": {
}
}
47 changes: 21 additions & 26 deletions src/OpenLayers.Blazor/wwwroot/openlayers_interop.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,10 @@ MapOL.prototype.prepareLayers = function(layers) {
l = MapOL.transformNullToUndefined(l);

if (l.extent && this.Options.coordinatesProjection) {
let projection = that.Options.viewProjection ??
let projection = that.Options.viewProjection ? that.Options.viewProjection :
(ollayers.length > 0 ? ollayers[0].getSource().getProjection() : "EPSG:3857");
l.extent = ol.proj.transformExtent(l.extent,
l.source.projection ?? that.Options.coordinatesProjection,
l.source.projection ? l.source.projection : that.Options.coordinatesProjection,
projection);
}

Expand Down Expand Up @@ -415,11 +415,11 @@ MapOL.prototype.prepareLayers = function(layers) {
if (l.source.data) {
features = l.source.format.readFeatures(l.source.data,
{
featureProjection: this.Options.viewProjection ??
featureProjection: this.Options.viewProjection ? this.Options.viewProjection :
(ollayers.length > 0
? ollayers[0].getSource().getProjection()
: (that.Map ? that.Map.getView().getProjection() : "EPSG:3857")),
dataProjection: l.source.projection ?? this.Options.coordinatesProjection
dataProjection: l.source.projection ? l.source.projection : this.Options.coordinatesProjection
});
}
l.source = l.layerType == "VectorTile"
Expand Down Expand Up @@ -570,15 +570,19 @@ MapOL.prototype.addControls = function() {
if (this.Options.zoomToExtentControl) this.Map.addControl(new ol.control.ZoomToExtent());
};

MapOL.objectWithoutKey = function objectWithoutKey(object, key) {
const newObject = {};
for (let prop in object) {
if (prop !== key) {
newObject[prop] = object[prop];
}
}
return newObject;
}

MapOL.prototype.getReducedFeature = function(feature) {
const type = feature.getGeometry().getType();

const objectWithoutKey = (object, key) => {
const { [key]: deletedKey, ...otherKeys } = object;
return otherKeys;
};

const properties = objectWithoutKey(feature.getProperties(), "geometry");
const properties = MapOL.objectWithoutKey(feature.getProperties(), "geometry");

const reduced = {
type: "Feature",
Expand Down Expand Up @@ -872,7 +876,7 @@ MapOL.prototype.mapFeatureToShape = function(feature) {
if (feature == null) return null;

var geometry = feature.getGeometry();
var viewProjection = this.Map ? this.Map.getView().getProjection() : (this.Options.viewProjection ?? "EPSG:3857");
var viewProjection = this.Map ? this.Map.getView().getProjection() : (this.Options.viewProjection ? this.Options.viewProjection : "EPSG:3857");
var coordinates = null;

if (geometry != null && !Array.isArray(geometry)) {
Expand Down Expand Up @@ -909,11 +913,7 @@ MapOL.prototype.mapFeatureToShape = function(feature) {
id = id.toString();
}

var objectWithoutKey = (object, key) => {
const { [key]: deletedKey, ...otherKeys } = object;
return otherKeys;
};
var properties = objectWithoutKey(feature.getProperties(), "geometry");
var properties = MapOL.objectWithoutKey(feature.getProperties(), "geometry");

if (!properties.type) properties.type = "Shape";

Expand All @@ -935,7 +935,7 @@ MapOL.prototype.mapFeatureToShape = function(feature) {
MapOL.prototype.mapFeatureToInternalFeature = function (feature) {
if (feature == null) return null;

var viewProjection = this.Map ? this.Map.getView().getProjection() : (this.Options.viewProjection ?? "EPSG:3857");
var viewProjection = this.Map ? this.Map.getView().getProjection() : (this.Options.viewProjection ? this.Options.viewProjection : "EPSG:3857");
var coordinates = null;

var c = feature.getFlatCoordinates();
Expand All @@ -944,7 +944,7 @@ MapOL.prototype.mapFeatureToInternalFeature = function (feature) {
if (l < this.Options.serializationCoordinatesLimit)
coordinates = MapOL.transformCoordinates(c, viewProjection, this.Options.coordinatesProjection);

var id = feature.getId() ?? feature.getProperties().feature_id;
var id = feature.getId() ? feature.getId() : feature.getProperties().feature_id;
var properties = feature.getProperties();
properties.type = feature.getType();

Expand All @@ -963,7 +963,7 @@ MapOL.prototype.mapShapeToFeature = function(shape, source = null, transformCoor
if (shape.coordinates) {
const coordinates = transformCoordinates
? MapOL.transformCoordinates(shape.coordinates,
sourceProjection ?? this.Options.coordinatesProjection,
sourceProjection ? sourceProjection : this.Options.coordinatesProjection,
viewProjection)
: shape.coordinates;

Expand Down Expand Up @@ -1098,7 +1098,7 @@ MapOL.prototype.setCoordinates = function (layerId, featureId, coordinates) {
const viewProjection = this.Map.getView().getProjection();
const sourceProjection = this.getLayer(layerId).getSource().getProjection();
const coordinatesTransformed = MapOL.transformCoordinates(coordinates,
sourceProjection ?? this.Options.coordinatesProjection,
sourceProjection ? sourceProjection : this.Options.coordinatesProjection,
viewProjection);
if (geometry.getType() == "Circle")
geometry.setCenter(coordinatesTransformed);
Expand Down Expand Up @@ -1259,11 +1259,6 @@ MapOL.prototype.mapStylesToStyleOptions = function(style) {
width: text.getBackgroundStroke().getWidth(),
}
: undefined,
backgroundFill: text.getBackgroundFill()
? {
color: text.getBackgroundFill().getColor()
}
: undefined,
padding: text.getPadding(),
}
: undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/OpenLayers.Blazor/wwwroot/openlayers_interop.min.js

Large diffs are not rendered by default.

This file was deleted.

10 changes: 5 additions & 5 deletions test/OpenLayers.Blazor.Tests/OpenLayers.Blazor.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="bunit" Version="1.37.7" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<PackageReference Include="bunit" Version="1.38.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down