update for 2gis
This commit is contained in:
+9
-24
@@ -3,7 +3,7 @@
|
|||||||
"version": 1,
|
"version": 1,
|
||||||
"newProjectRoot": "projects",
|
"newProjectRoot": "projects",
|
||||||
"projects": {
|
"projects": {
|
||||||
"maps": {
|
"gorodar-front": {
|
||||||
"projectType": "application",
|
"projectType": "application",
|
||||||
"schematics": {
|
"schematics": {
|
||||||
"@schematics/angular:component": {
|
"@schematics/angular:component": {
|
||||||
@@ -18,15 +18,11 @@
|
|||||||
"builder": "@angular/build:application",
|
"builder": "@angular/build:application",
|
||||||
"options": {
|
"options": {
|
||||||
"browser": "src/main.ts",
|
"browser": "src/main.ts",
|
||||||
"polyfills": [
|
"polyfills": ["zone.js"],
|
||||||
"zone.js"
|
|
||||||
],
|
|
||||||
"tsConfig": "tsconfig.app.json",
|
"tsConfig": "tsconfig.app.json",
|
||||||
"inlineStyleLanguage": "scss",
|
"inlineStyleLanguage": "scss",
|
||||||
"stylePreprocessorOptions": {
|
"stylePreprocessorOptions": {
|
||||||
"includePaths": [
|
"includePaths": ["src/assets/styles"]
|
||||||
"src/assets/styles"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"assets": [
|
"assets": [
|
||||||
{
|
{
|
||||||
@@ -34,10 +30,7 @@
|
|||||||
"input": "public"
|
"input": "public"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"styles": [
|
"styles": ["@angular/material/prebuilt-themes/magenta-violet.css", "src/styles.scss"]
|
||||||
"@angular/material/prebuilt-themes/magenta-violet.css",
|
|
||||||
"src/styles.scss"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
@@ -68,10 +61,10 @@
|
|||||||
"builder": "@angular/build:dev-server",
|
"builder": "@angular/build:dev-server",
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
"buildTarget": "maps:build:production"
|
"buildTarget": "gorodar-front:build:production"
|
||||||
},
|
},
|
||||||
"development": {
|
"development": {
|
||||||
"buildTarget": "maps:build:development"
|
"buildTarget": "gorodar-front:build:development"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"defaultConfiguration": "development"
|
"defaultConfiguration": "development"
|
||||||
@@ -82,16 +75,11 @@
|
|||||||
"test": {
|
"test": {
|
||||||
"builder": "@angular/build:karma",
|
"builder": "@angular/build:karma",
|
||||||
"options": {
|
"options": {
|
||||||
"polyfills": [
|
"polyfills": ["zone.js", "zone.js/testing"],
|
||||||
"zone.js",
|
|
||||||
"zone.js/testing"
|
|
||||||
],
|
|
||||||
"tsConfig": "tsconfig.spec.json",
|
"tsConfig": "tsconfig.spec.json",
|
||||||
"inlineStyleLanguage": "scss",
|
"inlineStyleLanguage": "scss",
|
||||||
"stylePreprocessorOptions": {
|
"stylePreprocessorOptions": {
|
||||||
"includePaths": [
|
"includePaths": ["src/assets/styles"]
|
||||||
"src/assets/styles"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"assets": [
|
"assets": [
|
||||||
{
|
{
|
||||||
@@ -99,10 +87,7 @@
|
|||||||
"input": "public"
|
"input": "public"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"styles": [
|
"styles": ["@angular/material/prebuilt-themes/magenta-violet.css", "src/styles.scss"]
|
||||||
"@angular/material/prebuilt-themes/magenta-violet.css",
|
|
||||||
"src/styles.scss"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+21
-26
@@ -1,13 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "maps",
|
"name": "gorodar-front",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "maps",
|
"name": "gorodar-front",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@2gis/mapgl": "^1.78.1",
|
||||||
"@angular/animations": "^20.3.32",
|
"@angular/animations": "^20.3.32",
|
||||||
"@angular/cdk": "^20.2.14",
|
"@angular/cdk": "^20.2.14",
|
||||||
"@angular/common": "^20.3.0",
|
"@angular/common": "^20.3.0",
|
||||||
@@ -35,7 +36,6 @@
|
|||||||
"@angular/compiler-cli": "^20.3.0",
|
"@angular/compiler-cli": "^20.3.0",
|
||||||
"@capacitor/cli": "^6.2.2",
|
"@capacitor/cli": "^6.2.2",
|
||||||
"@types/jasmine": "~5.1.0",
|
"@types/jasmine": "~5.1.0",
|
||||||
"@yandex/ymaps3-types": "^1.0.21108841",
|
|
||||||
"jasmine-core": "~5.9.0",
|
"jasmine-core": "~5.9.0",
|
||||||
"karma": "~6.4.0",
|
"karma": "~6.4.0",
|
||||||
"karma-chrome-launcher": "~3.2.0",
|
"karma-chrome-launcher": "~3.2.0",
|
||||||
@@ -45,6 +45,18 @@
|
|||||||
"typescript": "~5.9.2"
|
"typescript": "~5.9.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@2gis/mapgl": {
|
||||||
|
"version": "1.78.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@2gis/mapgl/-/mapgl-1.78.1.tgz",
|
||||||
|
"integrity": "sha512-SkbrqwBMPTLV4hihV+BgAtftIfyMeSru6yqlVF0IJEE6jaGQ8LFq0NJb1TTaXt3I1t3q8sjvU7X/hhHpxo5JXQ==",
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/geojson": "^7946.0.7"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@algolia/abtesting": {
|
"node_modules/@algolia/abtesting": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@algolia/abtesting/-/abtesting-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@algolia/abtesting/-/abtesting-1.1.0.tgz",
|
||||||
@@ -4536,6 +4548,12 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/geojson": {
|
||||||
|
"version": "7946.0.16",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz",
|
||||||
|
"integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@types/jasmine": {
|
"node_modules/@types/jasmine": {
|
||||||
"version": "5.1.15",
|
"version": "5.1.15",
|
||||||
"resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-5.1.15.tgz",
|
"resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-5.1.15.tgz",
|
||||||
@@ -4593,29 +4611,6 @@
|
|||||||
"node": ">=14.6"
|
"node": ">=14.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@yandex/ymaps3-types": {
|
|
||||||
"version": "1.0.21108841",
|
|
||||||
"resolved": "https://registry.npmjs.org/@yandex/ymaps3-types/-/ymaps3-types-1.0.21108841.tgz",
|
|
||||||
"integrity": "sha512-ZUUjQ2sgVQZE+Alt7d1u2oVvHhDNlq1YrVqlqadiqvotkOWT5kIKWoWv+qsMoCsriObtYh1jRtAyXzOqAsFyRg==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"peerDependencies": {
|
|
||||||
"@types/react": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
||||||
"@types/react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
||||||
"@vue/runtime-core": "3"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@types/react": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@types/react-dom": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@vue/runtime-core": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@yarnpkg/lockfile": {
|
"node_modules/@yarnpkg/lockfile": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz",
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "maps",
|
"name": "gorodar-front",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@2gis/mapgl": "^1.78.1",
|
||||||
"@angular/animations": "^20.3.32",
|
"@angular/animations": "^20.3.32",
|
||||||
"@angular/cdk": "^20.2.14",
|
"@angular/cdk": "^20.2.14",
|
||||||
"@angular/common": "^20.3.0",
|
"@angular/common": "^20.3.0",
|
||||||
@@ -49,7 +50,6 @@
|
|||||||
"@angular/compiler-cli": "^20.3.0",
|
"@angular/compiler-cli": "^20.3.0",
|
||||||
"@capacitor/cli": "^6.2.2",
|
"@capacitor/cli": "^6.2.2",
|
||||||
"@types/jasmine": "~5.1.0",
|
"@types/jasmine": "~5.1.0",
|
||||||
"@yandex/ymaps3-types": "^1.0.21108841",
|
|
||||||
"jasmine-core": "~5.9.0",
|
"jasmine-core": "~5.9.0",
|
||||||
"karma": "~6.4.0",
|
"karma": "~6.4.0",
|
||||||
"karma-chrome-launcher": "~3.2.0",
|
"karma-chrome-launcher": "~3.2.0",
|
||||||
@@ -58,4 +58,4 @@
|
|||||||
"karma-jasmine-html-reporter": "~2.1.0",
|
"karma-jasmine-html-reporter": "~2.1.0",
|
||||||
"typescript": "~5.9.2"
|
"typescript": "~5.9.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
>
|
>
|
||||||
<app-icon name="pin" [size]="18" />
|
<app-icon name="pin" [size]="18" />
|
||||||
<span>{{ city.name }}</span>
|
<span>{{ city.name }}</span>
|
||||||
<app-icon name="chevron-down" [size]="18" />
|
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
.city-map__chip {
|
.city-map__chip {
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
padding: 0 12px 0 16px;
|
padding: 0 16px;
|
||||||
font: inherit;
|
font: inherit;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
inject,
|
inject,
|
||||||
signal,
|
signal,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
import { load } from '@2gis/mapgl';
|
||||||
import { Geolocation, type Position } from '@capacitor/geolocation';
|
import { Geolocation, type Position } from '@capacitor/geolocation';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
@@ -19,11 +20,16 @@ import type { Landmark } from '../../data/nizhny-novgorod';
|
|||||||
import { Icon } from '../../shared/icon/icon';
|
import { Icon } from '../../shared/icon/icon';
|
||||||
import { selectCollectedIdSet } from '../../state';
|
import { selectCollectedIdSet } from '../../state';
|
||||||
|
|
||||||
declare global {
|
const MAPGL_KEY = 'bf0a466f-43a6-48c7-b274-7fea5952957b';
|
||||||
interface Window {
|
const MAP_STYLE_NIGHT = 'e05ac437-fcc2-4845-ad74-b1de9ce07555';
|
||||||
ymaps3: any;
|
const CITY_ZOOM = 13;
|
||||||
}
|
const USER_ZOOM = 16;
|
||||||
}
|
const LANDMARK_SIZE = 40;
|
||||||
|
const USER_SIZE = 32;
|
||||||
|
|
||||||
|
type MapglApi = Awaited<ReturnType<typeof load>>;
|
||||||
|
type MapglMap = InstanceType<MapglApi['Map']>;
|
||||||
|
type MapglHtmlMarker = InstanceType<MapglApi['HtmlMarker']>;
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-city-map',
|
selector: 'app-city-map',
|
||||||
@@ -39,14 +45,16 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
private readonly catalog = inject(CityCatalogService);
|
private readonly catalog = inject(CityCatalogService);
|
||||||
private readonly store = inject(Store);
|
private readonly store = inject(Store);
|
||||||
private readonly zone = inject(NgZone);
|
private readonly zone = inject(NgZone);
|
||||||
private map: any;
|
private mapgl: MapglApi | null = null;
|
||||||
private userMarker: any;
|
private map: MapglMap | null = null;
|
||||||
|
private userMarker: MapglHtmlMarker | null = null;
|
||||||
private userMarkerElement: HTMLElement | null = null;
|
private userMarkerElement: HTMLElement | null = null;
|
||||||
private watchId: string | null = null;
|
private watchId: string | null = null;
|
||||||
private lastPosition: Position | null = null;
|
private lastPosition: Position | null = null;
|
||||||
private zoomOnNextPan = true;
|
private zoomOnNextPan = true;
|
||||||
private currentZoom = 13;
|
private destroyed = false;
|
||||||
private readonly markerElements = new Map<string, HTMLElement>();
|
private readonly markerElements = new Map<string, HTMLElement>();
|
||||||
|
private readonly markers = new Map<string, MapglHtmlMarker>();
|
||||||
private readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
private readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
||||||
|
|
||||||
protected readonly city = this.catalog.city;
|
protected readonly city = this.catalog.city;
|
||||||
@@ -64,71 +72,64 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async ngAfterViewInit(): Promise<void> {
|
async ngAfterViewInit(): Promise<void> {
|
||||||
await window.ymaps3.ready;
|
const mapgl = await load();
|
||||||
|
|
||||||
const {
|
if (this.destroyed) {
|
||||||
YMap,
|
|
||||||
YMapDefaultSchemeLayer,
|
|
||||||
YMapDefaultFeaturesLayer,
|
|
||||||
YMapMarker,
|
|
||||||
YMapListener,
|
|
||||||
} = window.ymaps3;
|
|
||||||
const center = this.city.center;
|
|
||||||
|
|
||||||
this.map = new YMap(this.mapElement.nativeElement, {
|
|
||||||
location: {
|
|
||||||
center,
|
|
||||||
zoom: 13,
|
|
||||||
},
|
|
||||||
theme: 'dark',
|
|
||||||
distribution: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.map.addChild(new YMapDefaultSchemeLayer({ theme: 'dark' }));
|
|
||||||
this.map.addChild(new YMapDefaultFeaturesLayer());
|
|
||||||
|
|
||||||
if (YMapListener) {
|
|
||||||
this.map.addChild(
|
|
||||||
new YMapListener({
|
|
||||||
onActionStart: (event: { type?: string }) => {
|
|
||||||
if (event?.type === 'drag' || event?.type === 'scrollZoom' || event?.type === 'pinchZoom') {
|
|
||||||
this.zone.run(() => this.following.set(false));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onUpdate: ({ location }: { location?: { zoom?: number } }) => {
|
|
||||||
if (location?.zoom == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.currentZoom = location.zoom;
|
|
||||||
this.syncRadiusSize();
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const landmark of this.city.objects) {
|
|
||||||
this.map.addChild(this.createMarker(YMapMarker, landmark));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
void this.stopWatching();
|
|
||||||
this.map?.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected focusCity(): void {
|
|
||||||
if (!this.map) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.mapgl = mapgl;
|
||||||
|
|
||||||
|
this.zone.runOutsideAngular(() => {
|
||||||
|
if (this.destroyed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const map = new mapgl.Map(this.mapElement.nativeElement, {
|
||||||
|
center: this.city.center,
|
||||||
|
zoom: CITY_ZOOM,
|
||||||
|
key: MAPGL_KEY,
|
||||||
|
lang: 'ru',
|
||||||
|
style: MAP_STYLE_NIGHT,
|
||||||
|
defaultBackgroundColor: '#12110f',
|
||||||
|
zoomControl: false,
|
||||||
|
disablePitchByUserInteraction: true,
|
||||||
|
disableRotationByUserInteraction: true,
|
||||||
|
enableTrackResize: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.destroyed) {
|
||||||
|
map.destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.map = map;
|
||||||
|
map.on('movestart', (event) => {
|
||||||
|
if (!event.isUser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.zone.run(() => this.following.set(false));
|
||||||
|
});
|
||||||
|
map.on('move', () => this.syncRadiusSize());
|
||||||
|
|
||||||
|
for (const landmark of this.city.objects) {
|
||||||
|
this.markers.set(landmark.id, this.createMarker(mapgl, map, landmark));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
this.destroyed = true;
|
||||||
|
void this.stopWatching();
|
||||||
|
this.map?.destroy();
|
||||||
|
this.map = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected focusCity(): void {
|
||||||
this.following.set(false);
|
this.following.set(false);
|
||||||
this.clearSelection();
|
this.clearSelection();
|
||||||
this.map.setLocation({
|
this.moveMap(this.city.center, CITY_ZOOM, 500);
|
||||||
center: this.city.center,
|
|
||||||
zoom: 13,
|
|
||||||
duration: 500,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async locate(): Promise<void> {
|
protected async locate(): Promise<void> {
|
||||||
@@ -173,21 +174,35 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateUserPosition(position: Position, pan: boolean): void {
|
private updateUserPosition(position: Position, pan: boolean): void {
|
||||||
|
const map = this.map;
|
||||||
|
|
||||||
|
if (!map) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.lastPosition = position;
|
this.lastPosition = position;
|
||||||
const coordinates: [number, number] = [position.coords.longitude, position.coords.latitude];
|
const coordinates: [number, number] = [position.coords.longitude, position.coords.latitude];
|
||||||
const heading = position.coords.heading;
|
const heading = position.coords.heading;
|
||||||
|
|
||||||
if (!this.userMarker) {
|
if (!this.userMarker && this.mapgl) {
|
||||||
const { YMapMarker } = window.ymaps3;
|
|
||||||
const markerElement = document.createElement('div');
|
const markerElement = document.createElement('div');
|
||||||
markerElement.className = 'city-map__user';
|
markerElement.className = 'city-map__user';
|
||||||
markerElement.innerHTML =
|
markerElement.innerHTML =
|
||||||
'<span class="city-map__user-body"><span class="city-map__user-heading"></span><span class="city-map__user-dot"></span></span>';
|
'<span class="city-map__user-body"><span class="city-map__user-heading"></span><span class="city-map__user-dot"></span></span>';
|
||||||
this.userMarkerElement = markerElement;
|
this.userMarkerElement = markerElement;
|
||||||
this.userMarker = new YMapMarker({ coordinates, dx: -16, dy: -16 }, markerElement);
|
this.userMarker = new this.mapgl.HtmlMarker(map, {
|
||||||
this.map.addChild(this.userMarker);
|
coordinates,
|
||||||
|
html: markerElement,
|
||||||
|
anchor: [USER_SIZE / 2, USER_SIZE / 2],
|
||||||
|
interactive: false,
|
||||||
|
preventMapInteractions: false,
|
||||||
|
disableRounding: true,
|
||||||
|
labeling: { type: 'none' },
|
||||||
|
zIndex: 3,
|
||||||
|
});
|
||||||
|
this.userMarker.getContent().style.overflow = 'visible';
|
||||||
} else {
|
} else {
|
||||||
this.userMarker.update({ coordinates });
|
this.userMarker?.setCoordinates(coordinates);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (heading != null && !Number.isNaN(heading) && this.userMarkerElement) {
|
if (heading != null && !Number.isNaN(heading) && this.userMarkerElement) {
|
||||||
@@ -196,11 +211,7 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pan) {
|
if (pan) {
|
||||||
this.map.setLocation({
|
this.moveMap(coordinates, this.zoomOnNextPan ? USER_ZOOM : null, 400);
|
||||||
center: coordinates,
|
|
||||||
...(this.zoomOnNextPan ? { zoom: 16 } : {}),
|
|
||||||
duration: 400,
|
|
||||||
});
|
|
||||||
this.zoomOnNextPan = false;
|
this.zoomOnNextPan = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,7 +225,7 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
this.watchId = null;
|
this.watchId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createMarker(YMapMarker: any, landmark: Landmark): any {
|
private createMarker(mapgl: MapglApi, map: MapglMap, landmark: Landmark): MapglHtmlMarker {
|
||||||
const markerElement = document.createElement('button');
|
const markerElement = document.createElement('button');
|
||||||
markerElement.type = 'button';
|
markerElement.type = 'button';
|
||||||
markerElement.className = 'city-map__marker';
|
markerElement.className = 'city-map__marker';
|
||||||
@@ -234,14 +245,18 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
this.zone.run(() => this.selectLandmark(landmark));
|
this.zone.run(() => this.selectLandmark(landmark));
|
||||||
});
|
});
|
||||||
|
|
||||||
return new YMapMarker(
|
const marker = new mapgl.HtmlMarker(map, {
|
||||||
{
|
coordinates: landmark.coordinates,
|
||||||
coordinates: landmark.coordinates,
|
html: markerElement,
|
||||||
dx: -20,
|
anchor: [LANDMARK_SIZE / 2, LANDMARK_SIZE / 2],
|
||||||
dy: -20,
|
interactive: true,
|
||||||
},
|
disableRounding: true,
|
||||||
markerElement,
|
labeling: { type: 'none' },
|
||||||
);
|
zIndex: 1,
|
||||||
|
});
|
||||||
|
marker.getContent().style.overflow = 'visible';
|
||||||
|
|
||||||
|
return marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
private setMarkerIcon(element: HTMLElement, collected: boolean): void {
|
private setMarkerIcon(element: HTMLElement, collected: boolean): void {
|
||||||
@@ -251,9 +266,7 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const src = collected
|
const src = collected ? '/assets/icons/check-marker.svg' : '/assets/icons/lock-marker.svg';
|
||||||
? '/assets/icons/check-marker.svg'
|
|
||||||
: '/assets/icons/lock-marker.svg';
|
|
||||||
|
|
||||||
if (img.getAttribute('src') !== src) {
|
if (img.getAttribute('src') !== src) {
|
||||||
img.setAttribute('src', src);
|
img.setAttribute('src', src);
|
||||||
@@ -278,14 +291,17 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
const selectedId = this.selected()?.id;
|
const selectedId = this.selected()?.id;
|
||||||
|
|
||||||
for (const [id, element] of this.markerElements) {
|
for (const [id, element] of this.markerElements) {
|
||||||
element.classList.toggle('city-map__marker--active', id === selectedId);
|
const active = id === selectedId;
|
||||||
|
element.classList.toggle('city-map__marker--active', active);
|
||||||
|
this.markers.get(id)?.setZIndex(active ? 2 : 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private syncRadiusSize(): void {
|
private syncRadiusSize(): void {
|
||||||
const selected = this.selected();
|
const selected = this.selected();
|
||||||
|
const map = this.map;
|
||||||
|
|
||||||
if (!selected) {
|
if (!selected || !map) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,14 +311,41 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const diameter = this.metersToPixels(selected.geoRadiusMeters, selected.coordinates[1]) * 2;
|
const diameter = this.metersToPixels(map, selected.geoRadiusMeters, selected.coordinates) * 2;
|
||||||
element.style.setProperty('--radius-px', `${diameter}px`);
|
element.style.setProperty('--radius-px', `${diameter}px`);
|
||||||
}
|
}
|
||||||
|
|
||||||
private metersToPixels(meters: number, latitude: number): number {
|
private metersToPixels(
|
||||||
const metersPerPixel =
|
map: MapglMap,
|
||||||
(156543.03392 * Math.cos((latitude * Math.PI) / 180)) / 2 ** this.currentZoom;
|
meters: number,
|
||||||
|
coordinates: [number, number],
|
||||||
|
): number {
|
||||||
|
const [longitude, latitude] = coordinates;
|
||||||
|
const origin = map.project(coordinates);
|
||||||
|
const metersPerDegree = 111_320 * Math.cos((latitude * Math.PI) / 180);
|
||||||
|
const shifted = map.project([
|
||||||
|
longitude + meters / Math.max(metersPerDegree, 1),
|
||||||
|
latitude,
|
||||||
|
]);
|
||||||
|
|
||||||
return meters / Math.max(metersPerPixel, 0.01);
|
return Math.hypot(shifted[0] - origin[0], shifted[1] - origin[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private moveMap(center: [number, number], zoom: number | null, duration: number): void {
|
||||||
|
const map = this.map;
|
||||||
|
|
||||||
|
if (!map) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
map.setCenter(center, { duration, easing: 'easeOutCubic' });
|
||||||
|
|
||||||
|
if (zoom != null) {
|
||||||
|
map.setZoom(zoom, {
|
||||||
|
duration,
|
||||||
|
easing: 'easeOutCubic',
|
||||||
|
useHeightForAnimation: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,110 +2,122 @@
|
|||||||
@if (claiming()) {
|
@if (claiming()) {
|
||||||
<app-claim-flow [landmark]="item" />
|
<app-claim-flow [landmark]="item" />
|
||||||
} @else {
|
} @else {
|
||||||
<article class="object" [class.object--owned]="collected()">
|
<article class="object" [class.object--owned]="collected()">
|
||||||
<header class="object__hero">
|
<header class="object__hero">
|
||||||
<img class="object__hero-img" src="/assets/illustrations/object-hero.svg" alt="" />
|
<img class="object__hero-img" src="/assets/illustrations/object-hero.svg" alt="" />
|
||||||
<button class="object__back" type="button" aria-label="Назад" (click)="goBack()">
|
<button class="object__back" type="button" aria-label="Назад" (click)="goBack()">
|
||||||
<app-icon name="chevron-left" [size]="22" />
|
<app-icon name="chevron-left" [size]="22" />
|
||||||
</button>
|
</button>
|
||||||
<span class="object__city">{{ city.name }}</span>
|
<span class="object__city">{{ city.name }}</span>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="object__intro">
|
<div class="object__intro">
|
||||||
<h1>{{ item.title }}</h1>
|
<h1>{{ item.title }}</h1>
|
||||||
|
|
||||||
<div class="object__chips">
|
<div class="object__chips">
|
||||||
<span class="chip" [class.chip--open]="collected()">
|
<span class="chip" [class.chip--open]="collected()">
|
||||||
<app-icon [name]="collected() ? 'check' : 'lock'" [size]="15" />
|
<app-icon [name]="collected() ? 'check' : 'lock'" [size]="15" />
|
||||||
{{ collectedLabel() }}
|
{{ collectedLabel() }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="object__address">
|
<div class="object__address">
|
||||||
<app-icon name="pin" [size]="18" />
|
<app-icon name="pin" [size]="18" />
|
||||||
<div>
|
<div>
|
||||||
<p>{{ item.address }}</p>
|
<p>{{ item.address }}</p>
|
||||||
<span>{{ item.addressHint }}</span>
|
<span>{{ item.addressHint }}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="object__body">
|
<div class="object__body">
|
||||||
<section>
|
|
||||||
<h2>О месте</h2>
|
|
||||||
<p>{{ item.description }}</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<h2>Интересные факты</h2>
|
|
||||||
<ol class="facts">
|
|
||||||
@for (fact of item.facts; track fact; let index = $index) {
|
|
||||||
<li>
|
|
||||||
<span>{{ index + 1 }}</span>
|
|
||||||
{{ fact }}
|
|
||||||
</li>
|
|
||||||
}
|
|
||||||
</ol>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
@if (collected()) {
|
|
||||||
<section>
|
<section>
|
||||||
<h2>Ваше фото</h2>
|
<h2>О месте</h2>
|
||||||
<button class="owned-photo" type="button" (click)="openPhoto()">
|
<p>{{ item.description }}</p>
|
||||||
<img [src]="userPhoto() ?? '/assets/illustrations/photo-day.svg'" alt="Ваше фото объекта" />
|
|
||||||
<span class="owned-photo__badge">
|
|
||||||
<app-icon name="check" [size]="14" />
|
|
||||||
Подтверждено
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
<p class="object__hint">Этот объект уже в вашей коллекции. Повторно его получить нельзя.</p>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<a class="object__map" routerLink="/map">
|
|
||||||
<app-icon name="pin" [size]="20" />
|
|
||||||
Показать на карте
|
|
||||||
</a>
|
|
||||||
} @else {
|
|
||||||
<section>
|
<section>
|
||||||
<h2>Примеры фото</h2>
|
<h2>Интересные факты</h2>
|
||||||
<div class="photos">
|
<ol class="facts">
|
||||||
@for (photo of photoExamples; track photo.label) {
|
@for (fact of item.facts; track fact; let index = $index) {
|
||||||
<figure>
|
<li>
|
||||||
<img [src]="photo.src" [alt]="photo.label" />
|
<span class="facts__number">{{ index + 1 }}</span>
|
||||||
<span>{{ photo.label }}</span>
|
<span class="facts__value">
|
||||||
</figure>
|
{{ fact }}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
}
|
}
|
||||||
</div>
|
|
||||||
<p class="object__hint">{{ item.photoHint }}</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<h2>Как забрать</h2>
|
|
||||||
<ol class="steps">
|
|
||||||
<li>Приезжайте на место и найдите объект</li>
|
|
||||||
<li>Нажмите «Забрать» и сфотографируйте объект</li>
|
|
||||||
<li>Получите объект в свою коллекцию</li>
|
|
||||||
</ol>
|
</ol>
|
||||||
</section>
|
</section>
|
||||||
}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@if (!collected()) {
|
@if (collected()) {
|
||||||
<footer class="object__bar">
|
<section>
|
||||||
<button class="object__claim" matButton="filled" type="button" (click)="claimItem()">
|
<h2>Ваше фото</h2>
|
||||||
<app-icon name="camera" [size]="22" />
|
<button class="owned-photo" type="button" (click)="openPhoto()">
|
||||||
Забрать
|
<img
|
||||||
</button>
|
[src]="userPhoto() ?? '/assets/illustrations/photo-day.svg'"
|
||||||
<p>Понадобится доступ к камере</p>
|
alt="Ваше фото объекта"
|
||||||
</footer>
|
/>
|
||||||
}
|
<span class="owned-photo__badge">
|
||||||
</article>
|
<app-icon name="check" [size]="14" />
|
||||||
|
Подтверждено
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<p class="object__hint">
|
||||||
|
Этот объект уже в вашей коллекции. Повторно его получить нельзя.
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<a class="object__map" routerLink="/map">
|
||||||
|
<app-icon name="pin" [size]="20" />
|
||||||
|
Показать на карте
|
||||||
|
</a>
|
||||||
|
} @else {
|
||||||
|
<section>
|
||||||
|
<h2>Примеры фото</h2>
|
||||||
|
<div class="photos">
|
||||||
|
@for (photo of photoExamples; track photo.label) {
|
||||||
|
<figure>
|
||||||
|
<img [src]="photo.src" [alt]="photo.label" />
|
||||||
|
<span>{{ photo.label }}</span>
|
||||||
|
</figure>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<p class="object__hint">{{ item.photoHint }}</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>Как забрать</h2>
|
||||||
|
<ol class="steps">
|
||||||
|
<li>Приезжайте на место и найдите объект</li>
|
||||||
|
<li>Нажмите «Забрать» и сфотографируйте объект</li>
|
||||||
|
<li>Получите объект в свою коллекцию</li>
|
||||||
|
</ol>
|
||||||
|
</section>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (!collected()) {
|
||||||
|
<footer class="object__bar">
|
||||||
|
<button class="object__claim" matButton="filled" type="button" (click)="claimItem()">
|
||||||
|
<app-icon name="camera" [size]="22" />
|
||||||
|
Забрать
|
||||||
|
</button>
|
||||||
|
<p>Понадобится доступ к камере</p>
|
||||||
|
</footer>
|
||||||
|
}
|
||||||
|
</article>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (photoOpen()) {
|
@if (photoOpen()) {
|
||||||
@if (userPhoto(); as image) {
|
@if (userPhoto(); as image) {
|
||||||
<div class="photo-viewer" (click)="closePhoto()">
|
<div class="photo-viewer" (click)="closePhoto()">
|
||||||
<button class="photo-viewer__close" type="button" aria-label="Закрыть" (click)="closePhoto()">
|
<button
|
||||||
|
class="photo-viewer__close"
|
||||||
|
type="button"
|
||||||
|
aria-label="Закрыть"
|
||||||
|
(click)="closePhoto()"
|
||||||
|
>
|
||||||
<app-icon name="chevron-left" [size]="22" />
|
<app-icon name="chevron-left" [size]="22" />
|
||||||
</button>
|
</button>
|
||||||
<img [src]="image" alt="Ваше фото объекта" (click)="$event.stopPropagation()" />
|
<img [src]="image" alt="Ваше фото объекта" (click)="$event.stopPropagation()" />
|
||||||
|
|||||||
@@ -78,10 +78,17 @@
|
|||||||
|
|
||||||
.object__intro h1,
|
.object__intro h1,
|
||||||
.object__body h2,
|
.object__body h2,
|
||||||
.facts span {
|
.facts {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: var(--font-display);
|
|
||||||
font-weight: 700;
|
&__number {
|
||||||
|
font-family: var(--font-display);
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__value {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.object__intro h1 {
|
.object__intro h1 {
|
||||||
@@ -220,11 +227,13 @@
|
|||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.facts span {
|
.facts {
|
||||||
min-width: 18px;
|
&__number {
|
||||||
color: var(--color-accent);
|
min-width: 18px;
|
||||||
font-size: 24px;
|
color: var(--color-accent);
|
||||||
line-height: 1;
|
font-size: 24px;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.object__hint {
|
.object__hint {
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
pwa-camera-modal-instance {
|
||||||
|
--inset-width: var(--camera-width);
|
||||||
|
--inset-height: var(--camera-height);
|
||||||
|
}
|
||||||
@@ -140,13 +140,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.city-map__canvas [class*='distribution'],
|
.city-map__canvas :has(> .city-map__marker),
|
||||||
.city-map__canvas [class*='Distribution'],
|
.city-map__canvas :has(> .city-map__user) {
|
||||||
.city-map__canvas .ymaps3--open-maps-button,
|
|
||||||
.city-map__canvas .ymaps3--controls_bottom {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.city-map__canvas :has(> .city-map__marker) {
|
|
||||||
overflow: visible !important;
|
overflow: visible !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,6 @@
|
|||||||
--page-max-width: 560px;
|
--page-max-width: 560px;
|
||||||
--radius-card: 24px;
|
--radius-card: 24px;
|
||||||
--radius-pill: 999px;
|
--radius-pill: 999px;
|
||||||
|
--camera-width: 100%;
|
||||||
|
--camera-height: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,3 +6,4 @@
|
|||||||
@use 'map';
|
@use 'map';
|
||||||
@use 'object';
|
@use 'object';
|
||||||
@use 'collection';
|
@use 'collection';
|
||||||
|
@use 'camera';
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
href="https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600;700&family=Playfair+Display:wght@700&display=swap"
|
href="https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600;700&family=Playfair+Display:wght@700&display=swap"
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
/>
|
/>
|
||||||
<script src="https://api-maps.yandex.ru/v3/?apikey=ea28b13d-e359-4f13-8020-1b492d5ddc8f&lang=ru_RU"></script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<app-root></app-root>
|
<app-root></app-root>
|
||||||
|
|||||||
Reference in New Issue
Block a user