Skip to content

Commit 751f71b

Browse files
committed
feat: Map Projection in Advanced Options "needs enhancement"
1 parent a106534 commit 751f71b

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/GEOComp.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ var GEOComp = (function () {
141141
maxZoom:30,
142142
menuTitle: "Menu",
143143
menuContent: "No Content",
144+
projection: "EPSG:3857",
144145
buttons: {
145146
draw: true
146147
},

src/vendors/Geo.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function Geo(props) {
122122
const validatedLayers = layers.filter(layer => layer !== null && layer !== undefined);
123123
const sortedLayers = validatedLayers
124124
.sort((a, b) => (a.order || 0) - (b.order || 0))
125-
.map(createLayer)
125+
.map(layerConfig => createLayer(layerConfig, map))
126126
.filter(layer => layer !== null && layer !== undefined);
127127
map.getLayers().clear();
128128
sortedLayers.forEach(layer => { if (layer) map.addLayer(layer) });
@@ -152,7 +152,8 @@ function Geo(props) {
152152
center: fromLonLat((props.center.length == 2 ? props.center : props.defaults.center) || geoLoc || [0, 0]),
153153
zoom: props.zoom || props.defaults.zoom,
154154
maxZoom: props.maxZoom || props.defaults.maxZoom || 100,
155-
rotation: props.rotation || props.defaults.rotation
155+
rotation: props.rotation || props.defaults.rotation,
156+
projection: props.defaults.projection || 'EPSG:3857'
156157
}),
157158
target: 'GEO_' + geoId,
158159
layers: [],

src/vendors/helpers/Layers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { geoJsonStyleFunction } from './Styles'
1717
import { applyBackground, applyStyle } from 'ol-mapbox-style';
1818
import { createXYZ } from 'ol/tilegrid.js';
1919

20-
export function createLayer(layerConfig) {
20+
export function createLayer(layerConfig, map) {
2121
if (!layerConfig || !layerConfig.type) {
2222
console.warn("Skipping layer due to missing type or configuration:", layerConfig);
2323
return null;
@@ -90,7 +90,7 @@ export function createLayer(layerConfig) {
9090
features: new GeoJSON().readFeatures(layerConfig.source.data, {
9191
// Ensure the features are read with the correct projection
9292
dataProjection: layerConfig.source.projection || 'EPSG:4326', // Assuming the GeoJSON is in WGS 84
93-
featureProjection: 'EPSG:3857' // Assuming the map projection
93+
featureProjection: map.getView().getProjection() || 'EPSG:3857' // Assuming the map projection
9494
}),
9595
}),
9696
// Add this line to apply a generic style to the layer
@@ -132,7 +132,7 @@ export function createLayer(layerConfig) {
132132
opacity: layerConfig.opacity,
133133
selectable: layerConfig.selectable,
134134
source: new VectorTileSource({
135-
projection: layerConfig.source?.projection,
135+
projection: layerConfig.source?.projection || 'EPSG:3857',
136136
}),
137137
style: layerConfig.source.style,
138138
});

0 commit comments

Comments
 (0)