Skip to content

Commit

Permalink
buttons to check expor/import mouse shadow (#28)
Browse files Browse the repository at this point in the history
* buttons to check expor/import mouse shadow

* update style

* not use ansynapi store

* update ansyn version

* xvdb as service
  • Loading branch information
tltk90 authored Jul 25, 2019
1 parent 8d7a53e commit c8ad87f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 30 deletions.
54 changes: 27 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ yarn upgrade @ansyn/ansyn @ansyn/assets
```

## Usage
add ansyn to your assets / styles on `angular.json` file, under yourProject/architect/build/options:
1.add ansyn to your assets / styles on `angular.json` file, under yourProject/architect/build/options:

```json
"assets": [
Expand All @@ -38,15 +38,24 @@ add ansyn to your assets / styles on `angular.json` file, under yourProject/arc
]
```

on `main.ts` file:
2.on `main.ts` file:

```typescript
import { fetchConfigProviders } from '@ansyn/ansyn';

fetchConfigProviders('assets/config/app.config.json').then(providers => platformBrowserDynamic(providers).bootstrapModule(AppModule).catch(err => console.log(err)));
```

on `app.module.ts`:
You can provide an object that override the default configuration of your Ansyn app.(let's say we called it overrideConfig) ,
then you need to pass it to the `fetchConfigProviders` function from `@ansyn/ansyn` with the path of the original configuration('assets/config/app.config.json') which return you a promise with provider then pass it to `platformBrowserDynamic` function.
```typescript
fetchConfigProviders('assets/config/app.config.json', overrideConfig)
.then(providers => platformBrowserDynamic(providers).bootstrapModule(AppModule).catch(err => console.log(err)));
```
Learn more about `Ansyn` [configuration](https://github.com/AnSyn/ansyn/wiki/Ansyn-configuration).


3.on `app.module.ts`:
```typescript
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
Expand All @@ -67,29 +76,15 @@ import { AnsynModule } from '@ansyn/ansyn';
export class AppModule { }
```

on `app.component.html`:
4.on `app.component.html`:

```html
...
<ansyn-app></ansyn-app>
...
```
`AnsynApi` service on `ansyn.component.ts`:
```typescript
import { AnsynApi } from '@ansyn/ansyn';

@Component({
...
})
export class AppComponent {
constructor(protected ansynApi: AnsynApi) {
}
}
```

Learn more about [AnsynApi](https://github.com/AnSyn/ansyn/wiki/Ansyn-Package).

on `app.component.css`:
5.on `app.component.css`:

The element `ansyn-app` has to receive height. It can be explicit height, or implicit like "display:flex" + "flex:1"
For example:
Expand All @@ -102,15 +97,20 @@ ansyn-app {
}
```

on `main.ts`:

You can provide an object that override the default configuration of your Ansyn app.(let's say we called it overrideConfig) ,
then you need to pass it to the `fetchConfigProviders` function from `@ansyn/ansyn` with the path of the original configuration('assets/config/app.config.json') which return you a promise with provider then pass it to `platformBrowserDynamic` function.
6.inject `AnsynApi` service on `ansyn.component.ts`:
```typescript
fetchConfigProviders('assets/config/app.config.json', overrideConfig)
.then(providers => platformBrowserDynamic(providers).bootstrapModule(AppModule).catch(err => console.log(err)));
```
Learn more about `Ansyn` [configuration](https://github.com/AnSyn/ansyn/wiki/Ansyn-configuration).
import { AnsynApi } from '@ansyn/ansyn';

@Component({
...
})
export class AppComponent {
constructor(protected ansynApi: AnsynApi) {
}
}
```
Learn more about [AnsynApi](https://github.com/AnSyn/ansyn/wiki/Ansyn-Package#AnsynApi).


### Add custome menu item

Expand Down
4 changes: 4 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ <h1> Angular 2 implementation </h1>
<button (click)="setOverlays()">set overlays</button>
<button (click)="displayOverlay()">display overlay</button>
<button (click)="displayTwoOverlays()">display two overlays</button>
<button (click)="getMouseShadowPoint()">
{{mouseShadowOutputSubscription? 'disable get mouse coordinate' : 'enable get mouse coordinate'}}
</button>
<button (click)="setMouseShadowPoint()">get mouse coordinate</button>

</div>

Expand Down
23 changes: 20 additions & 3 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Component } from '@angular/core';
import { AnsynApi, GeoRegisteration, IOverlay } from '@ansyn/ansyn';
import { FeatureCollection } from 'geojson';
import * as momentNs from 'moment';
import { Observable } from 'rxjs';
import {Observable, Subscription} from 'rxjs';
import { take, tap } from 'rxjs/operators';
import { layoutOptions } from '@ansyn/map-facade';
import { LayoutKey } from '@ansyn/map-facade';
Expand All @@ -20,6 +20,7 @@ const moment = momentNs;
export class AppComponent {
layoutKeys: LayoutKey[] = Array.from(layoutOptions.keys());
featureOptions: FeatureCollection<any>;
mouseShadowOutputSubscription: Subscription;

overlays = [
this.overlay('000', 'https://upload.wikimedia.org/wikipedia/commons/e/e2/Reeipublic_Banana.gif',
Expand Down Expand Up @@ -86,8 +87,9 @@ export class AppComponent {
this.getFeatureCollectionFromFile().subscribe(response => {
this.featureOptions = response.featureCollection;
});
this.ansynApi.getActiveCenter$.subscribe((center) => {
console.log(center);

this.ansynApi.onReady.subscribe( (ready) => {
console.log('ready: ' + ready);
});
}

Expand Down Expand Up @@ -129,4 +131,19 @@ export class AppComponent {
take(1)
).subscribe();
}

getMouseShadowPoint() {
if (this.mouseShadowOutputSubscription) {
this.mouseShadowOutputSubscription.unsubscribe();
this.mouseShadowOutputSubscription = undefined;
} else {
this.mouseShadowOutputSubscription = this.ansynApi.onShadowMouseProduce$.pipe(
tap(coordinate => console.log('Shadow mouse: ' + coordinate))
).subscribe();
}
}

setMouseShadowPoint() {
this.ansynApi.setOutSourceMouseShadow([-122.3857620823084, 37.62041171284878]);
}
}

0 comments on commit c8ad87f

Please sign in to comment.