# WebMap Service

The `WebMapService` enables communication with the BackEnd of a WebMap application.

## Configuration

The `WebMapService` should exist as a singleton instance inside the application. This service allows to specify a configuration when the default behavior wants to be modified.

To use a non-default configuration for this service you can use two methods:

1. Provide the `WEBMAP_CONFIG` InjectionToken in the root module with the configuration value. To learn more about Angular's dependency injection tokens check out the [official documentation](https://angular.io/guide/dependency-injection#dependency-injection-tokens).

   ```typescript
    @NgModule({
    declarations: [ AppComponent ],
    imports: [ WebMapModule ],
    providers: [
        { provide: WEBMAP_CONFIG, useValue: { useDynamicServerEvents: false }},
        WebMapService
    ],
    bootstrap: [ AppComponent ]
    })
    export class AppModule { }
   ```
2. Use the static function `provide(config: WebMapServiceConfig)` that is available from the service's class.

   ```typescript
    @NgModule({
    declarations: [ AppComponent ],
    imports: [ WebMapModule ],
    providers: [ WebMapService.provide({ useDynamicServerEvents: false }) ],
    bootstrap: [ AppComponent ]
    })
    export class AppModule { }
   ```

Below are the list of configuration options:

| Option                     | Type        | Default  | Description                                                                                                                                                                                                                                                              |
| -------------------------- | ----------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| \`useDynamicServerEvents\` | \`boolean\` | \`true\` | Enabled by default. Allows the Web Components to automatically send events to the Server when they have handlers in the Server Code. The typical case for disabling this is when the WebMap Application will handle manually all events that must be sent to the server. |
| \`webMapVersion\`          | \`string\`  | \`v5\`   | Its default value is v5. Allows to choose between protocol WebMAP5 (v5) and WepMAP4 (v4) for managing the communication between the back-end server and the front-end.                                                                                                   |

## Configuration Object Example

```javascript
webmapConfig = {
    useDynamicServerEvents: false,
    webMapVersion: 'v5'
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gapvelocity.ai/webmap/general/frontend/documentation/angular-client/webmap-service.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
