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

Manager add center and level #435

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
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
16 changes: 16 additions & 0 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export namespace Components {
* boolean: when true the grid will display like the previous manager app with the table across the top
*/
"classicGrid": boolean;
/**
* string: default center point values for the map ; delimited x;y pair
*/
"defaultCenter": string;
/**
* string: Global ID of the feature to select
*/
Expand All @@ -97,6 +101,10 @@ export namespace Components {
* string: when provided this layer ID will be used when the app loads
*/
"defaultLayer": string;
/**
* string: default zoom level
*/
"defaultLevel": string;
/**
* string: Object ID of feature to select
*/
Expand Down Expand Up @@ -1756,6 +1764,10 @@ declare namespace LocalJSX {
* boolean: when true the grid will display like the previous manager app with the table across the top
*/
"classicGrid"?: boolean;
/**
* string: default center point values for the map ; delimited x;y pair
*/
"defaultCenter"?: string;
/**
* string: Global ID of the feature to select
*/
Expand All @@ -1764,6 +1776,10 @@ declare namespace LocalJSX {
* string: when provided this layer ID will be used when the app loads
*/
"defaultLayer"?: string;
/**
* string: default zoom level
*/
"defaultLevel"?: string;
/**
* string: Object ID of feature to select
*/
Expand Down
56 changes: 51 additions & 5 deletions src/components/crowdsource-manager/crowdsource-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export class CrowdsourceManager {
*/
@Prop() classicGrid = false;

/**
* string: default center point values for the map
* ; delimited x;y pair
*/
@Prop() defaultCenter = "";

/**
* string: Global ID of the feature to select
*/
Expand All @@ -53,6 +59,11 @@ export class CrowdsourceManager {
*/
@Prop() defaultLayer = "";

/**
* string: default zoom level
*/
@Prop() defaultLevel = "";

/**
* string: Object ID of feature to select
*/
Expand Down Expand Up @@ -201,11 +212,21 @@ export class CrowdsourceManager {
//
//--------------------------------------------------------------------------

/**
* number[]: X,Y pair used to center the map
*/
protected _defaultCenter: number[];

/**
* string[]: List of global ids that should be selected by default
*/
protected _defaultGlobalId: string[];

/**
* number: zoom level the map should go to
*/
protected _defaultLevel: number;

/**
* number[]: List of ids that should be selected by default
*/
Expand Down Expand Up @@ -233,6 +254,15 @@ export class CrowdsourceManager {
//
//--------------------------------------------------------------------------

/**
* Watch for center url param to be set
*/
@Watch("defaultCenter")
defaultCenterWatchHandler(): void {
this._defaultCenter = !this.defaultCenter ? undefined :
this.defaultCenter.split(";").map(v => parseFloat(v));
}

/**
* Watch for globalid url param to be set
*/
Expand All @@ -251,6 +281,14 @@ export class CrowdsourceManager {
this.defaultOid.indexOf(",") > -1 ? this.defaultOid.split(",").map(o => parseInt(o, 10)) : [parseInt(this.defaultOid, 10)];
}

/**
* Watch for zoom level param to be set
*/
@Watch("defaultLevel")
defaultLevelWatchHandler(): void {
this._defaultLevel = !this.defaultLevel ? undefined : parseInt(this.defaultLevel, 10);
}

/**
* When true the map zoom tools will be available
*/
Expand Down Expand Up @@ -289,8 +327,8 @@ export class CrowdsourceManager {
evt: CustomEvent
): Promise<void> {
this._mapChange = evt.detail;
await this._mapChange.mapView.when(() => {
this._setMapView();
await this._mapChange.mapView.when(async () => {
await this._setMapView();
});
}

Expand Down Expand Up @@ -341,10 +379,10 @@ export class CrowdsourceManager {
* Called after each render
* Used to delay the setting of the mapView when the popup is expaneded and obstructs the view
*/
componentDidRender() {
async componentDidRender() {
if (this._shouldSetMapView) {
this._shouldSetMapView = false;
this._setMapView();
await this._setMapView();
}
}

Expand Down Expand Up @@ -725,11 +763,19 @@ export class CrowdsourceManager {
*
* @protected
*/
protected _setMapView(): void {
protected async _setMapView(): Promise<void> {
this._mapInfo = this._getMapInfo(this._mapChange.id);
this._mapView = this._mapChange.mapView;
this._initMapZoom();
this._mapView.popupEnabled = false;
if (this._defaultCenter && this._defaultLevel) {
await this._mapView.goTo({
center: this._defaultCenter,
zoom: this._defaultLevel
});
this._defaultCenter = undefined;
this._defaultLevel = undefined;
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/components/crowdsource-manager/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
| ------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------ | ---------------------- | ----------- |
| `basemapConfig` | -- | IBasemapConfig: List of any basemaps to filter out from the basemap widget | `IBasemapConfig` | `undefined` |
| `classicGrid` | `classic-grid` | boolean: when true the grid will display like the previous manager app with the table across the top | `boolean` | `false` |
| `defaultCenter` | `default-center` | string: default center point values for the map ; delimited x;y pair | `string` | `""` |
| `defaultGlobalId` | `default-global-id` | string: Global ID of the feature to select | `string` | `""` |
| `defaultLayer` | `default-layer` | string: when provided this layer ID will be used when the app loads | `string` | `""` |
| `defaultLevel` | `default-level` | string: default zoom level | `string` | `""` |
| `defaultOid` | `default-oid` | string: Object ID of feature to select | `string` | `""` |
| `defaultWebmap` | `default-webmap` | string: Item ID of the web map that should be selected by default | `string` | `""` |
| `enableAutoRefresh` | `enable-auto-refresh` | boolean: when true the layer table will auto refresh the data | `boolean` | `false` |
Expand Down
Loading