-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Mileposts located by click now show connecting line (#488)
* feat: Mileposts located by click now show connecting line * refactor: Add click / SRMP line offset CIM renderer * refactor: ♻️ move milepost-point-layer to own folder
- Loading branch information
1 parent
7b0d914
commit b07437f
Showing
10 changed files
with
248 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
src/layers/MilepostLayer/milepost-line-layer/MilepostOffsetLineRenderer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import MilepostLocationRenderer from "./Milepost Location Renderer.json"; | ||
import SimpleRenderer from "@arcgis/core/renderers/SimpleRenderer"; | ||
|
||
/** | ||
* Simple Renderer using a CIM symbol. | ||
*/ | ||
export default SimpleRenderer.fromJSON(MilepostLocationRenderer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import FeatureLayer from "@arcgis/core/layers/FeatureLayer"; | ||
import { createPopupTemplate, fields } from ".."; | ||
import waExtent from "../../../WAExtent"; | ||
import { objectIdFieldName } from "../../../elc/types"; | ||
import MilepostOffsetLineRenderer from "./MilepostOffsetLineRenderer"; | ||
|
||
/** | ||
* Creates a new feature layer that displays mileposts as lines. | ||
* @param spatialReference - The spatial reference of the layer. | ||
* @returns A new feature layer that displays mileposts as lines. | ||
*/ | ||
export function createMilepostLineLayer( | ||
spatialReference = waExtent.spatialReference, | ||
) { | ||
// Make a clone of the milepost point layer, as most of the properties | ||
// will be the same aside from the geometry type and renderer. | ||
const lineLayerProperties: __esri.FeatureLayerProperties = { | ||
geometryType: "polyline", | ||
title: "Near Mileposts", | ||
fields, | ||
objectIdField: objectIdFieldName, | ||
id: "nearMileposts", | ||
listMode: "hide", | ||
fullExtent: waExtent, | ||
spatialReference, | ||
// Since there are no features at the beginning, | ||
// need to add an empty array as the source. | ||
renderer: MilepostOffsetLineRenderer, | ||
source: [], | ||
popupEnabled: true, | ||
hasM: true, | ||
}; | ||
|
||
const lineLayer = new FeatureLayer(lineLayerProperties); | ||
lineLayer.popupTemplate = createPopupTemplate(lineLayer); | ||
|
||
return lineLayer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import type SpatialReference from "@arcgis/core/geometry/SpatialReference"; | ||
import FeatureLayer from "@arcgis/core/layers/FeatureLayer"; | ||
import SimpleRenderer from "@arcgis/core/renderers/SimpleRenderer"; | ||
import { SimpleMarkerSymbol } from "@arcgis/core/symbols"; | ||
import { createPopupTemplate, fields } from ".."; | ||
import waExtent from "../../../WAExtent"; | ||
import { | ||
highwaySignBackgroundColor, | ||
highwaySignTextColor, | ||
} from "../../../colors"; | ||
import { objectIdFieldName } from "../../../elc/types"; | ||
import labelClass from "../labelClass"; | ||
|
||
/** | ||
* Creates the {@link FeatureLayer} that displays located mileposts. | ||
* @param spatialReference - The {@link SpatialReference} of the layer. | ||
* @returns - A {@link FeatureLayer} | ||
*/ | ||
export function createMilepostPointLayer(spatialReference: SpatialReference) { | ||
/** | ||
* This is the symbol for the point on the route. | ||
*/ | ||
const milepostLayer = new FeatureLayer({ | ||
labelingInfo: [labelClass], | ||
title: "Mileposts", | ||
id: "mileposts", | ||
listMode: "hide", | ||
fields: fields, | ||
geometryType: "point", | ||
objectIdField: objectIdFieldName, | ||
fullExtent: waExtent, | ||
spatialReference, | ||
// Since there are no features at the beginning, | ||
// need to add an empty array as the source. | ||
source: [], | ||
popupEnabled: true, | ||
hasM: true, | ||
}); | ||
|
||
milepostLayer.renderer = createRenderer(); | ||
createPopupTemplate(milepostLayer); | ||
|
||
return milepostLayer; | ||
} | ||
function createRenderer() { | ||
const actualMPSymbol = new SimpleMarkerSymbol({ | ||
color: highwaySignBackgroundColor, | ||
size: 12, | ||
style: "circle", | ||
outline: { | ||
width: 1, | ||
color: highwaySignTextColor, | ||
}, | ||
}); | ||
|
||
const renderer = new SimpleRenderer({ | ||
symbol: actualMPSymbol, | ||
}); | ||
return renderer; | ||
} |
Oops, something went wrong.