Skip to content

Commit

Permalink
Merge pull request #33 from xieziyu/dev
Browse files Browse the repository at this point in the history
Release v2.2.0
  • Loading branch information
Xie, Ziyu authored Nov 28, 2018
2 parents 4c1d0cb + 701c5b3 commit 06626b2
Show file tree
Hide file tree
Showing 71 changed files with 1,718 additions and 83 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 2.2.0 (2018-11-26)

#### New
+ 支持路径规划:
+ AMap.Driving 驾车路线规划服务:AmapDrivingService
+ AMap.TruckDriving 货车路线规划服务:AmapTruckDrivingService
+ AMap.Transfer 公交换乘路线规划服务:AmapTransferService
+ AMap.Walking 步行路线规划服务:AmapWalkingService
+ AMap.Riding 骑行路线规划服务:AmapRidingService

----

## 2.1.1 & 1.3.3 (2018-06-22)

#### Bugfix
Expand Down
71 changes: 26 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ngx-amap
[![npm version](https://badge.fury.io/js/ngx-amap.svg)](https://badge.fury.io/js/ngx-amap)
[![npm downloads](https://img.shields.io/npm/dm/ngx-amap.svg)](https://npmjs.org/ngx-amap)
[![Build Status](https://travis-ci.org/xieziyu/ngx-amap.svg?branch=master)](https://travis-ci.org/xieziyu/ngx-amap)
[![npm](https://img.shields.io/npm/v/ngx-amap.svg)][npm-badge-url]
[![npm](https://img.shields.io/npm/dm/ngx-amap.svg)][npm-badge-url]
[![Build Status](https://travis-ci.org/xieziyu/ngx-amap.svg?branch=master)][ci-url]

+ [在线演示](https://xieziyu.github.io/ngx-amap)
+ [模块文档](https://xieziyu.github.io/ngx-amap/api-doc)
Expand All @@ -20,7 +20,7 @@ ngx-amap 是为在**Angular**(ver >= 2.x)项目中便捷、高效地使用**高

# 版本信息
@npm:
+ `v2.1.1` for Angular >= 6
+ `v2.x` for Angular >= 6
+ `v1.3.3` for Angular < 6

Github branches:
Expand All @@ -29,10 +29,18 @@ Github branches:


# 最新进度
2018.06.22: v2.1.1 & v1.3.3:
2018.11.28: v2.2.0
+ 新增支持路径规划:
+ AMap.Driving 驾车路线规划服务:AmapDrivingService
+ AMap.TruckDriving 货车路线规划服务:AmapTruckDrivingService
+ AMap.Transfer 公交换乘路线规划服务:AmapTransferService
+ AMap.Walking 步行路线规划服务:AmapWalkingService
+ AMap.Riding 骑行路线规划服务:AmapRidingService

2018.06.22: v2.1.1 & v1.3.3
+ Bugfix:[amapAutocomplete] 切换city时不起作用 [issue#23](https://github.com/xieziyu/ngx-amap/issues/23)

2018.05.24: v2.1.0:
2018.05.24: v2.1.0
+ 新增支持图层AMap.Heatmap指令:amap-heatmap

2018.05.11: v2.0.0: 支持 Angular 6
Expand All @@ -48,43 +56,6 @@ Github branches:
+ [demo](https://xieziyu.github.io/ngx-amap/#/amap-rectangle/methods) AMap.RectangleEditor编辑功能:amap-rectangle `[editor]="true"`
+ 添加editor相关事件emitter,例如:`(editorAddnode)`, `(editorAdjust)`等,详见示例

2018.03.26: v1.3.0: 覆盖物
+ 新增支持覆盖物AMap.Polygon指令:amap-polygon
+ 新增支持覆盖物AMap.Text指令:amap-text
+ 新增支持覆盖物AMap.BezierCurve指令:amap-bezier-curve
+ 新增支持覆盖物AMap.Ellipse指令:amap-ellipse
+ 新增支持覆盖物AMap.Rectangle指令:amap-rectangle

2018.03.21: v1.2.0
+ 新增支持AMap.MouseTool鼠标工具插件:AmapMouseToolService (感谢: [noob9527](https://github.com/noob9527))

2018.02.28: v1.1.2
+ ngx-amap支持gridMapForeign选项,以显示国外的地图细节

2018.02.05: v1.1.1
+ 新增支持覆盖物AMap.CircleMarker的指令:amap-circle-marker (需要高德API-v1.4.3支持)

2018.02.05: v1.1.0
+ 新增支持覆盖物AMap.Circle的指令:amap-circle
+ 默认高德API的baseUrl调整为https协议
+ 默认高德API的版本调整为1.4.3

2017.11.29: v1.0.1
+ 修复 input[Autocomplete] 指令事件错误的问题

2017.11.29: v1.0.0
+ 新增支持AMap.PlaceSearch的搜索服务:AmapPlaceSearchService

2017.11.28: v1.0.0-beta.4
+ 新增支持AMap.Geocoder的地理服务:AmapGeocoderService
+ 新增支持AMap.Autocomplete的搜索服务和指令:AmapAutocompleteService, AmapAutocompleteDirective
+ 逻辑变更:marker在没有position的时候不再绘制于默认位置
+ 逻辑变更:info-window现在会跟随它的hostMarker改变位置

2017.11.24: 新增支持AMap.MakerClusterer点聚合:amap-marker-clusterer

2017.11.23: 重写了各个组件,尽可能齐全地为每个组件提供了public方法和output事件,以适配高德原生API

# 安装
```bash
$ npm install ngx-amap --save
Expand Down Expand Up @@ -152,8 +123,8 @@ $ yarn add ngx-amap
```typescript
{
apiKey: string; // *必须, 高德地图的开发者license key
apiVersion: string; // [可选],默认是'1.4.1'
urlPath: string; // [可选], 默认是 'http://webapi.amap.com/maps', 可以用它设置HTTPS或者HTTP协议
apiVersion: string; // [可选],默认是'1.4.11'
urlPath: string; // [可选], 默认是 'https://webapi.amap.com/maps', 可以用它设置HTTPS或者HTTP协议
}
```

Expand All @@ -179,6 +150,12 @@ $ yarn add ngx-amap
|`AmapDistrictSearchService`| `Service` | 行政区搜索服务 | **AMap.DistrictSearch** | [demo](https://xieziyu.github.io/ngx-amap/#/AmapDistrictSearchService/simple) |
|`AmapMouseToolService` | `Service` | 鼠标工具插件 | **AMap.MouseTool** | [demo](https://xieziyu.github.io/ngx-amap/#/AmapMouseToolService/simple) |
|`amap-heatmap` | `Directive` | 图层:热力图 | **AMap.Heatmap** | [demo](https://xieziyu.github.io/ngx-amap/#/amap-heatmap/simple) |
|`AmapDrivingService` | `Service` | 驾车路线规划服务 | **AMap.Driving** | [demo](https://xieziyu.github.io/ngx-amap/#/AmapDrivingService/simple) |
|`AmapTruckDrivingService` | `Service` | 货车路线规划服务 | **AMap.TruckDriving** | [demo](https://xieziyu.github.io/ngx-amap/#/AmapTruckDrivingService/simple) |
|`AmapTransferService` | `Service` | 换乘路线规划服务 | **AMap.Transfer** | [demo](https://xieziyu.github.io/ngx-amap/#/AmapTransferService/simple) |
|`AmapWalkingService` | `Service` | 步行路线规划服务 | **AMap.Walking** | [demo](https://xieziyu.github.io/ngx-amap/#/AmapWalkingService/simple) |
|`AmapRidingService` | `Service` | 骑行路线规划服务 | **AMap.Riding** | [demo](https://xieziyu.github.io/ngx-amap/#/AmapRidingService/simple) |


# 类型声明
可以从`ngx-amap/types/class`importAMap类的声明:
Expand Down Expand Up @@ -206,3 +183,7 @@ npm run demo
yarn
yarn demo
```


[npm-badge-url]: https://www.npmjs.com/package/ngx-amap
[ci-url]: https://travis-ci.org/xieziyu/ngx-amap
6 changes: 5 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
"styleext": "scss",
"spec": false
},
"@schematics/angular:module": {
"spec": false
}
},
"architect": {
Expand Down
20 changes: 17 additions & 3 deletions projects/ngx-amap/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{
"name": "ngx-amap",
"version": "2.1.1",
"version": "2.2.0",
"author": "Xie, Ziyu",
"license": "MIT",
"keywords": [
"angular",
"ng",
"map",
"amap"
],
"repository": {
"type" : "git",
"url" : "https://github.com/xieziyu/ngx-amap.git"
},
"homepage": "https://xieziyu.github.io/ngx-amap",
"bugs": "https://github.com/xieziyu/ngx-amap/issues",
"peerDependencies": {
"@angular/common": "^6.0.0-rc.0 || ^6.0.0",
"@angular/core": "^6.0.0-rc.0 || ^6.0.0"
"@angular/common": "^6.0.0-rc.0 || >=6.0.0",
"@angular/core": "^6.0.0-rc.0 || >=6.0.0"
}
}
24 changes: 22 additions & 2 deletions projects/ngx-amap/src/ngx-amap.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import { AmapBezierCurveDirective } from './directives/amap-bezier-curve/amap-be
import { AmapEllipseDirective } from './directives/amap-ellipse/amap-ellipse.directive';
import { AmapRectangleDirective } from './directives/amap-rectangle/amap-rectangle.directive';
import { AmapHeatmapDirective } from './directives/amap-heatmap/amap-heatmap.directive';
import { AmapDrivingService, AmapDrivingWrapper } from './services/amap-driving/amap-driving.service';
import { AmapTruckDrivingService, AmapTruckDrivingWrapper } from './services/amap-truck-driving/amap-truck-driving.service';
import { AmapTransferService, AmapTransferWrapper } from './services/amap-transfer/amap-transfer.service';
import { AmapWalkingService, AmapWalkingWrapper } from './services/amap-walking/amap-walking.service';
import { AmapRidingService, AmapRidingWrapper } from './services/amap-riding/amap-riding.service';

@NgModule({
declarations: [
Expand Down Expand Up @@ -84,7 +89,12 @@ export class NgxAmapModule {
AmapAutocompleteService,
AmapMouseToolService,
AmapPlaceSearchService,
AmapDistrictSearchService
AmapDistrictSearchService,
AmapDrivingService,
AmapTransferService,
AmapWalkingService,
AmapRidingService,
AmapTruckDrivingService
]
};
}
Expand Down Expand Up @@ -115,5 +125,15 @@ export {
AmapBezierCurveDirective,
AmapEllipseDirective,
AmapRectangleDirective,
AmapHeatmapDirective
AmapHeatmapDirective,
AmapDrivingService,
AmapDrivingWrapper,
AmapTransferService,
AmapTransferWrapper,
AmapWalkingService,
AmapWalkingWrapper,
AmapRidingService,
AmapRidingWrapper,
AmapTruckDrivingService,
AmapTruckDrivingWrapper
};
111 changes: 111 additions & 0 deletions projects/ngx-amap/src/services/amap-driving/amap-driving.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { AMapClass, Driving, LngLat } from '../../types/class';
import { DrivingOptions, ILngLat } from '../../types/interface';
import { LoggerService } from '../logger/logger.service';
import { PluginLoaderService } from '../plugin-loader/plugin-loader.service';
import { EventBinder } from '../../utils/event-binder';
import { DrivingResult } from '../../types/class/driving/driving-result';

declare const AMap: AMapClass;

/**
* 驾车路线规划服务
*/
@Injectable()
export class AmapDrivingService {
TAG = 'amap-driving';

private _plugin: Promise<void>;

constructor(private logger: LoggerService, private plugins: PluginLoaderService) {
}

get loaded(): Promise<void> {
if (!this._plugin) {
this._plugin = this.plugins.load('AMap.Driving');
}

return this._plugin;
}

of(opts?: DrivingOptions): Promise<AmapDrivingWrapper> {
return this.loaded.then(() => new AmapDrivingWrapper(opts));
}
}

/**
* AmapDrivingWrapper对象将高德原生的Driving对象提供的方法封装成Promise的实现,更方便回调
*/
export class AmapDrivingWrapper extends EventBinder {
private _driving: Driving;

constructor(opts?: DrivingOptions) {
super();
this._driving = new AMap.Driving(opts);
}

get native(): Driving {
return this._driving;
}

/**
* 用于侦听Driving事件,返回可以被subscribe的Observable对象
* @param event
* @returns
*/
on(event: string): Observable<any> {
return this.bindEvent<Driving>(this._driving, event);
}

search(origin: any[], destination?: ILngLat, opts?: any): Promise<{ status: string, result: string | DrivingResult }> {
if (typeof destination !== 'undefined') {
return new Promise(resolve => this._driving.search(origin, destination, opts, (status, result) => {
resolve({ status, result });
}));
} else {
return new Promise(resolve => this._driving.search(origin, (status, result) => {
resolve({ status, result });
}));
}
}

setPolicy(policy: any) {
this._driving.setPolicy(policy);
}

setAvoidPolygons(path: ILngLat[]) {
this._driving.setAvoidPolygons(path);
}

setAvoidRoad(road: string) {
this._driving.setAvoidRoad(road);
}

clearAvoidRoad() {
this._driving.clearAvoidRoad();
}

clearAvoidPolygons() {
this._driving.clearAvoidPolygons();
}

clear() {
this._driving.clear();
}

getAvoidPolygons(): LngLat[] {
return this._driving.getAvoidPolygons();
}
getAvoidRoad(): string {
return this._driving.getAvoidRoad();
}

setProvinceAndNumber(province: string, number: string) {
this._driving.setProvinceAndNumber(province, number);
}

searchOnAMAP(obj: any) {
this._driving.searchOnAMAP(obj);
}
}
Loading

0 comments on commit 06626b2

Please sign in to comment.