Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent returning all graphics for layer on hitTest. #296

Merged
merged 1 commit into from
Feb 3, 2024
Merged
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
24 changes: 13 additions & 11 deletions src/dymaptic.GeoBlazor.Core/Scripts/dotNetBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,13 @@ export function buildDotNetLayerView(layerView: LayerView): DotNetLayerView {
}
}

export function buildDotNetLayer(layer: Layer): DotNetLayer {
export function buildDotNetLayer(layer: Layer, includeGraphics: boolean = true)
: DotNetLayer {
switch (layer.type) {
case 'feature':
return buildDotNetFeatureLayer(layer as FeatureLayer);
case 'graphics':
return buildDotNetGraphicsLayer(layer as GraphicsLayer);
return buildDotNetGraphicsLayer(layer as GraphicsLayer, includeGraphics);
default:

let dotNetLayer = {
Expand All @@ -408,7 +409,8 @@ export function buildDotNetLayer(layer: Layer): DotNetLayer {
}
}

export function buildDotNetFeatureLayer(layer: FeatureLayer): DotNetFeatureLayer {
export function buildDotNetFeatureLayer(layer: FeatureLayer)
: DotNetFeatureLayer {

let dotNetLayer = {
title: layer.title,
Expand Down Expand Up @@ -520,7 +522,8 @@ export function buildDotNetRangeDomain(domain: RangeDomain): DotNetRangeDomain {
} as DotNetRangeDomain;
}

export function buildDotNetGraphicsLayer(layer: GraphicsLayer): DotNetGraphicsLayer {
export function buildDotNetGraphicsLayer(layer: GraphicsLayer, includeGraphics: boolean = true)
: DotNetGraphicsLayer {
let dotNetLayer = {
title: layer.title,
type: layer.type,
Expand All @@ -533,7 +536,7 @@ export function buildDotNetGraphicsLayer(layer: GraphicsLayer): DotNetGraphicsLa
dotNetLayer.fullExtent = buildDotNetExtent(layer.fullExtent) as DotNetExtent;
}

if (layer.graphics !== undefined && layer.graphics !== null) {
if (includeGraphics && layer.graphics !== undefined && layer.graphics !== null) {
dotNetLayer.graphics = (layer.graphics as MapCollection).items.map(g => buildDotNetGraphic(g));
}

Expand Down Expand Up @@ -564,10 +567,9 @@ function buildDotNetViewHit(viewHit: ViewHit): DotNetViewHit | null {
return {
type: "graphic",
graphic: buildDotNetGraphic(viewHit.graphic),
layer: buildDotNetLayer(viewHit.layer ?? viewHit.graphic.layer),
layer: buildDotNetLayer(viewHit.layer ?? viewHit.graphic.layer, false),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting false on buildDotNetLayer will limit the return to just the graphic layer. true would enable the complete layer and all graphics to be returned

mapPoint: buildDotNetPoint(viewHit.mapPoint)
} as DotNetGraphicHit;
break;
}

return null;
Expand Down Expand Up @@ -933,13 +935,13 @@ export function buildDotNetGoToOverrideParameters(parameters: any, viewId: strin
let firstObject = parameters.target.target[0];
if (firstObject instanceof Graphic) {
target.targetGraphics = [];
for (let g: Graphic in parameters.target.target as Graphic[]) {
target.targetGraphics.push(buildDotNetGraphic(g));
for (let g in parameters.target.target as Graphic[]) {
target.targetGraphics.push(buildDotNetGraphic(g as any));
}
} else if (firstObject instanceof Geometry) {
target.targetGeometries = [];
for (let g: Geometry in parameters.target.target as Geometry[]) {
target.targetGeometries.push(buildDotNetGeometry(g));
for (let g in parameters.target.target as Geometry[]) {
target.targetGeometries.push(buildDotNetGeometry(g as any));
}
} else {
target.targetCoordinates = parameters.target.target;
Expand Down
Loading