Skip to content

Commit e442566

Browse files
committed
fix: selectable layer assigned and cursor Style
1 parent f4fba49 commit e442566

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/i18n/comps/locales/enObj.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const enObj: I18nObjects = {
99
"minZoom": 0,
1010
"maxZoom": 22,
1111
"visible": true,
12+
"selectable": true,
1213
"source": {
1314
"peojection": "EPSG:4326",
1415
"data": {
@@ -282,6 +283,7 @@ export const enObj: I18nObjects = {
282283
maxZoom: 22,
283284
visible: true,
284285
opacity: 1,
286+
selectable: false,
285287
source: {
286288
url: "https://wms.wheregroup.com/tileserver/style/osm-bright.json",
287289
projection: "EPSG:3857",

src/vendors/Geo.jsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,12 +554,25 @@ function Geo(props) {
554554

555555
// Optional: pointer move logic for changing cursor over WMS layers
556556
olMap.on('pointermove', function (evt) {
557-
if (evt.dragging) return;
557+
if (evt.dragging) return; // skip if the map is being dragged
558+
559+
var cursorStyle = 'default'; // Default cursor style
558560
const pixel = olMap.getEventPixel(evt.originalEvent);
559-
const hit = olMap.hasFeatureAtPixel(pixel);
560-
olMap.getTargetElement().style.cursor = hit ? 'pointer' : '';
561+
562+
// Check for features at the current pointer position
563+
olMap.forEachFeatureAtPixel(pixel, function (feature, layer) {
564+
// If a layer is found and its selectable property is not false
565+
if (layer && layer.get('selectable') !== false) {
566+
cursorStyle = 'pointer'; // Change the cursor to pointer
567+
return true; // Stop iterating through the features
568+
}
569+
});
570+
571+
// Apply the determined cursor style to the map target element
572+
olMap.getTargetElement().style.cursor = cursorStyle;
561573
});
562574

575+
563576
//Handle the loaded event
564577
olMap.on('loadend', function (event) {
565578
fireEvent('map:loaded', event)

src/vendors/helpers/Layers.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export function createLayer(layerConfig) {
3131
maxZoom: layerConfig.maxZoom,
3232
visible: layerConfig.visible,
3333
opacity: layerConfig.opacity,
34+
selectable: layerConfig.selectable,
3435
source: new VectorTileSource({
3536
attributions: layerConfig.attributions,
3637
format: new MVT(),
@@ -44,6 +45,7 @@ export function createLayer(layerConfig) {
4445
maxZoom: layerConfig.maxZoom,
4546
visible: layerConfig.visible,
4647
opacity: layerConfig.opacity,
48+
selectable: layerConfig.selectable,
4749
source: new TileWMS({
4850
url: layerConfig.source.url,
4951
params: layerConfig.source.params,
@@ -58,6 +60,7 @@ export function createLayer(layerConfig) {
5860
maxZoom: layerConfig.maxZoom,
5961
visible: layerConfig.visible,
6062
opacity: layerConfig.opacity,
63+
selectable: layerConfig.selectable,
6164
source: new VectorSource({
6265
format: new GeoJSON(),
6366
url: layerConfig.source.url,
@@ -70,6 +73,7 @@ export function createLayer(layerConfig) {
7073
maxZoom: layerConfig.maxZoom,
7174
visible: layerConfig.visible,
7275
opacity: layerConfig.opacity,
76+
selectable: layerConfig.selectable,
7377
source: new XYZ({
7478
url: layerConfig.source.url,
7579
}),
@@ -81,6 +85,7 @@ export function createLayer(layerConfig) {
8185
maxZoom: layerConfig.maxZoom,
8286
visible: layerConfig.visible,
8387
opacity: layerConfig.opacity,
88+
selectable: layerConfig.selectable,
8489
source: new VectorSource({
8590
features: new GeoJSON().readFeatures(layerConfig.source.data, {
8691
// Ensure the features are read with the correct projection
@@ -99,6 +104,7 @@ export function createLayer(layerConfig) {
99104
maxZoom: layerConfig.maxZoom,
100105
visible: layerConfig.visible,
101106
opacity: layerConfig.opacity,
107+
selectable: layerConfig.selectable,
102108
source: new GeoTIFF({
103109
sources: [
104110
{
@@ -124,6 +130,7 @@ export function createLayer(layerConfig) {
124130
maxZoom: layerConfig.maxZoom,
125131
visible: layerConfig.visible,
126132
opacity: layerConfig.opacity,
133+
selectable: layerConfig.selectable,
127134
source: new VectorTileSource({
128135
projection: layerConfig.source?.projection,
129136
}),

0 commit comments

Comments
 (0)