angular 2+ component for AMap (高德地图). Please refer to the ngx-amap/demo page.
This project is ongoing ...
2017.09.22: Support AMap.Polyline: amap-polyline
;
2017.09.19: Support ngx-amap
setFitView(); some bugfix;
2017.09.13: Support AMap.InfoWindow: amap-info-window
2017.09.12: Support plugin AMap.ToolBar: amap-tool-bar
npm install ngx-amap --save
-
import
NgxAmapModule
in your app module (or any other proper angular module).- app.module:
import { NgxAmapModule } from 'ngx-amap'; @NgModule({ imports: [ ..., NgxAmapModule.forRoot({ apiKey: '你申请的key' }) ], ... }) export class AppModule { }
- app.module:
-
use
ngx-amap
component with pre-defined height.-
Simple example:
- html:
<ngx-amap class="demo-map"></ngx-amap>
- css:
.demo-map { height: 400px; }
-
-
use
amap-marker
to draw markers inside the map-
Simple example:
- html:
<ngx-amap class="demo-map" [center]="[116.397428, 39.90923]"> <amap-marker [position]="[116.397428, 39.90923]" (markerClick)="onMarkerClick($event)"></amap-marker> </ngx-amap>
-
-
add
amap-tool-bar
to add ToolBar plugin-
Simple example:
- html:
<ngx-amap class="demo-map"> <amap-tool-bar></amap-tool-bar> </ngx-amap>
-
You can setup NgxAmapModule
by forRoot
method. It supports following options:
{
apiKey: string; // *required*. Your developer key for AMap web service.
apiVersion: string; // [optional]. default is '1.3'
urlPath: string; // [optional]. default is 'http://webapi.amap.com/maps', You can change HTTP or HTTPS protocol by this string.
}
ngx-amap
: ngx-amap.mdamap-marker
: amap-marker.mdamap-tool-bar
: amap-tool-bar.mdamap-info-window
: amap-info-window.mdamap-polyline
: amap-polyline.md
Exported some useful type interfaces such as Icon
, Pixel
, etc. Please refer to Types.md.
- clone this repo to your working copy
- modify
demo/src/app/app.module.ts
to use your own KEY for ngx-amap - launch the demo page in your local machine:
npm install
npm run demo