src/directives/map-bubble.ts
Renders buble on map. Please note that directive must be placed inside map component, otherwise it will never be rendered.
Providers |
{
provide: BaseMapComponent, useExisting: forwardRef(() => MapBubbleDirective)
}
|
Selector | map-bubble |
Properties |
|
Methods |
|
Inputs |
Outputs |
Accessors |
constructor(_mapsManager: HereMapsManager)
|
||||||
Defined in src/directives/map-bubble.ts:80
|
||||||
Parameters :
|
clickable
|
If true, the marker receives mouse and touch events. Default value is true.
Type : |
Defined in src/directives/map-bubble.ts:67
|
contentElement
|
Rollover text |
Defined in src/directives/map-bubble.ts:76
|
position
|
Bubble position |
Defined in src/directives/map-bubble.ts:48
|
click
|
This event is fired when the marker icon was clicked. $event Type: EventEmitter<any>
|
Defined in src/directives/map-bubble.ts:38
|
Private bindEvents | ||||||
bindEvents(marker: H.ui.InfoBubble)
|
||||||
Defined in src/directives/map-bubble.ts:110
|
||||||
Parameters :
Returns :
void
|
Public hasMapComponent |
hasMapComponent()
|
Defined in src/directives/map-bubble.ts:86
|
Returns :
boolean
|
Public setMapComponent | ||||||||||||
setMapComponent(component: MapComponent, map: H.Map, ui: H.ui.UI)
|
||||||||||||
Defined in src/directives/map-bubble.ts:90
|
||||||||||||
Parameters :
Returns :
void
|
Private _clickable |
_clickable:
|
Default value : true
|
Defined in src/directives/map-bubble.ts:80
|
Protected mapComponent |
mapComponent:
|
Type : MapComponent
|
Defined in src/directives/map-bubble.ts:28
|
position | ||||
setposition(point)
|
||||
Defined in src/directives/map-bubble.ts:48
|
||||
Bubble position
Parameters :
Returns :
void
|
clickable | ||||||
setclickable(mode: boolean)
|
||||||
Defined in src/directives/map-bubble.ts:67
|
||||||
If true, the marker receives mouse and touch events. Default value is true.
Parameters :
Returns :
void
|
contentElement | ||||
setcontentElement(value)
|
||||
Defined in src/directives/map-bubble.ts:76
|
||||
Rollover text
Parameters :
Returns :
void
|
import {
Directive,
Input,
Output,
EventEmitter,
forwardRef
} from '@angular/core';
import { HereMapsManager } from '../services/maps-manager';
import { BaseMapComponent } from './base-map-component';
import { GeoPoint } from '../interface/lat-lng';
import { toLatLng } from '../utils/position';
import { MapComponent } from './map';
/**
* Renders buble on map. Please note that directive must be placed inside
* map component, otherwise it will never be rendered.
*/
@Directive({
selector: 'map-bubble',
providers: [
{
provide: BaseMapComponent,
useExisting: forwardRef(() => MapBubbleDirective)
}
]
})
export class MapBubbleDirective extends BaseMapComponent<H.ui.InfoBubble> {
protected mapComponent: MapComponent;
/*
* Outputs events
* **********************************************************
*/
/**
* This event is fired when the marker icon was clicked.
*/
@Output()
click: EventEmitter<any> = new EventEmitter<any>();
/*
* Inputs options
* **********************************************************
*/
/**
* Bubble position
*/
@Input()
set position(point: GeoPoint) {
const position = toLatLng(point);
this._mapsManager
.createBubble({ position })
.then((bubble: H.ui.InfoBubble) => {
this.bindEvents(bubble);
this.proxyResolver(bubble);
});
this.proxy.then(bubble => {
bubble.setPosition(toLatLng(point));
});
}
/**
* If true, the marker receives mouse and touch events.
* Default value is true.
*/
@Input()
set clickable(mode: boolean) {
// this.proxy.then(marker => marker.setClickable(mode));
this._clickable = mode;
}
/**
* Rollover text
*/
@Input()
set contentElement(value: HTMLElement) {
this.proxy.then(bubble => bubble.setContent(value));
}
private _clickable = true;
constructor(private _mapsManager: HereMapsManager) {
super();
}
public hasMapComponent(): boolean {
return !!this.mapComponent;
}
public setMapComponent(
component: MapComponent,
map: H.Map,
ui: H.ui.UI
): void {
this.mapComponent = component;
this.proxy.then((mapObject: H.ui.InfoBubble) =>
setTimeout(() => {
if (mapObject instanceof H.ui.InfoBubble) {
ui.addBubble(mapObject);
}
}, this.delay || 0)
);
}
/*
* Internal logic
* **********************************************************
*/
private bindEvents(marker: H.ui.InfoBubble) {
marker.addEventListener('tap', e => {
if (this._clickable) {
this.click.emit(e);
}
});
}
}