### Install angular-yandex-maps-v3 and Types Source: https://github.com/ddubrava/angular-yandex-maps/blob/main/libs/angular-yandex-maps-v3/README.md Install the library and its development types using npm. Ensure compatibility with your Angular version. ```bash npm install angular-yandex-maps-v3 npm install @yandex/ymaps3-types --save-dev ``` -------------------------------- ### Install angular-yandex-maps-v3 and Types Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Install the library and its development types. The types package requires `skipLibCheck` and `types` configuration in tsconfig.json. ```bash npm install angular-yandex-maps-v3 npm install @yandex/ymaps3-types --save-dev ``` ```jsonc // tsconfig.json — required for @yandex/ymaps3-types (uses React/Vue typings internally) { "compilerOptions": { "skipLibCheck": true, "types": ["@yandex/ymaps3-types"] } } ``` -------------------------------- ### SCAM Module Setup with API Key Source: https://github.com/ddubrava/angular-yandex-maps/blob/main/libs/angular-yandex-maps-v3/README.md Configure Yandex Maps with an API key within an Angular module using the SCAM (Single Component Angular Module) pattern. ```typescript import { NgModule } from '@angular/core'; import { YConfig, YMapComponent, YMapDefaultSchemeLayerDirective, provideYConfig, } from 'angular-yandex-maps-v3'; const config: YConfig = { apikey: 'API_KEY', }; @NgModule({ imports: [YMapComponent, YMapDefaultSchemeLayerDirective], providers: [provideYConfig(config)], }) export class AppModule {} ``` -------------------------------- ### Access Map Instance and API via `ready` Event Source: https://github.com/ddubrava/angular-yandex-maps/blob/main/libs/docsifier/assets/v3/faq.md Listen to the `ready` output event on the `y-map` component to get access to the created map instance and the global Yandex Maps API object. The event payload conforms to the `YReadyEvent` interface. ```html ``` ```typescript export class AppComponent { onMapReady(event: YReadyEvent): void { const { ymaps3, entity } = event; } } ``` -------------------------------- ### Configure YMap Component Properties Source: https://github.com/ddubrava/angular-yandex-maps/blob/main/libs/docsifier/assets/v3/faq.md Use the `props` input to pass configuration options to the `y-map` component, mirroring the Yandex.Maps JavaScript API class arguments. This example sets the initial location and theme. ```html ``` -------------------------------- ### Standalone Component Setup Source: https://github.com/ddubrava/angular-yandex-maps/blob/main/libs/angular-yandex-maps-v3/README.md Import and use YMapComponent and YMapDefaultSchemeLayerDirective in a standalone Angular component. ```typescript import { Component } from '@angular/core'; import { YMapComponent, YMapDefaultSchemeLayerDirective } from 'angular-yandex-maps-v3'; @Component({ imports: [YMapComponent, YMapDefaultSchemeLayerDirective], }) export class AppComponent {} ``` -------------------------------- ### Build Library Version Source: https://github.com/ddubrava/angular-yandex-maps/wiki/Major-Release-Checklist Execute this script to build the library for version 2. ```sh npm run build:lib:v2 ``` -------------------------------- ### Run Major Release Command Source: https://github.com/ddubrava/angular-yandex-maps/wiki/Major-Release-Checklist This command initiates the major release process, requiring a GITHUB_TOKEN environment variable. ```sh npm run release -- --specifier major ``` -------------------------------- ### Configure Yandex Maps API with provideYConfig (Standalone) Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Configure the Yandex.Maps API key and language using `provideYConfig` in the application's configuration file for standalone applications. ```typescript // app.config.ts — standalone application import { ApplicationConfig } from '@angular/core'; import { provideYConfig, YConfig } from 'angular-yandex-maps-v3'; const config: YConfig = { apikey: 'YOUR_API_KEY', lang: 'en_US', // optional, defaults to 'ru_RU' }; export const appConfig: ApplicationConfig = { providers: [provideYConfig(config)], }; ``` -------------------------------- ### Root Map Component () Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt The entry point for any map. Requires a 'location' prop with 'center' and 'zoom'. Emits a 'ready' event with the YMap instance. ```typescript import { Component } from '@angular/core'; import { YMapComponent, YMapDefaultSchemeLayerDirective, YReadyEvent, } from 'angular-yandex-maps-v3'; import type { YMap } from '@yandex/ymaps3-types'; @Component({ selector: 'app-root', imports: [YMapComponent, YMapDefaultSchemeLayerDirective], template: `
`, }) export class AppComponent { onMapReady(event: YReadyEvent) { // event.entity — the ymaps3.YMap instance // event.ymaps3 — the global ymaps3 object console.log('Map ready:', event.entity); } } ``` -------------------------------- ### Standalone App Configuration with API Key Source: https://github.com/ddubrava/angular-yandex-maps/blob/main/libs/angular-yandex-maps-v3/README.md Provide Yandex Maps configuration, including the API key, in the application's configuration file for standalone applications. ```typescript import { ApplicationConfig } from '@angular/core'; import { provideYConfig, YConfig } from 'angular-yandex-maps-v3'; const config: YConfig = { apikey: 'API_KEY', }; export const appConfig: ApplicationConfig = { providers: [provideYConfig(config)], }; ``` -------------------------------- ### Configure Map Component State and Options Source: https://github.com/ddubrava/angular-yandex-maps/blob/main/libs/docsifier/assets/v2/faq.md Set the initial state and options for the map component using input properties. Ensure the state and options objects conform to the ymaps API types. ```html ``` ```typescript export class AppComponent { state: ymaps.IMapState = { center: [55.751952, 37.600739], zoom: 3, }; options: ymaps.IMapOptions = { maxZoom: 5, }; } ``` -------------------------------- ### Configure Yandex Maps API with provideYConfig (NgModule) Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Configure the Yandex.Maps API key using `provideYConfig` within an NgModule. This approach is suitable for NgModule-based applications or SCAMs. ```typescript // app.module.ts — NgModule / SCAM approach import { NgModule } from '@angular/core'; import { YMapComponent, YMapDefaultSchemeLayerDirective, provideYConfig } from 'angular-yandex-maps-v3'; @NgModule({ imports: [YMapComponent, YMapDefaultSchemeLayerDirective], providers: [provideYConfig({ apikey: 'YOUR_API_KEY' })], }) export class AppModule {} ``` -------------------------------- ### Access Map Instance and API on Ready Source: https://github.com/ddubrava/angular-yandex-maps/blob/main/libs/docsifier/assets/v2/faq.md Retrieve the map instance and the global Yandex Maps API object when the map component is ready. This is useful for interacting with the map programmatically. ```html ``` ```typescript export class AppComponent { onMapReady(event: YaReadyEvent): void { const { ymaps, target } = event; } } ``` -------------------------------- ### Set Map Center and Zoom Directly Source: https://github.com/ddubrava/angular-yandex-maps/blob/main/libs/docsifier/assets/v2/faq.md Configure the map's center coordinates and zoom level directly via input properties for simpler use cases. ```html ``` -------------------------------- ### Handling Map and Layer Ready Events (`YReadyEvent`) Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt The `(ready)` event emits a `YReadyEvent` object, providing access to the underlying Yandex.Maps entity and the `ymaps3` namespace for imperative operations. This is useful for tasks like programmatically changing the map's location or accessing layer details. ```typescript import { Component } from '@angular/core'; import { YMapComponent, YMapDefaultSchemeLayerDirective, YReadyEvent } from 'angular-yandex-maps-v3'; import type { YMap } from '@yandex/ymaps3-types'; @Component({ selector: 'app-root', imports: [YMapComponent, YMapDefaultSchemeLayerDirective], template: ફો>
`, }) export class AppComponent { onMapReady(event: YReadyEvent) { // Imperative access: pan the map programmatically event.entity.setLocation({ center: [0, 51.5], zoom: 8, duration: 500 }); } onLayerReady(event: YReadyEvent) { console.log('Layer entity:', event.entity); console.log('ymaps3 version:', event.ymaps3.version); } } ``` -------------------------------- ### Update Packages to Latest Versions Source: https://github.com/ddubrava/angular-yandex-maps/wiki/Major-Release-Checklist Use this command to update all project packages to their latest versions before proceeding with the release. ```sh npx npm-check-updates -u ``` -------------------------------- ### Dynamic Yandex Maps API Configuration with Observable Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Provide dynamic Yandex.Maps API configuration using an RxJS Observable. This allows for runtime changes to settings like language or API key, triggering map reinitialization. ```typescript // Static config import { provideYConfig, YConfig } from 'angular-yandex-maps-v3'; export const appConfig: ApplicationConfig = { providers: [ provideYConfig({ apikey: 'YOUR_API_KEY', lang: 'en_US' }), ], }; // Dynamic (Observable) config — e.g. language toggle import { BehaviorSubject } from 'rxjs'; const config$ = new BehaviorSubject({ apikey: 'YOUR_API_KEY', lang: 'ru_RU' }); export const appConfig: ApplicationConfig = { providers: [provideYConfig(config$)], }; // Toggle language at runtime: config$.next({ apikey: 'YOUR_API_KEY', lang: 'en_US' }); // The map is automatically reinitialized with the new language. ``` -------------------------------- ### Map Container CSS Styling Source: https://github.com/ddubrava/angular-yandex-maps/blob/main/libs/angular-yandex-maps-v3/README.md Define the dimensions for the map container using CSS. Ensure the container has a defined width and height. ```css .container { width: 1000px; height: 500px; } ``` -------------------------------- ### Custom Map Layer () Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Wraps `ymaps3.YMapLayer` for custom tile or marker layers. Allows explicit z-index control. ```html ``` -------------------------------- ### Map Controls Container Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Use `` to group UI controls on the map. It must be nested within `` and accepts a `position` prop for placement. ```html ``` -------------------------------- ### Standard Tile Layer () Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Adds the default Yandex vector tile layer. Usually the first child of ``. Essential for tiles to render. ```html
``` -------------------------------- ### Custom Text Control Button Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Create a custom labeled button with `` for map interactions. It requires a `text` prop and an `onClick` handler, and must be inside ``. ```html ``` -------------------------------- ### Default Features Layer () Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Adds the default layer for rendering geo-objects and markers. Must be present with `` when using these objects. ```html ``` -------------------------------- ### Programmatic Yandex Maps API Loading with YApiLoaderService Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Use `YApiLoaderService` to programmatically load the Yandex.Maps JS API script. This is useful for interacting with the raw `ymaps3` global or reacting directly to API load events without using a `` component. ```typescript import { Component, OnInit, OnDestroy } from '@angular/core'; import { YApiLoaderService } from 'angular-yandex-maps-v3'; import { Subscription } from 'rxjs'; @Component({ selector: 'app-root', template: '' }) export class AppComponent implements OnInit, OnDestroy { private sub?: Subscription; constructor(private apiLoader: YApiLoaderService) {} ngOnInit() { // load() returns Observable // Emits once when the API is ready; re-emits if the config changes. this.sub = this.apiLoader.load().subscribe((ymaps3) => { console.log('API loaded, version:', ymaps3.version); // Perform any raw ymaps3 operations here }); } ngOnDestroy() { this.sub?.unsubscribe(); } } ``` -------------------------------- ### Marker Clusterer with Custom Templates Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Use `y-map-clusterer` to group nearby markers. It accepts `Feature[]` and allows custom HTML rendering for markers and clusters using `` and ``. ```typescript import { Component } from '@angular/core'; import { YMapComponent, YMapDefaultSchemeLayerDirective, YMapDefaultFeaturesLayerDirective, YMapClustererDirective, } from 'angular-yandex-maps-v3'; import type { Feature } from '@yandex/ymaps3-types/packages/clusterer'; @Component({ selector: 'app-root', imports: [ YMapComponent, YMapDefaultSchemeLayerDirective, YMapDefaultFeaturesLayerDirective, YMapClustererDirective, ], template: '
pin
{{ context.features.length }}
', }) export class AppComponent { features: Feature[] = [ { type: 'Feature', id: '0', geometry: { type: 'Point', coordinates: [-0.597696, 51.907351] } }, { type: 'Feature', id: '1', geometry: { type: 'Point', coordinates: [-0.127696, 51.507351] } }, { type: 'Feature', id: '2', geometry: { type: 'Point', coordinates: [0.302304, 51.127351] } }, { type: 'Feature', id: '3', geometry: { type: 'Point', coordinates: [-0.227696, 51.607351] } }, ]; } ``` -------------------------------- ### Instantiate Unexisting Yandex Maps Class Source: https://github.com/ddubrava/angular-yandex-maps/blob/main/libs/docsifier/assets/v2/faq.md Use type casting with 'any' to instantiate classes that might be missing from the current Yandex Maps typings. This is a workaround for incomplete type definitions. ```typescript const instance = new (ymaps as any).UnexistingClass(); ``` -------------------------------- ### Define Feature Data Source with y-map-feature-data-source Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Use `` to provide a named data source, essential for clusterers or external data pipelines. Assign a unique ID to the source. ```html ``` -------------------------------- ### Open in Yandex Maps Button Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Add a button to open the current map view in the full Yandex Maps application using ``. It must be placed within ``. ```html ``` -------------------------------- ### Common Style Control Button (``) Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Use this component to render a button that matches the style of native Yandex Maps controls. It must be placed within a `` element. ```html ``` -------------------------------- ### Basic Map Component Usage in HTML Source: https://github.com/ddubrava/angular-yandex-maps/blob/main/libs/angular-yandex-maps-v3/README.md Integrate the YMap component into your Angular template. Configure map properties like location and theme. ```html
``` -------------------------------- ### Display Hover Tooltips with y-map-hint Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Use `` to display template-driven tooltips on hover. The `hint` callback receives the hovered entity, and its return value is available as `$implicit` in the ng-template. ```typescript import { Component } from '@angular/core'; import { YMapComponent, YMapDefaultSchemeLayerDirective, YMapDefaultFeaturesLayerDirective, YMapDefaultMarkerDirective, YMapHintDirective, } from 'angular-yandex-maps-v3'; @Component({ selector: 'app-root', imports: [ YMapComponent, YMapDefaultSchemeLayerDirective, YMapDefaultFeaturesLayerDirective, YMapDefaultMarkerDirective, YMapHintDirective, ], template: '
{{ context?.hint }}
', }) export class AppComponent { // Return what you want displayed; it appears as context.hint in the template onHint = (entity?: any) => entity?.properties?.['label']; } ``` -------------------------------- ### Geolocation Control Button Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Include a geolocation button with `` to pan the map to the user's current location. It requires placement within ``. ```html ``` -------------------------------- ### Handle Map Events with y-map-listener Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Attach global event callbacks like 'onClick' or 'onMouseMove' to the map using ``. Event handlers receive event data, including coordinates for clicks. ```typescript import { Component } from '@angular/core'; import { YMapComponent, YMapDefaultSchemeLayerDirective, YMapListenerDirective, } from 'angular-yandex-maps-v3'; @Component({ selector: 'app-root', imports: [YMapComponent, YMapDefaultSchemeLayerDirective, YMapListenerDirective], template: '

Last click: {{ lastClick }}

', }) export class AppComponent { lastClick = ''; onMapClick = (event: any) => { const [lng, lat] = event.coordinates; this.lastClick = `lng=${lng.toFixed(4)}, lat=${lat.toFixed(4)}`; }; onMouseMove = (event: any) => { // Runs outside Angular zone — use NgZone.run() to trigger change detection if needed }; } ``` -------------------------------- ### Custom HTML Control (``) Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt This component allows you to render any custom HTML content as a map control. Ensure it is placed inside a `` tag. ```html
Info Panel

Zoom: {{ currentZoom }}

``` -------------------------------- ### Render Styled Polygon with y-map-feature Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Use `` to render GeoJSON-style polygons with custom stroke and fill styles. Ensure the map component is properly initialized with location props. ```html ``` -------------------------------- ### Default Styled Marker () Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Renders a pre-styled pin marker. Supports reactive updates to title, subtitle, color, and click handlers. Requires `angular-yandex-maps-v3` and `@yandex/ymaps3-markers`. ```typescript import { Component } from '@angular/core'; import { YMapComponent, YMapDefaultSchemeLayerDirective, YMapDefaultFeaturesLayerDirective, YMapDefaultMarkerDirective, } from 'angular-yandex-maps-v3'; @Component({ selector: 'app-root', imports: [ YMapComponent, YMapDefaultSchemeLayerDirective, YMapDefaultFeaturesLayerDirective, YMapDefaultMarkerDirective, ], template: `
`, }) export class AppComponent { onMarkerClick = () => alert('Marker clicked!'); } ``` -------------------------------- ### Scale Indicator Control Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Display a map scale bar using ``. This component must be nested inside ``. ```html ``` -------------------------------- ### TypeScript Configuration for Yandex Maps Types Source: https://github.com/ddubrava/angular-yandex-maps/blob/main/libs/angular-yandex-maps-v3/README.md Configure tsconfig.json to skip library checks and include Yandex Maps types globally. This is necessary due to the library using both Vue and React typings. ```json { "compilerOptions": { "skipLibCheck": true, "types": ["@yandex/ymaps3-types"] } } ``` -------------------------------- ### Zoom Control Button Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Add a zoom control to the map using ``. This component must be placed inside ``. ```html ``` -------------------------------- ### Custom HTML Marker () Source: https://context7.com/ddubrava/angular-yandex-maps/llms.txt Wraps `ymaps3.YMapMarker` to render custom HTML elements as markers. The projected child element becomes the marker's DOM node. Supports draggable markers. ```typescript import { Component } from '@angular/core'; import { YMapComponent, YMapDefaultSchemeLayerDirective, YMapDefaultFeaturesLayerDirective, YMapMarkerDirective, } from 'angular-yandex-maps-v3'; @Component({ selector: 'app-root', imports: [ YMapComponent, YMapDefaultSchemeLayerDirective, YMapDefaultFeaturesLayerDirective, YMapMarkerDirective, ], template: `
📍 London
`, }) export class AppComponent {} ``` -------------------------------- ### Handle Map Balloon Close Event Source: https://github.com/ddubrava/angular-yandex-maps/blob/main/libs/docsifier/assets/v2/faq.md Listen for the 'balloonclose' event emitted by the map component to execute custom logic when the map's balloon is closed. ```html ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.