Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
8 changes: 4 additions & 4 deletions examples/earthquakes.jGIS
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@
"options": {
"bearing": 0.0,
"extent": [
-18039043.293897964,
-4847443.5412946865,
1383665.5829297584,
13318211.842235815
-19456309.48732131,
-3639686.263420881,
2800931.776353102,
12110454.564362008
],
"latitude": 35.52446437432016,
"longitude": -74.80890180273175,
Expand Down
10 changes: 7 additions & 3 deletions packages/base/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export function addCommands(
'VectorLayer',
'ShapefileLayer',
'WebGlLayer',
'VectorTileLayer',
].includes(selectedLayer.type);
const isIdentifying = current.model.isIdentifying;

Expand All @@ -174,9 +175,12 @@ export function addCommands(
if (!selectedLayer) {
return false;
}
return ['VectorLayer', 'ShapefileLayer', 'WebGlLayer'].includes(
selectedLayer.type,
);
return [
'VectorLayer',
'ShapefileLayer',
'WebGlLayer',
'VectorTileLayer',
].includes(selectedLayer.type);
},
execute: args => {
const current = tracker.currentWidget;
Expand Down
49 changes: 47 additions & 2 deletions packages/base/src/mainview/mainView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import {
transformExtent,
} from 'ol/proj';
import { register } from 'ol/proj/proj4.js';
import RenderFeature from 'ol/render/Feature';
import RenderFeature, { toGeometry } from 'ol/render/Feature';
import {
GeoTIFF as GeoTIFFSource,
ImageTile as ImageTileSource,
Expand Down Expand Up @@ -650,7 +650,10 @@ export class MainView extends React.Component<IProps, IStates> {
const features = tile.getFeatures();

if (features && features.length > 0) {
this._model.syncTileFeatures({ sourceId: id, features });
this._model.syncTileFeatures({
sourceId: id,
features,
});
}
});

Expand Down Expand Up @@ -2101,6 +2104,48 @@ export class MainView extends React.Component<IProps, IStates> {
const jgisLayer = this._model.getLayer(layerId);

switch (jgisLayer?.type) {
case 'VectorTileLayer': {
const geometries: Geometry[] = [];
const features: any[] = [];

this._Map.forEachFeatureAtPixel(e.pixel, (feature: FeatureLike) => {
let geom: Geometry | undefined = undefined;

if (feature instanceof RenderFeature) {
geom = toGeometry(feature);
} else {
geom = feature.getGeometry ? feature.getGeometry() : undefined;
}

const props = feature.getProperties();

if (geom) {
geometries.push(geom);
}
features.push({
...props,
});

return true;
});

if (features.length > 0) {
this._model.syncIdentifiedFeatures(features, this._mainViewModel.id);
}

if (geometries.length > 0) {
for (const geom of geometries) {
this._model.highlightFeatureSignal.emit(geom);
}
} else {
const coordinate = this._Map.getCoordinateFromPixel(e.pixel);
const point = new Point(coordinate);
this._model.highlightFeatureSignal.emit(point);
}

break;
}

case 'WebGlLayer': {
const layer = this.getLayer(layerId) as WebGlTileLayer;
const data = layer.getData(e.pixel);
Expand Down
Loading