├── .gitignore
├── .npmignore
├── .travis.yml
├── CHANGELOG.md
├── README.md
├── angular.json
├── bs-config.e2e.json
├── e2e
├── protractor.conf.js
├── src
│ ├── app.e2e-spec.ts
│ └── app.po.ts
└── tsconfig.e2e.json
├── non-essential-files.txt
├── package.json
├── projects
└── yamapng
│ ├── README.md
│ ├── karma.conf.js
│ ├── ng-package.json
│ ├── package.json
│ ├── src
│ ├── lib
│ │ ├── core.module.ts
│ │ ├── directives
│ │ │ ├── claster.ts
│ │ │ ├── marker.ts
│ │ │ ├── objectManager.ts
│ │ │ └── ymap.ts
│ │ ├── services
│ │ │ ├── managers
│ │ │ │ ├── claster-manager.ts
│ │ │ │ ├── marker-manager.ts
│ │ │ │ └── objectManager-manager.ts
│ │ │ └── ya-maps-loader.ts
│ │ ├── utils
│ │ │ └── browser-globals.ts
│ │ ├── ya-maps-api-wrapper.ts
│ │ ├── ya-maps-types.ts
│ │ ├── yamapng.component.spec.ts
│ │ ├── yamapng.component.ts
│ │ ├── yamapng.module.ts
│ │ ├── yamapng.service.spec.ts
│ │ └── yamapng.service.ts
│ ├── public_api.ts
│ └── test.ts
│ ├── tsconfig.lib.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── src
├── app
│ ├── app.component.html
│ ├── app.component.spec.ts
│ ├── app.component.styl
│ ├── app.component.ts
│ └── app.module.ts
├── assets
│ └── .gitkeep
├── browserslist
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.html
├── karma.conf.js
├── main.ts
├── polyfills.ts
├── styles.styl
├── test.ts
├── tsconfig.app.json
├── tsconfig.spec.json
└── tslint.json
├── tsconfig.json
├── tslint.json
└── ya-an.png
/.gitignore:
--------------------------------------------------------------------------------
1 | tmp/
2 | node_modules/
3 | dist/
4 | docs/
5 | coverage/
6 | package-lock.json
7 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # Node
2 | node_modules
3 | npm-debug.log
4 |
5 | # Yarn
6 | yarn-error.log
7 |
8 | # JetBrains
9 | .idea/
10 |
11 | # VS Code
12 | .vscode/
13 |
14 | # Windows
15 | Thumbs.db
16 | Desktop.ini
17 |
18 | # Mac
19 | .DS_Store
20 |
21 | # Temporary files
22 | coverage/
23 | demo/
24 | docs
25 | tmp
26 |
27 | # Library files
28 | src/
29 |
30 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: required
2 | dist: trusty
3 | addons:
4 | apt:
5 | sources:
6 | - google-chrome
7 | packages:
8 | - google-chrome-stable
9 | language: node_js
10 | node_js:
11 | - node
12 | script:
13 | - npm run ci
14 | before_script:
15 | - export DISPLAY=:99.0
16 | - sh -e /etc/init.d/xvfb start
17 | - sleep 3
18 | cache:
19 | yarn: true
20 | notifications:
21 | email: false
22 | after_success:
23 | - npm run codecov
24 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## Angular Documentation QuickStart Changelog
2 | Upgraders: for a fresh start, consider running these commands
3 | * `git clean -xdf`
4 | * `npm install`
5 |
6 |
7 | # 0.2.22 (2017-01-05)
8 | * Add `non-essential-files.txt` and instructions to use it to README
9 |
10 |
11 | # 0.2.21 (2016-12-14)
12 | * Update to in-memory-web-api v.0.2.1
13 |
14 |
15 | # 0.2.20 (2016-12-07)
16 | * Update to Angular 2.3.0
17 |
18 |
19 | # 0.2.19 (2016-11-30)
20 | * remove upgrade mappings from `systemjs.config.js` PR #301
21 |
22 |
23 | # 0.2.18 (2016-11-30)
24 | * remove `exclude` clause from `tsconfig.json`; it was just confusing people
25 | * karma.config + karma-test-shim can handle multiple spec source paths (issue #294)
26 | * cosmetic `app.component.spec.ts` changes
27 | * cosmetic `karma.config.js` changes
28 |
29 |
30 | # 0.2.17 (2016-11-16)
31 | * Conform to updated QuickStart advice
32 | * removed docker everywhere (was nice but not necessary)
33 | * removed wallaby
34 | * shrink styles.css
35 | * refine tsconfig.json
36 | * `AppComponent` uses interpolation
37 |
38 |
39 | # 0.2.16 (2016-11-14)
40 | * Update to Angular 2.2.0
41 |
42 |
43 | # 0.2.15 (2016-10-29)
44 | * Revert to Jasmine 2.4.1 because bug in 2.5.x (see [jasmine issue #1231](https://github.com/jasmine/jasmine/issues/1231))
45 |
46 |
47 | # 0.2.14 (2016-10-29)
48 | * Remove bootstrap.css install
49 | * Angular v2.1.2
50 |
51 |
52 | # 0.2.13 (2016-10-20)
53 | * Protractor 4
54 | * Move from `typings` to `@types`. See `tsconfig.json` changes.
55 | * Angular v2.1.1
56 |
57 |
58 | # 0.2.12 (2016-10-06)
59 | * Angular v2.1.0
60 |
61 |
62 | # 0.2.11 (2016-10-06)
63 | * Angular v2.0.2
64 | * License is MIT
65 | * Current testing configuration
66 | * No code changes
67 |
68 |
69 | # 0.2.10 (2016-09-19)
70 | * All "Angular 2" references become just "Angular"
71 | * No code changes
72 |
73 |
74 | # 0.2.9 (2016-09-14)
75 | * Angular 2.0.0 version
76 | * Update to Typescript 2.0.2
77 | * Fix e2e test missing dir
78 |
79 |
80 | # 0.2.8 (2016-09-01)
81 | * remove @angular test libraries from system.js (now in shim)
82 | * update test related files
83 | * wallaby doesn't completely work. Researching.
84 |
85 |
86 | # 0.2.7 (2016-08-31)
87 | * Angular 2 RC6 version
88 | * Updated new forms, router, angular2-in-memory-web-api, karma, core-js, rxjs and zone.js packages
89 | * Removed router-deprecated package
90 | * Updated karma.conf.js and systemjs.config.js
91 |
92 |
93 | # 0.2.6 (2016-08-09)
94 | * Angular 2 RC5 version
95 | * Updated new forms, router and angular2-in-memory-web-api
96 |
97 |
98 | # 0.2.5 (2016-06-30)
99 | * Angular 2 RC4 version
100 | * Updated new forms and router
101 |
102 |
103 | # 0.2.4 (2016-06-21)
104 | * Angular 2 RC3 version
105 | * Add new forms and router
106 | * Add support for TS e2e tests
107 |
108 |
109 | # 0.2.3 (2016-06-15)
110 | * Angular 2 RC2 version
111 |
112 |
113 | # 0.2.2 (2016-05-21)
114 | * Update to Typings 1.x
115 |
116 |
117 | # 0.2.1 (2016-05-03)
118 | * Angular 2 RC01 version
119 |
120 |
121 | # 0.2.0 (2016-05-02)
122 | * Angular 2 RC0 version
123 |
124 |
125 | # 0.1.17 (2016-04-29)
126 | * update packages
127 | * Angular 2 beta 17
128 | * RxJS 5.0.0-beta.6
129 | * a2-in-memory-web-api 0.1.17
130 |
131 |
132 | # 0.1.16 (2016-04-26)
133 | * update packages
134 | * Angular 2 beta 16
135 | * a2-in-memory-web-api 0.1.6
136 | * protractor 3.3.0
137 | * typings 0.8.1
138 | * zone.js 0.6.12
139 |
140 | * added favicon.ico
141 |
142 | * testing
143 | - updated wallaby.js and karma.conf.js
144 | - updated app.component.spec.ts
145 |
146 |
147 |
148 | # 0.1.15 (2016-04-13)
149 | * Add testing support
150 | * npm scripts
151 | * karma/jasmine
152 | * protractor
153 |
154 | * update packages
155 | * Angular 2 beta 15
156 | * lite-server 2.2.0
157 | * systemjs 0.19.26
158 | * typescript 1.8.10
159 | * typings 0.7.12
160 |
161 | * add run packages
162 | * a2-in-memory-web-api
163 |
164 | * add testing dev-dependency packages
165 | * canonical-path: 0.0.2,
166 | * http-server: ^0.9.0,
167 | * jasmine-core: ~2.4.1,
168 | * karma: ^0.13.22,
169 | * karma-chrome-launcher: ^0.2.3,
170 | * karma-cli: ^0.1.2,
171 | * karma-htmlfile-reporter: ^0.2.2,
172 | * karma-jasmine: ^0.3.8,
173 | * protractor: ^3.2.2,
174 | * rimraf: ^2.5.2
175 |
176 |
177 | # 0.1.14 (2016-04-07)
178 | * update packages
179 | * Angular 2 beta 14
180 | * lite-server 2.2.0
181 | * typings 0.7.12
182 |
183 |
184 | # 0.1.13 (2016-03-31)
185 | * update packages
186 | * Angular 2 beta 13
187 |
188 |
189 | # 0.1.12 (2016-03-23)
190 | * update packages
191 | * Angular 2 beta 12
192 | * zones 0.6.6
193 | * remove es6-promise because no longer needed.
194 |
195 |
196 | # 0.1.11 (2016-03-18)
197 | * update packages
198 | * Angular 2 beta 11
199 | * zones 0.6.4
200 | * typescript 1.8.9
201 | * typings 0.7.9
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [Angular2]: https://angular.io/
2 |
3 | Читайте мой блог на medium https://ashatilovdev.medium.com/
4 |
5 | 
6 | #### Yandex Maps API as an Angular2 components
7 |
8 | [Wiki](https://github.com/AnteaterKit/angular2-yandex-maps/wiki)
9 |
10 |
11 |
12 | [](http://badge.fury.io/js/yamapng)
13 | [](https://www.npmjs.com/package/yamapng)
14 |
15 |
16 | #### Live Demo Plnkr
17 | #### Добавление маркеров admin panel
18 | https://plnkr.co/edit/djaxM0nKECMynWLJwmjO?p=preview
19 | #### Работа с большим числом объектов через ObjectManager
20 | https://plnkr.co/edit/mq8VzzINPYXOInPOS2mQ?p=preview
21 | #### Простая метка с balloon
22 | https://plnkr.co/edit/2m3qE90MxPghI9DKjML6?p=preview
23 | #### ngFor метки draggable
24 | https://plnkr.co/edit/8njMNbV9vjYTSfyP3fxI?p=preview
25 | #### Изменение позиций карты
26 | https://plnkr.co/edit/9K1fAZbpgDDoZYUfIdVo?p=preview
27 | #### Кластеры
28 | https://plnkr.co/edit/rpJpm8FnWWsuJoScAFAN?p=preview
29 | #### Изменение иконок
30 | https://plnkr.co/edit/dm8EJt8Waa61yKsZRRrM?p=preview
31 |
32 | #### Install
33 | ```bash
34 | npm i yamapng
35 | ```
36 |
37 | #### imports
38 | ```
39 | @NgModule({
40 | declarations: [
41 | AppComponent
42 | ],
43 | imports: [
44 | BrowserModule,
45 | YamapngModule,
46 | YaCoreModule.forRoot({
47 | apiKey: 'YOUR_KEY'
48 | })
49 | ],
50 | providers: [],
51 | bootstrap: [AppComponent]
52 | })
53 | ```
54 |
55 | ### API
56 |
57 | #### Тег ya-map & ya-marker:
58 | ```html
59 |
60 |
61 |
62 |
63 |
64 |
65 | ```
66 | Style.css
67 | ```
68 | .map-container-inner
69 | {
70 | width: 300px;
71 | height: 200px;
72 | }
73 | ```
74 |
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "ymapng": {
7 | "root": "",
8 | "sourceRoot": "src",
9 | "projectType": "application",
10 | "prefix": "app",
11 | "schematics": {
12 | "@schematics/angular:component": {
13 | "styleext": "styl"
14 | }
15 | },
16 | "architect": {
17 | "build": {
18 | "builder": "@angular-devkit/build-angular:browser",
19 | "options": {
20 | "outputPath": "dist/ymapng",
21 | "index": "src/index.html",
22 | "main": "src/main.ts",
23 | "polyfills": "src/polyfills.ts",
24 | "tsConfig": "src/tsconfig.app.json",
25 | "assets": [
26 | "src/favicon.ico",
27 | "src/assets"
28 | ],
29 | "styles": [
30 | "src/styles.styl"
31 | ],
32 | "scripts": []
33 | },
34 | "configurations": {
35 | "production": {
36 | "fileReplacements": [
37 | {
38 | "replace": "src/environments/environment.ts",
39 | "with": "src/environments/environment.prod.ts"
40 | }
41 | ],
42 | "optimization": true,
43 | "outputHashing": "all",
44 | "sourceMap": false,
45 | "extractCss": true,
46 | "namedChunks": false,
47 | "aot": true,
48 | "extractLicenses": true,
49 | "vendorChunk": false,
50 | "buildOptimizer": true,
51 | "budgets": [
52 | {
53 | "type": "initial",
54 | "maximumWarning": "2mb",
55 | "maximumError": "5mb"
56 | }
57 | ]
58 | }
59 | }
60 | },
61 | "serve": {
62 | "builder": "@angular-devkit/build-angular:dev-server",
63 | "options": {
64 | "browserTarget": "ymapng:build"
65 | },
66 | "configurations": {
67 | "production": {
68 | "browserTarget": "ymapng:build:production"
69 | }
70 | }
71 | },
72 | "extract-i18n": {
73 | "builder": "@angular-devkit/build-angular:extract-i18n",
74 | "options": {
75 | "browserTarget": "ymapng:build"
76 | }
77 | },
78 | "test": {
79 | "builder": "@angular-devkit/build-angular:karma",
80 | "options": {
81 | "main": "src/test.ts",
82 | "polyfills": "src/polyfills.ts",
83 | "tsConfig": "src/tsconfig.spec.json",
84 | "karmaConfig": "src/karma.conf.js",
85 | "styles": [
86 | "src/styles.styl"
87 | ],
88 | "scripts": [],
89 | "assets": [
90 | "src/favicon.ico",
91 | "src/assets"
92 | ]
93 | }
94 | },
95 | "lint": {
96 | "builder": "@angular-devkit/build-angular:tslint",
97 | "options": {
98 | "tsConfig": [
99 | "src/tsconfig.app.json",
100 | "src/tsconfig.spec.json"
101 | ],
102 | "exclude": [
103 | "**/node_modules/**"
104 | ]
105 | }
106 | }
107 | }
108 | },
109 | "ymapng-e2e": {
110 | "root": "e2e/",
111 | "projectType": "application",
112 | "prefix": "",
113 | "architect": {
114 | "e2e": {
115 | "builder": "@angular-devkit/build-angular:protractor",
116 | "options": {
117 | "protractorConfig": "e2e/protractor.conf.js",
118 | "devServerTarget": "ymapng:serve"
119 | },
120 | "configurations": {
121 | "production": {
122 | "devServerTarget": "ymapng:serve:production"
123 | }
124 | }
125 | },
126 | "lint": {
127 | "builder": "@angular-devkit/build-angular:tslint",
128 | "options": {
129 | "tsConfig": "e2e/tsconfig.e2e.json",
130 | "exclude": [
131 | "**/node_modules/**"
132 | ]
133 | }
134 | }
135 | }
136 | },
137 | "yamapng": {
138 | "root": "projects/yamapng",
139 | "sourceRoot": "projects/yamapng/src",
140 | "projectType": "library",
141 | "prefix": "lib",
142 | "architect": {
143 | "build": {
144 | "builder": "@angular-devkit/build-ng-packagr:build",
145 | "options": {
146 | "tsConfig": "projects/yamapng/tsconfig.lib.json",
147 | "project": "projects/yamapng/ng-package.json"
148 | }
149 | },
150 | "test": {
151 | "builder": "@angular-devkit/build-angular:karma",
152 | "options": {
153 | "main": "projects/yamapng/src/test.ts",
154 | "tsConfig": "projects/yamapng/tsconfig.spec.json",
155 | "karmaConfig": "projects/yamapng/karma.conf.js"
156 | }
157 | },
158 | "lint": {
159 | "builder": "@angular-devkit/build-angular:tslint",
160 | "options": {
161 | "tsConfig": [
162 | "projects/yamapng/tsconfig.lib.json",
163 | "projects/yamapng/tsconfig.spec.json"
164 | ],
165 | "exclude": [
166 | "**/node_modules/**"
167 | ]
168 | }
169 | }
170 | }
171 | }
172 | },
173 | "defaultProject": "ymapng"
174 | }
--------------------------------------------------------------------------------
/bs-config.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "open": false,
3 | "logLevel": "silent",
4 | "port": 8080,
5 | "server": {
6 | "baseDir": "src",
7 | "routes": {
8 | "/node_modules": "node_modules"
9 | },
10 | "middleware": {
11 | "0": null
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/e2e/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './src/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: require('path').join(__dirname, './tsconfig.e2e.json')
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
--------------------------------------------------------------------------------
/e2e/src/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 |
3 | describe('workspace-project App', () => {
4 | let page: AppPage;
5 |
6 | beforeEach(() => {
7 | page = new AppPage();
8 | });
9 |
10 | it('should display welcome message', () => {
11 | page.navigateTo();
12 | expect(page.getTitleText()).toEqual('Welcome to ymapng!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/e2e/src/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getTitleText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "jasminewd2",
10 | "node"
11 | ]
12 | }
13 | }
--------------------------------------------------------------------------------
/non-essential-files.txt:
--------------------------------------------------------------------------------
1 | .git
2 | .gitignore
3 | .travis.yml
4 | *.spec*.ts
5 | bs-config.e2e.json
6 | CHANGELOG.md
7 | e2e
8 | favicon.ico
9 | karma.conf.js
10 | karma-test-shim.js
11 | LICENSE
12 | non-essential-files.txt
13 | non-essential-files.osx.txt
14 | protractor.config.js
15 | README.md
16 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ymapng",
3 | "version": "0.0.0",
4 | "scripts": {
5 | "ng": "ng",
6 | "start": "ng serve",
7 | "build": "ng build",
8 | "test": "ng test",
9 | "lint": "ng lint",
10 | "e2e": "ng e2e"
11 | },
12 | "private": true,
13 | "dependencies": {
14 | "@angular/animations": "~7.1.0",
15 | "@angular/common": "~7.1.0",
16 | "@angular/compiler": "~7.1.0",
17 | "@angular/core": "~7.1.0",
18 | "@angular/forms": "~7.1.0",
19 | "@angular/platform-browser": "~7.1.0",
20 | "@angular/platform-browser-dynamic": "~7.1.0",
21 | "@angular/router": "~7.1.0",
22 | "core-js": "^2.5.4",
23 | "rxjs": "~6.3.3",
24 | "tslib": "^1.9.0",
25 | "zone.js": "~0.8.26"
26 | },
27 | "devDependencies": {
28 | "@angular-devkit/build-angular": "~0.11.0",
29 | "@angular-devkit/build-ng-packagr": "~0.11.0",
30 | "@angular/cli": "~7.1.0",
31 | "@angular/compiler-cli": "~7.1.0",
32 | "@angular/language-service": "~7.1.0",
33 | "@types/node": "~8.9.4",
34 | "@types/jasmine": "~2.8.8",
35 | "@types/jasminewd2": "~2.0.3",
36 | "codelyzer": "~4.5.0",
37 | "jasmine-core": "~2.99.1",
38 | "jasmine-spec-reporter": "~4.2.1",
39 | "karma": "~3.1.1",
40 | "karma-chrome-launcher": "~2.2.0",
41 | "karma-coverage-istanbul-reporter": "~2.0.1",
42 | "karma-jasmine": "~1.1.2",
43 | "karma-jasmine-html-reporter": "^0.2.2",
44 | "ng-packagr": "^4.2.0",
45 | "protractor": "~5.4.0",
46 | "ts-node": "~7.0.0",
47 | "tsickle": ">=0.29.0",
48 | "tslib": "^1.9.0",
49 | "tslint": "~5.11.0",
50 | "typescript": "~3.1.6"
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/projects/yamapng/README.md:
--------------------------------------------------------------------------------
1 | [Angular2]: https://angular.io/
2 |
3 | 
4 | #### Yandex Maps API as an Angular2 components
5 |
6 | [Wiki](https://github.com/AnteaterKit/angular2-yandex-maps/wiki)
7 |
8 |
9 |
10 | [](http://badge.fury.io/js/yamapng)
11 | [](https://www.npmjs.com/package/yamapng)
12 |
13 |
14 | #### Live Demo Plnkr
15 | #### Добавление маркеров admin panel
16 | https://plnkr.co/edit/djaxM0nKECMynWLJwmjO?p=preview
17 | #### Работа с большим числом объектов через ObjectManager
18 | https://plnkr.co/edit/mq8VzzINPYXOInPOS2mQ?p=preview
19 | #### Простая метка с balloon
20 | https://plnkr.co/edit/2m3qE90MxPghI9DKjML6?p=preview
21 | #### ngFor метки draggable
22 | https://plnkr.co/edit/8njMNbV9vjYTSfyP3fxI?p=preview
23 | #### Изменение позиций карты
24 | https://plnkr.co/edit/9K1fAZbpgDDoZYUfIdVo?p=preview
25 | #### Кластеры
26 | https://plnkr.co/edit/rpJpm8FnWWsuJoScAFAN?p=preview
27 | #### Изменение иконок
28 | https://plnkr.co/edit/dm8EJt8Waa61yKsZRRrM?p=preview
29 |
30 | #### Install
31 | ```bash
32 | npm i yamapng
33 | ```
34 |
35 | #### imports
36 | ```
37 | @NgModule({
38 | declarations: [
39 | AppComponent
40 | ],
41 | imports: [
42 | BrowserModule,
43 | YamapngModule,
44 | YaCoreModule.forRoot({
45 | apiKey: 'YOUR_KEY'
46 | })
47 | ],
48 | providers: [],
49 | bootstrap: [AppComponent]
50 | })
51 | ```
52 |
53 | ### API
54 |
55 | #### Тег ya-map & ya-marker:
56 | ```html
57 |
58 |
59 |
60 |
61 |
62 |
63 | ```
64 | Style.css
65 | ```
66 | .map-container-inner
67 | {
68 | width: 300px;
69 | height: 200px;
70 | }
71 | ```
72 |
--------------------------------------------------------------------------------
/projects/yamapng/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, '../../coverage'),
20 | reports: ['html', 'lcovonly'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false
30 | });
31 | };
32 |
--------------------------------------------------------------------------------
/projects/yamapng/ng-package.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3 | "dest": "../../dist/yamapng",
4 | "lib": {
5 | "entryFile": "src/public_api.ts"
6 | }
7 | }
--------------------------------------------------------------------------------
/projects/yamapng/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "yamapng",
3 | "version": "2.0.4",
4 | "readme": "README.md",
5 | "description": "yandex-maps-directive",
6 |
7 | "peerDependencies": {
8 | "@angular/common": "^7.1.0",
9 | "@angular/core": "^7.1.0"
10 | }
11 | }
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/core.module.ts:
--------------------------------------------------------------------------------
1 | import { ModuleWithProviders, NgModule } from '@angular/core';
2 | import { YaMarker } from './directives/marker';
3 | import { YaClaster } from './directives/claster';
4 | import { YaObjectManager } from './directives/objectManager';
5 | import { YaMapsAPILoader, YaMapsAPILoaderConfigLiteral, LAZY_MAPS_API_CONFIG } from './services/ya-maps-loader';
6 | import { BROWSER_GLOBALS_PROVIDERS } from './utils/browser-globals';
7 | import { YaMap } from './directives/ymap';
8 |
9 | export * from './ya-maps-types';
10 |
11 | /**
12 | * @internal
13 | */
14 | export function coreDirectives() {
15 | return [
16 | YaMap,
17 | YaMarker,
18 | YaClaster,
19 | YaObjectManager
20 | ];
21 | }
22 |
23 | /**
24 | * The angular-ya-maps core module. Contains all Directives/Services/Pipes
25 | * of the core module. Please use `YaCoreModule.forRoot()` in your app module.
26 | */
27 | @NgModule({ declarations: coreDirectives(), exports: coreDirectives() })
28 | export class YaCoreModule {
29 | /**
30 | * Please use this method when you register the module at the root level.
31 | */
32 | public static forRoot(yaMapsAPILoaderConfig: YaMapsAPILoaderConfigLiteral): ModuleWithProviders {
33 | return {
34 | ngModule: YaCoreModule,
35 | providers: [
36 | ...BROWSER_GLOBALS_PROVIDERS,
37 | { provide: YaMapsAPILoader, useClass: YaMapsAPILoader },
38 | { provide: LAZY_MAPS_API_CONFIG, useValue: yaMapsAPILoaderConfig }
39 | ],
40 | };
41 | }
42 | }
43 |
44 | export function YaCoreModuleForRoot(yaMapsAPILoaderConfig: YaMapsAPILoaderConfigLiteral) {
45 | return [
46 | YaCoreModule.forRoot(yaMapsAPILoaderConfig)
47 | ];
48 | }
49 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/directives/claster.ts:
--------------------------------------------------------------------------------
1 | import {
2 | Directive,
3 | EventEmitter,
4 | OnChanges,
5 | OnDestroy,
6 | SimpleChange,
7 | AfterContentInit,
8 | ContentChildren,
9 | QueryList,
10 | Input } from '@angular/core';
11 |
12 | import { YaMapsAPIWrapper } from '../ya-maps-api-wrapper';
13 | import * as mapTypes from '../ya-maps-types';
14 | import { ClasterManager } from '../services/managers/claster-manager';
15 | import { Claster, MarkerClaster } from '../ya-maps-types';
16 |
17 | let clasterId = 0;
18 |
19 | @Directive({
20 | // tslint:disable-next-line:directive-selector
21 | selector: 'ya-claster',
22 | providers: [
23 | YaMapsAPIWrapper
24 | ]
25 | })
26 |
27 | // tslint:disable-next-line:directive-class-suffix
28 | export class YaClaster implements OnChanges, OnDestroy {
29 | @Input() public markers: any[];
30 |
31 | private _id: string;
32 | private _markerAddedToManger = false;
33 |
34 | constructor(private _clasterManager: ClasterManager) {
35 | this._id = (clasterId++).toString();
36 | }
37 |
38 | public ngOnChanges(changes: { [key: string]: SimpleChange }) {
39 | if (!this._markerAddedToManger) {
40 | this._clasterManager.addClaster(this);
41 | }
42 | }
43 |
44 | public ngOnDestroy() { }
45 |
46 | private _addEventListeners() { }
47 | }
48 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/directives/marker.ts:
--------------------------------------------------------------------------------
1 | import { Directive, EventEmitter, OnChanges, OnDestroy, SimpleChange, Input, Output } from '@angular/core';
2 |
3 | import { YaMapsAPIWrapper } from '../ya-maps-api-wrapper';
4 | import * as mapTypes from '../ya-maps-types';
5 | import { MarkerManager } from '../services/managers/marker-manager';
6 | import { Marker } from '../ya-maps-types';
7 | import { Subscription } from 'rxjs';
8 |
9 | let markerId = 0;
10 |
11 | @Directive({
12 | // tslint:disable-next-line:directive-selector
13 | selector: 'ya-marker',
14 | providers: [
15 | YaMapsAPIWrapper
16 | ]
17 | })
18 |
19 | // tslint:disable-next-line:directive-class-suffix
20 | export class YaMarker implements OnChanges, OnDestroy {
21 | @Input() public latitude: number;
22 | @Input() public longitude: number;
23 | @Input() public balloonLayout: any;
24 | @Input() public balloonContentHeader: string;
25 | @Input() public balloonContentBody: string;
26 | @Input() public balloonContentFooter: string;
27 | @Input() public draggable = false;
28 | @Input() public preset = 'islands#blueIcon';
29 | @Input() public iconContent: string;
30 | @Input() public showInfo: boolean;
31 | // default#image
32 | @Input() public iconLayout: any;
33 | @Input() public iconImageHref: any;
34 | // [30, 42]
35 | @Input() public iconImageSize: any;
36 | // [-5, -38]
37 | @Input() public iconImageOffset: any;
38 |
39 | @Output() public markerClick: EventEmitter = new EventEmitter();
40 | // tslint:disable-next-line:max-line-length
41 | @Output() public dragEnd: EventEmitter = new EventEmitter();
42 |
43 | private _markerAddedToManger = false;
44 | private _id: string;
45 | private _observableSubscriptions: Subscription[] = [];
46 |
47 | constructor(private _markerManager: MarkerManager) {
48 | this._id = (markerId++).toString();
49 | }
50 |
51 | public ngOnChanges(changes: { [key: string]: SimpleChange }) {
52 | if (!this._markerAddedToManger) {
53 |
54 | this._markerManager.addMarker(this);
55 | this._markerAddedToManger = true;
56 | this._addEventListeners();
57 | return;
58 | }
59 | if (changes['showInfo']) {
60 | this._markerManager.showBalloon(this);
61 | }
62 | }
63 |
64 | public ngOnDestroy() {
65 | this._markerManager.deleteMarker(this);
66 | this._observableSubscriptions.forEach((s) => s.unsubscribe());
67 | }
68 |
69 | private _addEventListeners() {
70 | // click event
71 | const cs = this._markerManager.createEventObservable('click', this).subscribe(() => {
72 | this._markerManager.showBalloon(this);
73 | this.markerClick.emit(null);
74 | });
75 | this._observableSubscriptions.push(cs);
76 | // dragend event
77 | // tslint:disable-next-line:max-line-length
78 | const ds = this._markerManager.createEventObservable('dragend', this).subscribe((e: mapTypes.MouseEvent) => {
79 |
80 | const thisPlacemark = e.get('target');
81 | const coords = thisPlacemark.geometry.getCoordinates();
82 | this._markerManager.getNativeMarker(this).then((m: Marker) => {
83 | // tslint:disable-next-line:max-line-length
84 | this.dragEnd.emit({ lat: coords[0], lng: coords[1], nativeMarker: m } as mapTypes.MapMouseEvent);
85 | });
86 | });
87 | this._observableSubscriptions.push(ds);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/directives/objectManager.ts:
--------------------------------------------------------------------------------
1 | import {
2 | Directive, EventEmitter, OnChanges, OnDestroy, SimpleChange,
3 | AfterContentInit, ContentChildren, QueryList, Input
4 | } from '@angular/core';
5 | import { Subscription } from 'rxjs';
6 |
7 | import { YaMapsAPIWrapper } from '../ya-maps-api-wrapper';
8 | import * as mapTypes from '../ya-maps-types';
9 | import { ObjectManagerManager } from '../services/managers/objectManager-manager';
10 |
11 | let markerId = 0;
12 |
13 | @Directive({
14 | // tslint:disable-next-line:directive-selector
15 | selector: 'ya-object-manager',
16 | providers: [
17 | YaMapsAPIWrapper
18 | ]
19 | })
20 |
21 | // tslint:disable-next-line:directive-class-suffix
22 | export class YaObjectManager implements OnChanges {
23 | @Input() public clusterize = false;
24 | @Input() public datasource: any;
25 | @Input() public clasterPreset = 'islands#blueIcon';
26 | @Input() public objectPreset = 'islands#blueClusterIcons';
27 | @Input() public gridSize = 0;
28 | @Input() public selectedObjectId: number;
29 | @Input() public filter: any;
30 |
31 | private _id: string;
32 | private _observableSubscriptions: Subscription[] = [];
33 | private _addedToManger = false;
34 |
35 | constructor(private _manager: ObjectManagerManager) {
36 | this._id = (markerId++).toString();
37 | }
38 |
39 | public ngOnChanges(changes: { [key: string]: SimpleChange }) {
40 | if (!this._addedToManger) {
41 |
42 | this._manager.add(this);
43 | this._addedToManger = true;
44 | return;
45 | }
46 |
47 | if (changes['selectedObjectId']) {
48 | this._manager.navigateToGeoObject(this, this.selectedObjectId);
49 | }
50 | if (changes['filter']) {
51 | this._manager.setFilter(this, this.filter);
52 | }
53 |
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/directives/ymap.ts:
--------------------------------------------------------------------------------
1 | import {
2 | Component,
3 | ElementRef,
4 | EventEmitter,
5 | OnChanges,
6 | OnDestroy,
7 | OnInit,
8 | SimpleChanges,
9 | Input,
10 | Output } from '@angular/core';
11 | import { Subscription } from 'rxjs';
12 |
13 | import { YaMapsAPIWrapper } from '../ya-maps-api-wrapper';
14 | import { MarkerManager } from '../services/managers/marker-manager';
15 | import { ClasterManager } from '../services/managers/claster-manager';
16 | import { ObjectManagerManager } from '../services/managers/objectManager-manager';
17 | import * as mapTypes from '../ya-maps-types';
18 |
19 | @Component({
20 | // tslint:disable-next-line:component-selector
21 | selector: 'ya-map',
22 | providers: [
23 | YaMapsAPIWrapper,
24 | MarkerManager,
25 | ClasterManager,
26 | ObjectManagerManager
27 | ],
28 | template: `
29 |
30 |
31 |
32 | `
33 | })
34 | // tslint:disable-next-line:component-class-suffix
35 | export class YaMap implements OnInit, OnChanges {
36 |
37 | @Input() public longitude = 0;
38 | @Input() public latitude = 0;
39 | @Input() public zoom = 8;
40 | @Input() public minZoom: number;
41 | @Input() public maxZoom: number;
42 | @Input() public mapType: any = 'yandex#map';
43 | @Input() public controls: any[] = null;
44 | @Input() public panToObjects: mapTypes.PanToObjects;
45 | // tslint:disable-next-line:max-line-length
46 | @Output() public mapClick: EventEmitter = new EventEmitter();
47 | @Output() public actionTick: EventEmitter = new EventEmitter();
48 |
49 | public mapInit = false;
50 |
51 | private _observableSubscriptions: Subscription[] = [];
52 |
53 | constructor(private _elem: ElementRef, private _mapsWrapper: YaMapsAPIWrapper) { }
54 |
55 | public ngOnInit() {
56 | console.log('map iit');
57 | const container = this._elem.nativeElement.querySelector('.map-container-inner');
58 | this._initMapInstance(container);
59 | this.mapInit = true;
60 | }
61 |
62 | public ngOnChanges(changes: SimpleChanges) {
63 | if (this.mapInit) {
64 | this.updatePosition(changes);
65 | this.panTo(changes);
66 | }
67 | }
68 |
69 | private _initMapInstance(el: HTMLElement) {
70 | if (this.controls != null) {
71 | this._mapsWrapper.createMap(el, {
72 | center: [this.latitude, this.longitude], zoom: this.zoom, type: this.mapType,
73 | controls: this.controls
74 | });
75 |
76 | } else {
77 | this._mapsWrapper.createMap(el, {
78 | center: [this.latitude, this.longitude], zoom: this.zoom, type: this.mapType
79 | });
80 |
81 | }
82 |
83 | this._handleMapMouseEvents();
84 | }
85 |
86 | private updatePosition(changes: SimpleChanges) {
87 | if (changes['latitude'] == null && changes['longitude'] == null) {
88 | return;
89 | }
90 | this._mapsWrapper.setCenter(this.latitude, this.longitude);
91 | }
92 |
93 | private panTo(changes: SimpleChanges) {
94 | if (changes['panToObjects'] == null) {
95 | return;
96 | }
97 | this._mapsWrapper.panTo(this.panToObjects.points, this.panToObjects.params);
98 | }
99 |
100 | private _handleMapMouseEvents() {
101 | interface Emitter {
102 | emit(value: any): void;
103 | }
104 | interface Event { name: string; emitter: Emitter; }
105 |
106 | const clickEvents: Event[] = [
107 | { name: 'click', emitter: this.mapClick }
108 | ];
109 | const events: Event[] = [
110 | { name: 'actiontick', emitter: this.actionTick }
111 | ];
112 |
113 | clickEvents.forEach((e: Event) => {
114 | const s = this._mapsWrapper.subscribeToMapEvent<{ latLng: any }>(e.name).subscribe(
115 | (event: any) => {
116 | const coords = event.get('coords');
117 | const value = { lat: coords[0], lng: coords[1] } as mapTypes.MapClickMouseEvent;
118 | e.emitter.emit(value);
119 | });
120 | this._observableSubscriptions.push(s);
121 | });
122 |
123 | events.forEach((e: Event) => {
124 | const s = this._mapsWrapper.subscribeToMapEvent<{ latLng: any }>(e.name).subscribe(
125 | (event: any) => {
126 |
127 | this._mapsWrapper.getCenter().then((coords: any) => {
128 | this.latitude = coords[0];
129 | this.longitude = coords[1];
130 | const value = { lat: coords[0], lng: coords[1] } as mapTypes.MapClickMouseEvent;
131 | e.emitter.emit(value);
132 | });
133 |
134 | });
135 | this._observableSubscriptions.push(s);
136 | });
137 |
138 | }
139 | }
140 |
141 | import { NgModule } from '@angular/core';
142 |
143 |
144 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/services/managers/claster-manager.ts:
--------------------------------------------------------------------------------
1 | import { Injectable, NgZone } from '@angular/core';
2 | import { Observable } from 'rxjs';
3 | import { Observer } from 'rxjs';
4 |
5 | import { YaClaster } from './../../directives/claster';
6 | import { YaMapsAPIWrapper } from '../../ya-maps-api-wrapper';
7 | import { MarkerClaster, Claster } from '../../ya-maps-types';
8 |
9 | @Injectable()
10 | export class ClasterManager {
11 | private _clasters: Map> =
12 | new Map>();
13 |
14 | constructor(private _mapsWrapper: YaMapsAPIWrapper, private _zone: NgZone) { }
15 |
16 | public addClaster(claster: YaClaster) {
17 | const clasterPromise = this._mapsWrapper.createClaster(claster);
18 | this._clasters.set(claster, clasterPromise);
19 | }
20 |
21 | /* getNativeMarker(marker: YaMarker): Promise {
22 | return this._markers.get(marker);
23 | }
24 | createEventObservable(eventName: string, marker: YaMarker): Observable {
25 | return Observable.create((observer: Observer) => {
26 | this._markers.get(marker).then((m: Marker) => {
27 | m.events.add(eventName, (e: T) => this._zone.run(() => observer.next(e)));
28 | });
29 | });
30 | }
31 | */
32 | }
33 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/services/managers/marker-manager.ts:
--------------------------------------------------------------------------------
1 | import { Injectable, NgZone } from '@angular/core';
2 | import { Observable } from 'rxjs';
3 | import { Observer } from 'rxjs';
4 |
5 | import { YaMarker } from './../../directives/marker';
6 |
7 | import { YaMapsAPIWrapper } from '../../ya-maps-api-wrapper';
8 | import { Marker } from '../../ya-maps-types';
9 |
10 | @Injectable()
11 | export class MarkerManager {
12 | private _markers: Map> =
13 | new Map>();
14 |
15 | constructor(private _mapsWrapper: YaMapsAPIWrapper, private _zone: NgZone) { }
16 |
17 | public deleteMarker(marker: YaMarker): Promise {
18 | const m = this._markers.get(marker);
19 | if (m == null) {
20 | return Promise.resolve();
21 | }
22 | // tslint:disable-next-line:no-shadowed-variable
23 | return m.then((m: Marker) => {
24 | return this._zone.run(() => {
25 | // tslint:disable-next-line:no-shadowed-variable
26 | this.getNativeMarker(marker).then((m: Marker) => {
27 | this._mapsWrapper.removeGeo(m);
28 | this._markers.delete(marker);
29 | });
30 | });
31 | });
32 | }
33 |
34 | public addMarker(marker: YaMarker) {
35 | const markerPromise = this._mapsWrapper.createMarker(marker);
36 | this._markers.set(marker, markerPromise);
37 | }
38 |
39 | public showBalloon(marker: YaMarker) {
40 | this.getNativeMarker(marker).then((m: Marker) => {
41 | m.balloon.open();
42 | });
43 |
44 | }
45 |
46 | public getNativeMarker(marker: YaMarker): Promise {
47 | return this._markers.get(marker);
48 | }
49 |
50 | public createEventObservable(eventName: string, marker: YaMarker): Observable {
51 | return Observable.create((observer: Observer) => {
52 | this._markers.get(marker).then((m: Marker) => {
53 | m.events.add(eventName, (e: T) => this._zone.run(() => observer.next(e)));
54 | });
55 | });
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/services/managers/objectManager-manager.ts:
--------------------------------------------------------------------------------
1 | import { Injectable, NgZone } from '@angular/core';
2 | import { Observable } from 'rxjs';
3 | import { Observer } from 'rxjs';
4 |
5 | import { YaObjectManager } from './../../directives/objectManager';
6 | import { YaMapsAPIWrapper } from '../../ya-maps-api-wrapper';
7 | import { ObjectManager } from '../../ya-maps-types';
8 |
9 | @Injectable()
10 | export class ObjectManagerManager {
11 | private _managers: Map> =
12 | new Map>();
13 |
14 | constructor(private _mapsWrapper: YaMapsAPIWrapper, private _zone: NgZone) { }
15 |
16 | public add(manager: YaObjectManager) {
17 | const managerPromise = this._mapsWrapper.createObjectManager(manager);
18 | this._managers.set(manager, managerPromise);
19 | }
20 |
21 | public navigateToGeoObject(manager: YaObjectManager, id: number) {
22 | this.getNativeManager(manager).then((p: any) => {
23 | this._mapsWrapper.navigateToGeoObject(p, id);
24 | });
25 |
26 | }
27 |
28 | public getNativeManager(manager: YaObjectManager): Promise {
29 | return this._managers.get(manager);
30 | }
31 |
32 | public setFilter(manager: YaObjectManager, filter: any) {
33 | this.getNativeManager(manager).then((p: any) => {
34 | this._mapsWrapper.objectManagerSetFilter(p, filter);
35 | });
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/services/ya-maps-loader.ts:
--------------------------------------------------------------------------------
1 | import { Inject, Injectable, InjectionToken, Optional } from '@angular/core';
2 | import { DocumentRef, WindowRef } from './../utils/browser-globals';
3 |
4 | /**
5 | * Token for the config of the YaMapsAPILoaderConfigLiteral. Please provide an object of type {@link
6 | * YaMapsAPILoaderConfigLiteral}.
7 | */
8 | export const LAZY_MAPS_API_CONFIG = new InjectionToken('angular-ya-maps MAPS_API_CONFIG');
9 |
10 | /**
11 | * Configuration for the {@link LazyMapsAPILoader}.
12 | */
13 | export interface YaMapsAPILoaderConfigLiteral {
14 | /**
15 | * API Key.
16 | */
17 | apiKey?: string;
18 | }
19 |
20 | @Injectable()
21 | export class YaMapsAPILoader {
22 | private _scriptLoadingPromise: Promise;
23 | private config: YaMapsAPILoaderConfigLiteral;
24 | private _windowRef: WindowRef;
25 | private _documentRef: DocumentRef;
26 |
27 | constructor(@Optional() @Inject(LAZY_MAPS_API_CONFIG) config: any = null, w: WindowRef, d: DocumentRef) {
28 | this.config = config;
29 | this._windowRef = w;
30 | this._documentRef = d;
31 | }
32 |
33 | public load(): Promise {
34 | const script = this._documentRef.getNativeDocument().createElement('script');
35 | script.type = 'text/javascript';
36 | script.async = false;
37 | script.defer = true;
38 | script.id = 'YaScript';
39 | const callbackName = `angular2YAMapsAPILoader`;
40 | script.src = `https://api-maps.yandex.ru/2.1/?apikey=${this.config.apiKey}&lang=ru_RU`;
41 | // tslint:disable-next-line:ban-types
42 | this._scriptLoadingPromise = new Promise((resolve: Function, reject: Function) => {
43 | script.onload = () => { resolve(); };
44 | script.onerror = (error: Event) => { reject(); };
45 | });
46 | this._documentRef.getNativeDocument().body.appendChild(script);
47 | return this._scriptLoadingPromise;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/utils/browser-globals.ts:
--------------------------------------------------------------------------------
1 | import { Provider } from '@angular/core';
2 |
3 | export class WindowRef {
4 | public getNativeWindow(): any { return window; }
5 | }
6 |
7 | // tslint:disable-next-line:max-classes-per-file
8 | export class DocumentRef {
9 |
10 | public getNativeDocument(): any {
11 | return document;
12 | }
13 |
14 | }
15 |
16 | export const BROWSER_GLOBALS_PROVIDERS: Provider[] = [WindowRef, DocumentRef];
17 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/ya-maps-api-wrapper.ts:
--------------------------------------------------------------------------------
1 | import { Injectable, NgZone } from '@angular/core';
2 | import { Observable } from 'rxjs';
3 | import { Observer } from 'rxjs';
4 |
5 | import * as mapTypes from './ya-maps-types';
6 | import { YaMapsAPILoader } from './services/ya-maps-loader';
7 | import { YaMarker } from './directives/marker';
8 | import { YaClaster } from './directives/claster';
9 | import { YaObjectManager } from './directives/objectManager';
10 | import { DocumentRef, WindowRef } from './utils/browser-globals';
11 |
12 | declare var ymaps: any;
13 |
14 | @Injectable()
15 | export class YaMapsAPIWrapper {
16 | private _map: Promise;
17 | private _mapResolver: (value?: mapTypes.YandexMap) => void;
18 | private _documentRef: DocumentRef;
19 |
20 | constructor(private _loader: YaMapsAPILoader, private _zone: NgZone, d: DocumentRef) {
21 | this._documentRef = d;
22 | this._map = new Promise((resolve: () => void) => {
23 | this._mapResolver = resolve;
24 | });
25 | }
26 |
27 | public createMap(el: HTMLElement, mapOptions: mapTypes.MapOptions): Promise {
28 | const res = this._loader.load().then(() => {
29 | const create = () => setTimeout(() => {
30 | if (ymaps.Map) {
31 | const map = new ymaps.Map(el, mapOptions);
32 | this._mapResolver(map as mapTypes.YandexMap);
33 | } else {
34 | create();
35 | }
36 | }, 100);
37 | create();
38 | }).catch((e) => console.log(e));
39 | return res;
40 | }
41 |
42 | public setCenter(latitude: number, longitude: number) {
43 | this._map.then((map: mapTypes.YandexMap) => {
44 | map.setCenter([latitude, longitude]);
45 | });
46 | }
47 |
48 | public getCenter(): Promise {
49 | return this._map.then((map: mapTypes.YandexMap) => {
50 | return map.getCenter();
51 | });
52 | }
53 |
54 | public panTo(points: any[], options: any[]) {
55 | this._map.then((map: mapTypes.YandexMap) => {
56 | map.panTo(points, options);
57 | });
58 | }
59 |
60 | public subscribeToMapEvent(eventName: string): Observable {
61 | return Observable.create((observer: Observer) => {
62 | this._map.then((m: mapTypes.YandexMap) => {
63 | m.events.add(eventName, (arg: E) => { this._zone.run(() => observer.next(arg)); });
64 | });
65 | });
66 | }
67 |
68 | public createMarker(marker: YaMarker): Promise {
69 | return this._map.then((map: mapTypes.YandexMap) => {
70 | const m = new ymaps.Placemark([marker.latitude, marker.longitude], {
71 | balloonContentHeader: marker.balloonContentHeader,
72 | balloonContentBody: marker.balloonContentBody,
73 | balloonContentFooter: marker.balloonContentFooter,
74 | iconContent: marker.iconContent
75 | },
76 | {
77 | draggable: marker.draggable,
78 | preset: marker.preset,
79 | iconLayout: marker.iconLayout,
80 | iconImageHref: marker.iconImageHref,
81 | iconImageSize: marker.iconImageSize,
82 | iconImageOffset: marker.iconImageOffset
83 | });
84 | map.geoObjects.add(m);
85 | return m;
86 | });
87 | }
88 |
89 | public removeGeo(overlay: any) {
90 | this._map.then((map: mapTypes.YandexMap) => {
91 | map.geoObjects.remove(overlay);
92 | });
93 | }
94 |
95 | public createClaster(claster: YaClaster): Promise {
96 | return this._map.then((map: mapTypes.YandexMap) => {
97 | if (claster.markers.length === 0) {
98 | return;
99 | }
100 |
101 | let myGeoObjects: any[];
102 | myGeoObjects = new Array();
103 | claster.markers.forEach((x: mapTypes.MarkerClaster) => {
104 | const point = new ymaps.GeoObject({
105 | geometry: { type: x.type, coordinates: [x.lat, x.lng] }
106 | });
107 | myGeoObjects.push(point);
108 | });
109 |
110 | const clusterer = new ymaps.Clusterer({});
111 | clusterer.add(myGeoObjects);
112 | map.geoObjects.add(clusterer);
113 |
114 | return clusterer;
115 | });
116 |
117 | }
118 |
119 | public createObjectManager(objectManager: YaObjectManager): any {
120 | return this._map.then((map: mapTypes.YandexMap) => {
121 |
122 | if (objectManager.datasource.length === 0) {
123 | return;
124 | }
125 |
126 | const nativeObjectManager = new ymaps.ObjectManager({
127 | clusterize: objectManager.clusterize,
128 | gridSize: objectManager.gridSize
129 | });
130 |
131 | nativeObjectManager.add(objectManager.datasource);
132 |
133 | nativeObjectManager.objects.options.set('preset', objectManager.objectPreset);
134 | nativeObjectManager.clusters.options.set('preset', objectManager.clasterPreset);
135 | map.geoObjects.add(nativeObjectManager);
136 | return nativeObjectManager;
137 | });
138 | }
139 |
140 | public navigateToGeoObject(objectManager: any, id: any) {
141 | const obj = objectManager.objects.getById(id);
142 | if (obj) {
143 | this.setCenter(obj.geometry.coordinates[0], obj.geometry.coordinates[1]);
144 | objectManager.objects.balloon.open(id);
145 | }
146 | }
147 |
148 | public checkYaSciptLoaded() {
149 | return this._documentRef.getNativeDocument().getElementById('YaScript');
150 | }
151 |
152 | public objectManagerSetFilter(objectManager: any, filter: any) {
153 | objectManager.setFilter(filter);
154 | }
155 |
156 | }
157 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/ya-maps-types.ts:
--------------------------------------------------------------------------------
1 | export let yandex: any;
2 |
3 | export interface MVCObject { addListener(eventName: string, handler: Function): MapsEventListener; }
4 |
5 | export interface YandexMap extends MVCObject {
6 |
7 | // constructor(el: HTMLElement, opts?: MapOptions): void;
8 | events: any;
9 | geoObjects: any;
10 | setCenter(param: any[]): void;
11 | getCenter(): any;
12 | panTo(points: any[], options: any[]): void;
13 | removeOverlay(overlay: any): void;
14 | }
15 |
16 | export interface LatLng {
17 | // constructor(lat: number, lng: number): void;
18 | lat(): number;
19 | lng(): number;
20 | }
21 | export interface PanToObjects {
22 | points: any[];
23 | params: any[];
24 | }
25 |
26 | export interface Marker extends MVCObject {
27 | // constructor(): void;
28 | events: any;
29 | balloon: any;
30 | layoutBalloon: any;
31 | balloonContentHeader: string;
32 | balloonContentBody: string;
33 | balloonContentFooter: string;
34 | draggable: boolean;
35 | iconLayout: any;
36 | iconImageHref: any;
37 | iconImageSize: any;
38 | iconImageOffset: any;
39 | setMap(map: YandexMap): void;
40 | setPosition(latLng: LatLng | LatLngLiteral): void;
41 | }
42 |
43 | export interface Claster {
44 | // tslint:disable-next-line:no-misused-new
45 | constructor(): void;
46 | }
47 |
48 | export interface MarkerClaster {
49 | lat: number;
50 | lng: number;
51 | balloonContentHeader: string;
52 | balloonContentBody: string;
53 | balloonContentFooter: string;
54 | type: string;
55 | }
56 |
57 | export interface LatLngLiteral {
58 | lat: number;
59 | lng: number;
60 | }
61 |
62 |
63 | export interface MapsEventListener { remove(): void; }
64 | export interface MouseEvent { latLng: LatLng; get: any; }
65 | export interface MapClickMouseEvent { lat: number; lng: number; }
66 | export interface MapMouseEvent { lat: number; lng: number; nativeMarker: any; }
67 | export interface MapOptions {
68 | zoom?: number;
69 | minZoom?: number;
70 | maxZoom?: number;
71 | center?: any;
72 | type: any;
73 | controls?: any[];
74 | }
75 |
76 | export interface ObjectManager {
77 | clusterize: boolean;
78 | objects: any[];
79 | }
80 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/yamapng.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { YamapngComponent } from './yamapng.component';
4 |
5 | describe('YamapngComponent', () => {
6 | let component: YamapngComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ YamapngComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(YamapngComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/yamapng.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'lib-yamapng',
5 | template: `
6 |
7 | yamapng works!
8 |
9 | `,
10 | styles: []
11 | })
12 | export class YamapngComponent implements OnInit {
13 |
14 | constructor() { }
15 |
16 | ngOnInit() {
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/yamapng.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { YamapngComponent } from './yamapng.component';
3 |
4 | @NgModule({
5 | declarations: [YamapngComponent],
6 | imports: [
7 | ],
8 | exports: [YamapngComponent]
9 | })
10 | export class YamapngModule { }
11 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/yamapng.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed } from '@angular/core/testing';
2 |
3 | import { YamapngService } from './yamapng.service';
4 |
5 | describe('YamapngService', () => {
6 | beforeEach(() => TestBed.configureTestingModule({}));
7 |
8 | it('should be created', () => {
9 | const service: YamapngService = TestBed.get(YamapngService);
10 | expect(service).toBeTruthy();
11 | });
12 | });
13 |
--------------------------------------------------------------------------------
/projects/yamapng/src/lib/yamapng.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 |
3 | @Injectable({
4 | providedIn: 'root'
5 | })
6 | export class YamapngService {
7 |
8 | constructor() { }
9 | }
10 |
--------------------------------------------------------------------------------
/projects/yamapng/src/public_api.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Public API Surface of yamapng
3 | */
4 |
5 | export * from './lib/yamapng.service';
6 | export * from './lib/yamapng.component';
7 | export * from './lib/yamapng.module';
8 | export * from './lib/core.module';
9 |
--------------------------------------------------------------------------------
/projects/yamapng/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'core-js/es7/reflect';
4 | import 'zone.js/dist/zone';
5 | import 'zone.js/dist/zone-testing';
6 | import { getTestBed } from '@angular/core/testing';
7 | import {
8 | BrowserDynamicTestingModule,
9 | platformBrowserDynamicTesting
10 | } from '@angular/platform-browser-dynamic/testing';
11 |
12 | declare const require: any;
13 |
14 | // First, initialize the Angular testing environment.
15 | getTestBed().initTestEnvironment(
16 | BrowserDynamicTestingModule,
17 | platformBrowserDynamicTesting()
18 | );
19 | // Then we find all the tests.
20 | const context = require.context('./', true, /\.spec\.ts$/);
21 | // And load the modules.
22 | context.keys().map(context);
23 |
--------------------------------------------------------------------------------
/projects/yamapng/tsconfig.lib.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../out-tsc/lib",
5 | "target": "es2015",
6 | "module": "es2015",
7 | "moduleResolution": "node",
8 | "declaration": true,
9 | "sourceMap": true,
10 | "inlineSources": true,
11 | "emitDecoratorMetadata": true,
12 | "experimentalDecorators": true,
13 | "importHelpers": true,
14 | "types": [],
15 | "lib": [
16 | "dom",
17 | "es2018"
18 | ]
19 | },
20 | "angularCompilerOptions": {
21 | "annotateForClosureCompiler": true,
22 | "skipTemplateCodegen": true,
23 | "strictMetadataEmit": true,
24 | "fullTemplateTypeCheck": true,
25 | "strictInjectionParameters": true,
26 | "enableResourceInlining": true
27 | },
28 | "exclude": [
29 | "src/test.ts",
30 | "**/*.spec.ts"
31 | ]
32 | }
33 |
--------------------------------------------------------------------------------
/projects/yamapng/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../out-tsc/spec",
5 | "types": [
6 | "jasmine",
7 | "node"
8 | ]
9 | },
10 | "files": [
11 | "src/test.ts"
12 | ],
13 | "include": [
14 | "**/*.spec.ts",
15 | "**/*.d.ts"
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/projects/yamapng/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "lib",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "lib",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { AppComponent } from './app.component';
3 |
4 | describe('AppComponent', () => {
5 | beforeEach(async(() => {
6 | TestBed.configureTestingModule({
7 | declarations: [
8 | AppComponent
9 | ],
10 | }).compileComponents();
11 | }));
12 |
13 | it('should create the app', () => {
14 | const fixture = TestBed.createComponent(AppComponent);
15 | const app = fixture.debugElement.componentInstance;
16 | expect(app).toBeTruthy();
17 | });
18 |
19 | it(`should have as title 'ymapng'`, () => {
20 | const fixture = TestBed.createComponent(AppComponent);
21 | const app = fixture.debugElement.componentInstance;
22 | expect(app.title).toEqual('ymapng');
23 | });
24 |
25 | it('should render title in a h1 tag', () => {
26 | const fixture = TestBed.createComponent(AppComponent);
27 | fixture.detectChanges();
28 | const compiled = fixture.debugElement.nativeElement;
29 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to ymapng!');
30 | });
31 | });
32 |
--------------------------------------------------------------------------------
/src/app/app.component.styl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnteaterKit/angular2-yandex-maps/9e32d7322847e7d409d8ce1c075d0b91a0bf79e9/src/app/app.component.styl
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.styl']
7 | })
8 | export class AppComponent {
9 | title = 'ymapng';
10 |
11 | markers: any[] = [
12 | {
13 | id: 0,
14 | src: 'https://www.tsum.ru/local/gulp/dist/assets/images/logo.svg',
15 | name: 'ЦУМ',
16 | lat: 55.847,
17 | lng: 38.6,
18 | balloonHeader: '22U',
19 | balloonBody: `
`,
22 | balloonFooter: 'Footette',
23 | draggable: true,
24 | preset: 'islands#violetStretchyIcon',
25 | iconContent: 'Move me!!!',
26 | showInfo: false
27 | },
28 | {
29 | id: 1,
30 | src: 'http://project-volna.ru/wp-content/uploads/udf_foundry/images/logo.png',
31 | name: 'Volna',
32 | lat: 55.847,
33 | lng: 37.6,
34 | balloonHeader: '22U',
35 | balloonBody: `
`,
38 | balloonFooter: 'Footette',
39 | draggable: true,
40 | preset: 'islands#blueSportIcon',
41 | showInfo: false
42 | },
43 | {
44 | id: 2,
45 | src: 'http://caviarclothes.ru/wp-content/uploads/2013/06/mini-logo1.png',
46 | name: 'Caviarclothes',
47 | lat: 55.547,
48 | lng: 37.2,
49 | balloonHeader: '22U',
50 | balloonBody: `
`,
53 | balloonFooter: 'Footette',
54 | draggable: true,
55 | preset: 'islands#oliveStretchyIcon',
56 | showInfo: false
57 | }
58 | ,
59 | {
60 | id: 3,
61 | src: 'http://rodinastore.ru/wp-content/themes/rodina/images/logo.png',
62 | name: 'Rodina',
63 | lat: 55.247,
64 | lng: 35.2,
65 | balloonHeader: '22U',
66 | balloonBody: `
`,
69 | balloonFooter: 'Footette',
70 | draggable: true,
71 | preset: 'islands#blueSportIcon',
72 | showInfo: false
73 | }
74 | ,
75 | {
76 | id: 4,
77 | src: 'https://brandshop.ru/catalog/view/theme/default/i/logo-white.png',
78 | name: 'Brandshop',
79 | lat: 55.347,
80 | lng: 37.0,
81 | balloonHeader: '22U',
82 | balloonBody: `
`,
85 | balloonFooter: 'Footette',
86 | draggable: true,
87 | preset: 'islands#oliveStretchyIcon',
88 | showInfo: false
89 | }
90 | ];
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 |
4 | import { AppComponent } from './app.component';
5 | import { YamapngModule } from 'projects/yamapng/src/public_api';
6 | import { YaCoreModule } from 'projects/yamapng/src/lib/core.module';
7 |
8 | @NgModule({
9 | declarations: [
10 | AppComponent
11 | ],
12 | imports: [
13 | BrowserModule,
14 | YamapngModule,
15 | YaCoreModule.forRoot({
16 | apiKey: ''
17 | })
18 | ],
19 | providers: [],
20 | bootstrap: [AppComponent]
21 | })
22 | export class AppModule { }
23 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnteaterKit/angular2-yandex-maps/9e32d7322847e7d409d8ce1c075d0b91a0bf79e9/src/assets/.gitkeep
--------------------------------------------------------------------------------
/src/browserslist:
--------------------------------------------------------------------------------
1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 | #
5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
6 |
7 | > 0.5%
8 | last 2 versions
9 | Firefox ESR
10 | not dead
11 | not IE 9-11
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false
7 | };
8 |
9 | /*
10 | * For easier debugging in development mode, you can import the following file
11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12 | *
13 | * This import should be commented out in production mode because it will have a negative impact
14 | * on performance if an error is thrown.
15 | */
16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
17 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnteaterKit/angular2-yandex-maps/9e32d7322847e7d409d8ce1c075d0b91a0bf79e9/src/favicon.ico
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ymapng
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, '../coverage'),
20 | reports: ['html', 'lcovonly', 'text-summary'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false
30 | });
31 | };
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule)
12 | .catch(err => console.error(err));
13 |
--------------------------------------------------------------------------------
/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/guide/browser-support
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/
22 | // import 'core-js/es6/symbol';
23 | // import 'core-js/es6/object';
24 | // import 'core-js/es6/function';
25 | // import 'core-js/es6/parse-int';
26 | // import 'core-js/es6/parse-float';
27 | // import 'core-js/es6/number';
28 | // import 'core-js/es6/math';
29 | // import 'core-js/es6/string';
30 | // import 'core-js/es6/date';
31 | // import 'core-js/es6/array';
32 | // import 'core-js/es6/regexp';
33 | // import 'core-js/es6/map';
34 | // import 'core-js/es6/weak-map';
35 | // import 'core-js/es6/set';
36 |
37 | /**
38 | * If the application will be indexed by Google Search, the following is required.
39 | * Googlebot uses a renderer based on Chrome 41.
40 | * https://developers.google.com/search/docs/guides/rendering
41 | **/
42 | // import 'core-js/es6/array';
43 |
44 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
45 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
46 |
47 | /** IE10 and IE11 requires the following for the Reflect API. */
48 | // import 'core-js/es6/reflect';
49 |
50 | /**
51 | * Web Animations `@angular/platform-browser/animations`
52 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
53 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
54 | **/
55 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
56 |
57 | /**
58 | * By default, zone.js will patch all possible macroTask and DomEvents
59 | * user can disable parts of macroTask/DomEvents patch by setting following flags
60 | */
61 |
62 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
63 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
64 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
65 |
66 | /*
67 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
68 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
69 | */
70 | // (window as any).__Zone_enable_cross_context_check = true;
71 |
72 | /***************************************************************************************************
73 | * Zone JS is required by default for Angular itself.
74 | */
75 | import 'zone.js/dist/zone'; // Included with Angular CLI.
76 |
77 |
78 | /***************************************************************************************************
79 | * APPLICATION IMPORTS
80 | */
81 |
--------------------------------------------------------------------------------
/src/styles.styl:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 | .map-container-inner
3 | {
4 | width: 300px;
5 | height: 200px;
6 | }
--------------------------------------------------------------------------------
/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone-testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: any;
11 |
12 | // First, initialize the Angular testing environment.
13 | getTestBed().initTestEnvironment(
14 | BrowserDynamicTestingModule,
15 | platformBrowserDynamicTesting()
16 | );
17 | // Then we find all the tests.
18 | const context = require.context('./', true, /\.spec\.ts$/);
19 | // And load the modules.
20 | context.keys().map(context);
21 |
--------------------------------------------------------------------------------
/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "types": []
6 | },
7 | "exclude": [
8 | "test.ts",
9 | "**/*.spec.ts"
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "types": [
6 | "jasmine",
7 | "node"
8 | ]
9 | },
10 | "files": [
11 | "test.ts",
12 | "polyfills.ts"
13 | ],
14 | "include": [
15 | "**/*.spec.ts",
16 | "**/*.d.ts"
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/src/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "app",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "app",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": true,
3 | "compilerOptions": {
4 | "baseUrl": "./",
5 | "outDir": "./dist/out-tsc",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "module": "es2015",
9 | "moduleResolution": "node",
10 | "emitDecoratorMetadata": true,
11 | "experimentalDecorators": true,
12 | "importHelpers": true,
13 | "target": "es5",
14 | "typeRoots": [
15 | "node_modules/@types"
16 | ],
17 | "lib": [
18 | "es2018",
19 | "dom"
20 | ],
21 | "paths": {
22 | "yamapng": [
23 | "dist/yamapng"
24 | ],
25 | "yamapng/*": [
26 | "dist/yamapng/*"
27 | ]
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "arrow-return-shorthand": true,
7 | "callable-types": true,
8 | "class-name": true,
9 | "comment-format": [
10 | true,
11 | "check-space"
12 | ],
13 | "curly": true,
14 | "deprecation": {
15 | "severity": "warn"
16 | },
17 | "eofline": true,
18 | "forin": true,
19 | "import-blacklist": [
20 | true,
21 | "rxjs/Rx"
22 | ],
23 | "import-spacing": true,
24 | "indent": [
25 | true,
26 | "spaces"
27 | ],
28 | "interface-over-type-literal": true,
29 | "label-position": true,
30 | "max-line-length": [
31 | true,
32 | 140
33 | ],
34 | "member-access": false,
35 | "member-ordering": [
36 | true,
37 | {
38 | "order": [
39 | "static-field",
40 | "instance-field",
41 | "static-method",
42 | "instance-method"
43 | ]
44 | }
45 | ],
46 | "no-arg": true,
47 | "no-bitwise": true,
48 | "no-console": [
49 | true,
50 | "debug",
51 | "info",
52 | "time",
53 | "timeEnd",
54 | "trace"
55 | ],
56 | "no-construct": true,
57 | "no-debugger": true,
58 | "no-duplicate-super": true,
59 | "no-empty": false,
60 | "no-empty-interface": true,
61 | "no-eval": true,
62 | "no-inferrable-types": [
63 | true,
64 | "ignore-params"
65 | ],
66 | "no-misused-new": true,
67 | "no-non-null-assertion": true,
68 | "no-redundant-jsdoc": true,
69 | "no-shadowed-variable": true,
70 | "no-string-literal": false,
71 | "no-string-throw": true,
72 | "no-switch-case-fall-through": true,
73 | "no-trailing-whitespace": true,
74 | "no-unnecessary-initializer": true,
75 | "no-unused-expression": true,
76 | "no-use-before-declare": true,
77 | "no-var-keyword": true,
78 | "object-literal-sort-keys": false,
79 | "one-line": [
80 | true,
81 | "check-open-brace",
82 | "check-catch",
83 | "check-else",
84 | "check-whitespace"
85 | ],
86 | "prefer-const": true,
87 | "quotemark": [
88 | true,
89 | "single"
90 | ],
91 | "radix": true,
92 | "semicolon": [
93 | true,
94 | "always"
95 | ],
96 | "triple-equals": [
97 | true,
98 | "allow-null-check"
99 | ],
100 | "typedef-whitespace": [
101 | true,
102 | {
103 | "call-signature": "nospace",
104 | "index-signature": "nospace",
105 | "parameter": "nospace",
106 | "property-declaration": "nospace",
107 | "variable-declaration": "nospace"
108 | }
109 | ],
110 | "unified-signatures": true,
111 | "variable-name": false,
112 | "whitespace": [
113 | true,
114 | "check-branch",
115 | "check-decl",
116 | "check-operator",
117 | "check-separator",
118 | "check-type"
119 | ],
120 | "no-output-on-prefix": true,
121 | "use-input-property-decorator": true,
122 | "use-output-property-decorator": true,
123 | "use-host-property-decorator": true,
124 | "no-input-rename": true,
125 | "no-output-rename": true,
126 | "use-life-cycle-interface": true,
127 | "use-pipe-transform-interface": true,
128 | "component-class-suffix": true,
129 | "directive-class-suffix": true
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/ya-an.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnteaterKit/angular2-yandex-maps/9e32d7322847e7d409d8ce1c075d0b91a0bf79e9/ya-an.png
--------------------------------------------------------------------------------