Skip to content

Commit

Permalink
Finish: #34. add loaded event for marker component
Browse files Browse the repository at this point in the history
  • Loading branch information
leftstick committed Nov 16, 2017
1 parent 7a004a4 commit 87875eb
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
8 changes: 7 additions & 1 deletion demo/components/apidoc/docMarker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component } from '@angular/core'

import { MapOptions, MarkerOptions, Point } from '../../../src'
import { environment } from '../../environments/environment'
import { BMarker } from '../../../src/types/Marker'

@Component({
selector: 'doc-marker',
Expand All @@ -14,7 +15,7 @@ import { environment } from '../../environments/environment'
<div class="snippet" highlight>
<pre><code class="html">
&lt;baidu-map [options]="expression"&gt;
&lt;marker [point]="expression" [options]="expression" (clicked)="expression"&gt;&lt;/marker&gt;
&lt;marker [point]="expression" [options]="expression" (loaded)="expression" (clicked)="expression"&gt;&lt;/marker&gt;
&lt;/baidu-map&gt;
</code></pre>
</div>
Expand Down Expand Up @@ -43,6 +44,11 @@ import { environment } from '../../environments/environment'
Literal for constructing marker. See <a href="#/apidoc/marker-options">MarkerOptions</a>
</td>
</tr>
<tr>
<td>loaded</td>
<td><span class="label">expression</span></td>
<td>Expression to evaluate upon marker load event. (<code>$event</code> object is available as <a href="http://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference.html#a3b2" target="_blank">BMap.Marker</a>)</td>
</tr>
<tr>
<td>clicked</td>
<td><span class="label">expression</span></td>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular2-baidu-map",
"version": "4.0.1",
"version": "4.1.0",
"description": "Angular2 component for Baidu map",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
Expand Down
2 changes: 2 additions & 0 deletions src/components/marker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class MarkerComponent implements OnInit, OnChanges, OnDestroy {
@Input() private point: Point
@Input() private options: MarkerOptions

@Output() private loaded = new EventEmitter()
@Output() private clicked = new EventEmitter()

private marker: BMarker
Expand All @@ -46,6 +47,7 @@ export class MarkerComponent implements OnInit, OnChanges, OnDestroy {
))
})
.then(({ map }) => {
this.loaded.emit(this.marker)
this.addListener(this.marker, map)
})
.then(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/types/BMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from './Control'
import { BIconConstructor } from './Icon'
import { BInfoWindowConstructor } from './InfoWindow'
import { BLabelConstructor } from './Label'
import { BMapConstructor } from './Map'
import { BMarkerConstructor } from './Marker'
import { BPointConstructor } from './Point'
Expand All @@ -19,6 +20,7 @@ export interface BMap {
Point: BPointConstructor
Size: BSizeConstructor
Icon: BIconConstructor
Label: BLabelConstructor
InfoWindow: BInfoWindowConstructor
NavigationControl: BNavigationControlConstructor
OverviewMapControl: BOverviewMapControlConstructor
Expand Down
21 changes: 21 additions & 0 deletions src/types/Label.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { BPointConstructor } from './Point'
import { BSizeConstructor } from './Size'

export interface BLabelConstructor {
new (content: string, opts?: BLabelOptions): BLabel
}

export interface BLabel {
setStyle(styles: any): void
setContent(content: string): void
setPosition(postion: BPointConstructor): void

setTitle(title: string): void
getTitle(): string
}

export interface BLabelOptions {
offset?: BSizeConstructor
position?: BPointConstructor
enableMassClear?: boolean
}
4 changes: 4 additions & 0 deletions src/types/Marker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BIconConstructor, Icon } from './Icon'
import { BLabel } from './Label'
import { Overlay } from './Overlay'
import { BPointConstructor } from './Point'
import { BSizeConstructor, Size } from './Size'
Expand All @@ -22,6 +23,9 @@ export interface BMarker extends Overlay {
setRotation(rotation: number): void
setShadow(icon: BIconConstructor): void
setTitle(title: string): void

setLabel(label: BLabel): void
getLabel(): BLabel
}

export interface MarkerOptions {
Expand Down

0 comments on commit 87875eb

Please sign in to comment.