Skip to content

Commit

Permalink
📝 Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
explooosion committed Feb 2, 2018
1 parent 4acbda8 commit c8a319f
Showing 1 changed file with 119 additions and 64 deletions.
183 changes: 119 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
# Agm-Direction
[![npm version](https://badge.fury.io/js/agm-direction.svg)](https://badge.fury.io/for/js/agm-direction)

[![npm version](https://badge.fury.io/js/agm-direction.svg)](https://badge.fury.io/js/agm-direction)
[![npm](https://img.shields.io/npm/dm/localeval.svg)](https://github.com/explooosion/Agm-Direction)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)
[![Dependency Status](https://david-dm.org/explooosion/Agm-Direction.svg?theme=shields.io)](https://david-dm.org/explooosion/Agm-Direction)

[Agm-Direction](https://github.com/explooosion/Agm-Direction) is the directive for [@agm/core](https://github.com/SebastianM/angular-google-maps)

+ Angular 2+
+ Google Map API

![Agm-Direction](https://i.imgur.com/DCIoXqS.jpg)

## Install
+ you must install @agm/core
## Installation

Installation is done using the
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):

+ You must install @agm/core
```bash
npm install --save @agm/core
```
+ install agm-direction

+ Install agm-direction
```bash
npm install --save agm-direction
```

## Import
## Importing Modules

+ @agm/core
+ agm-direction
Expand All @@ -27,8 +37,8 @@ import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

import { AgmCoreModule } from '@agm/core';
import { AgmDirectionModule } from 'agm-direction';
import { AgmCoreModule } from '@agm/core'; // @agm/core
import { AgmDirectionModule } from 'agm-direction'; // agm-direction

@NgModule({
declarations: [
Expand All @@ -45,88 +55,130 @@ import { AgmDirectionModule } from 'agm-direction';
bootstrap: [AppComponent]
})
export class AppModule { }

```

## Use
+ HTML
```html
<agm-map [latitude]="lat" [longitude]="lng">
## Usage

<agm-direction *ngIf="dir" [origin]="dir.origin" [destination]="dir.destination"></agm-direction>
+ HTML

</agm-map>
```html
<agm-map [latitude]="lat" [longitude]="lng">
<agm-direction *ngIf="dir" [origin]="dir.origin" [destination]="dir.destination"></agm-direction>
</agm-map>

<button type="button" (click)="getDirection()">Get</button>
```
<button type="button" (click)="getDirection()">Get</button>
```

+ CSS
```css
agm-map {
height: 400px;
}
```

```css
agm-map {
height: 400px;
}
```

+ TS
```ts
lat: Number = 24.799448;
lng: Number = 120.979021;
zoom: Number = 14;

dir = undefined;
```ts
lat: Number = 24.799448;
lng: Number = 120.979021;
zoom: Number = 14;

dir = undefined;

public getDirection() {
this.dir = {
origin: { lat: 24.799448, lng: 120.979021 },
destination: { lat: 24.799524, lng: 120.975017 }
public getDirection() {
this.dir = {
origin: { lat: 24.799448, lng: 120.979021 },
destination: { lat: 24.799524, lng: 120.975017 }
}
}
}
```
```

## Properties

## Attribute
+ origin: { lat, lng };
+ destination: { lat, lng };
+ waypoints: object = [];
+ travelMode: string = 'DRIVING';
+ optimizeWaypoints: boolean = true;
+ visible: boolean = true;
+ panel: object = undefined;
+ @Input() `origin`: { lat: Number, lng: Number };
+ @Input() `destination`: { lat: Number, lng: Number };
+ @Input() `waypoints`: object = [];
+ @Input() `travelMode`: string = 'DRIVING';
+ @Input() `optimizeWaypoints`: boolean = true;
+ @Input() `visible`: boolean = true;
+ @Input() `renderOptions`: any;
+ @Input() `panel`: object | undefined;

## Remove Direction
+ You can set `[visible]=false` .
## Options

## Show Panel Direction
[
Displaying text directions with setPanel()](https://developers.google.com/maps/documentation/javascript/examples/directions-panel?hl=zh-tw)
#### Remove Direction

+ HTML
```html
<agm-direction [panel]="myPanel"></agm-direction>
<div #myPanel></div>
```

Or you can use function:
```html
<agm-direction ... [visible]="show"></agm-direction>
```

+ TS

```ts
this.show = false
```

#### Show Panel Direction

Use of the DirectionsRenderer object to display a directions [panel](https://developers.google.com/maps/documentation/javascript/examples/directions-panel?hl=zh-tw).

+ HTML
```html
<agm-direction [panel]="setPanel()"></agm-direction>
<div id="myPanel"></div>
```

```html
<agm-direction ... [panel]="myPanel"></agm-direction>
<div #myPanel></div>
```

Or you could define a function using the panel:

+ HTML
```html
<agm-direction ... [panel]="setPanel()"></agm-direction>
<div id="myPanel"></div>
```

+ TS
```typescript
function setPanel(){
return document.querySelector('#myPanel');
}
```

```ts
function setPanel(){
return document.querySelector('#myPanel');
}
```

#### DirectionsRendererOptions

This object defines the properties that can be set on a [DirectionsRenderer](https://developers.google.com/maps/documentation/javascript/reference#DirectionsRendererOptions) object.

+ HTML

```html
<agm-direction ... [renderOptions]="options"></agm-direction>
```

+ TS

```ts
options = {
suppressMarkers: true,
draggable: true,
...
};
```

## Warning

#### The mission file seems to be part of a third. TS files...
#### Part of a third

The mission file seems to be part of a third. TS files...
![Imgur](https://i.imgur.com/LBDFQ6V.png)

+ ``tsconfig.app.json``
Please include it in `tsconfig.app.json`

```
{
// extends, compilerOptions ...
"include": [
Expand All @@ -136,10 +188,13 @@ function setPanel(){
}
```

#### is not part of the compilation output. Please check...
#### The compilation output

is not part of the compilation output. Please check...

![error](https://user-images.githubusercontent.com/11458959/32315694-202ee1de-bfe8-11e7-87cf-42394526d447.png)

You can use ___--aot___ to fix this error:
You can use `--aot` to fix this error:
```bash
ng serve --aot
```
Expand Down

4 comments on commit c8a319f

@NOVAXamarin
Copy link

@NOVAXamarin NOVAXamarin commented on c8a319f Feb 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having problem on importing the module, compilation errors I had are as follows. Please help
ERROR in .//agm-direction/src/agm-directions.directive.ts
Module build failed: Error: Final loader didn't return a Buffer or String
at runLoaders (D:\DEVELOP\TimeanywhereExt2\TimeanywhereExt2\node_modules\webpack\lib\NormalModule.js:201:46)
at D:\DEVELOP\TimeanywhereExt2\TimeanywhereExt2\node_modules\loader-runner\lib\LoaderRunner.js:370:3
at iterateNormalLoaders (D:\DEVELOP\TimeanywhereExt2\TimeanywhereExt2\node_modules\loader-runner\lib\LoaderRunner.js:211:10)
at iterateNormalLoaders (D:\DEVELOP\TimeanywhereExt2\TimeanywhereExt2\node_modules\loader-runner\lib\LoaderRunner.js:218:10)
at D:\DEVELOP\TimeanywhereExt2\TimeanywhereExt2\node_modules\loader-runner\lib\LoaderRunner.js:233:3
at context.callback (D:\DEVELOP\TimeanywhereExt2\TimeanywhereExt2\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
at runMicrotasksCallback (internal/process/next_tick.js:64:5)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
@ ./
/agm-direction/src/agm-direction.module.ts 10:33-70
@ ./~/agm-direction/index.js
@ ./angularApp/app/app.module.ts
@ ./angularApp/main.ts

@explooosion
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, what is your package version?
(node, angular, agm-direction)

Step 1

Please install the latest version of agm-direction.

  • npm version

Step 2

Please include it in tsconfig.app.json

{
  // extends, compilerOptions ...

  "include": [
    "../src/*",
    "../node_modules/agm-direction/*"
  ],
}  

@NOVAXamarin
Copy link

@NOVAXamarin NOVAXamarin commented on c8a319f Feb 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your response @explooosion.
The version is "version": "0.3.5"
I had done the step2 in file tsconfig.json not tsconfig.app.json, and still had the issue.
By the way, in the system I am working on, I do not see file tsconfig.app.json

@explooosion
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether my understanding is correct.
Maybe agm-direction isn't the main problem.

Please check the typescript version in package.json

{
  "typescript": "~2.5.3"
}

Do you use 3rd party libraries/frameworks in your projects?
Please check this discussion:

Hope it is useful for you 🙂

Please sign in to comment.